Difference between revisions of "How to set shell working directory after leaving Vifm"
Jump to navigation
Jump to search
m (Add ! to command definition) |
(Add HOWTO category) |
||
Line 27: | Line 27: | ||
mapped to <kbd>ZZ</kbd> and/or <kbd>ZQ</kbd>) will change directory of shell | mapped to <kbd>ZZ</kbd> and/or <kbd>ZQ</kbd>) will change directory of shell | ||
to the directory of current active pane. | to the directory of current active pane. | ||
+ | |||
+ | [[Category:HOWTO]] |
Revision as of 20:52, 28 September 2014
Vifm can't do that on its own, since it's impossible to change working directory of another process (parent shell in this case). Still, it's possible to do this by relying on a shell to do part of the job.
Here is an example, how one can do that with bash:
- Add special command to
vifmrc
command! Q :execute '!echo %d > ~/.vifm/lastdir' | quit
- Add this function to
.bashrc
vifm()
{
if [ -f ~/.vifm/lastdir ]; then
rm ~/.vifm/lastdir
fi
/usr/local/bin/vifm "$@"
if [ -f ~/.vifm/lastdir ]; then
cd `cat ~/.vifm/lastdir`
fi
}
Now running Vifm and quiting it using :Q
command (which can be
mapped to ZZ and/or ZQ) will change directory of shell
to the directory of current active pane.