Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.

Is it possible to use escape sequences in statusline?

0 votes
asked May 18, 2018 in vifm by GeorgeHJ

I am trying to make my statusline look fancy by using powerline symbols. My eventual hope is to create a nice informative statusline which emulates the appearance of powerline for tmux.

So far I can print the symbols but I was wondering if there was a trick for using escape sequences to colour in the different segments of the line created by the separator glyphs.

I am pasting my statusline from the vifmrc, but the symbols might not render correctly. It's a little rough as I'm in the process of figuring out my scheme, but it should illustrate what I'm trying to do.

set statusline=" %-26t %=  %A  %7u:%-7g  %-5s %d "

Ideally I would like to use ansi escape sequences like one would for a bash PS1. If not, is there a way to use cterm here?


1 Answer

0 votes
answered May 18, 2018 by xaizek
edited Jun 23, 2018 by xaizek

At the moment there is no such facility.

Escape codes aren't parsed in 'statusline' or 'rulerformat'. Vim's %[0-9]* syntax to insert user defined colors (:hi User1-User9) in those two options also isn't supported.

Not sure which approach is better. They don't seem to conflict with each other though, so theoretically could coexist.


Next version of vifm (after 0.9.1) will support %* macro in 'statusline' as well as italic ":highlight-cterm" attribute. An example using your 'statusline':

highlight User1 ctermbg=yellow
highlight User2 ctermbg=blue ctermfg=231 cterm=italic
highlight User3 ctermbg=blue ctermfg=yellow
highlight User4 ctermbg=yellow ctermfg=blue
let &statusline  = "%1*"         " initial color
let &statusline .= " %-26t "     " file name
let &statusline .= "%3*%2*"     " left separator
let &statusline .= "%="          " fill the whole status line
let &statusline .= "%3*%1*"     " right separator
let &statusline .= " %A "        " file attributes
let &statusline .= "%4*%2*"     " right separator
let &statusline .= " %7u:%-7g "  " user and group owners of the file
let &statusline .= "%3*%1*"     " right separator
let &statusline .= " %-5s "      " human readable file size
let &statusline .= "%4*%2*"     " right separator
let &statusline .= " %d "        " file modification date and time

Colorful statusline

commented May 18, 2018 by George HJ

I see.

Thanks for the clarification.

I've never used the vim method but I imagine it has the same options in another syntax.

I think it would be a really nice option one day and demonstrate a lot of finish in the project. But for now there are so many other things to play with in this great program. When they're tidy I can send you my RC and colorscheme.

commented May 18, 2018 by xaizek

I've never used the vim method but I imagine it has the same options in another syntax.

:highlight lacks "italics" attribute at the moment, but should match otherwise.

When they're tidy I can send you my RC and colorscheme.

Will be glad to add them to the collection.

commented Jul 4, 2018 by GeorgeHJ

Your updated answer looks really cool.

I'm looking forward to the next release!

commented Nov 14, 2018 by GeorgeHJ

The new release has just hit my distro's repositories.

So here's what I've done based upon your example. Thanks so much!

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here is acceptable, but this is not a perfect place for them.