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.

Status bar/line customized content

0 votes
asked Aug 7 in vifm by tagwint

Please suggest if / how it is possible to add some dynamic info to status line?
e.g. output of result of some external command
Or at least an environment variable value?
The very least would be just host name :)

1 Answer

+1 vote
answered Aug 7 by xaizek
selected Aug 8 by tagwint
 
Best answer

The easiest way to add environment variables is via :let:

let &statusline = $HOSTNAME . '| some other stuff'

A more cumbersome method, but one that works with versions older than 0.8.1 is to use :execute:

execute 'set' 'statusline="'.$HOSTNAME.' | some other stuff"'

To use external commands that don't produce static output you need to wait for the next release (after 0.9.1), which adds %{...} macro that can have arbitrary expressions, e.g. %{system('hostname')}.

If the command can be called once at startup, :let with system() should do.

commented Aug 8 by tagwint
edited Aug 8 by tagwint

Thank you for prompt reply, @xaizek

Suggested let works fine in v 0.8.2, thanks again.

On other hosts with v 0.8 the it does not :(
I can change statusline content with set statusline
but cannot modify it with let

Furthermore, if i do this interactively using :let &statusline="Customized"
v 0.8.2 accept this, whilst 0.8 throws "Incorrect variable type" message

Am I right thinking this is version - related?
Or there is something else i should check in vifmrc?

commented Aug 8 by xaizek

Yes, :let &option was added in 0.8.1. Updated the answer with an example of using :execute that is available since 0.7.1.

commented Aug 8 by tagwint

Overseen your reply when providing more details in my above comment :)

Yep, execute is my rescue for now.

Appreciate your prompt and friendly support!

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.
...