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

I try to create a command to change directory in active window:

command <cmd> :cd <stdout of external_command>

Tried with :cd {<external_command>} and :execute '<external_command>' :cd %u without success. An example will be helpful.

1 Answer

0 votes
by

Using :execute was correct idea, but you also need to use system() function to get the output of an external command:

command! gohome :execute 'cd' system('echo $HOME')

For paths that have spaces this should be better:

command! gohome :execute "cd '".system('echo $HOME')."'"
by

Thanks for the help. Works like a charm

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