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.
0 votes
in vifm by

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

edited by

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?


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.


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.