1

I'm trying to achieve what was described in the title. I followed these directions (http://sourceforge.net/p/vifm/feature-requests/24/) but they did not work. Here are the instructions I followed:

  1. Add special command to vifmrc command Q :execute '!echo %d > ~/.vifm/lastdir' | quit
  2. Add an alias to .bashrc alias vifm='source ~/bin/vf'
  3. Save the following script to ~/bin/vf if [ -f ~/.vifm/lastdir ]; then rm ~/.vifm/lastdir fi /usr/local/bin/vifm "$@" if [ -f ~/.vifm/lastdir ]; then cd cat ~/.vifm/lastdir fi

I'm most skeptical of (3). I had to create a "bin" folder in my home directory, and then create a "vf" file within the new "bin" to then place the text described in (3). Did I proceed correctly here?

5
  • Is ~/bin in your $PATH? Is ~/bin/vf executable? Is vifm installed at /usr/local/bin/? Personally, I am sceptical about (3) as well... – jasonwryan Oct 5 '14 at 20:39
  • I'm a linux newbie and don't know off hand how to verify these things. – George Oct 5 '14 at 20:41
  • Except I can verify that that vifm is indeed installed in /usr/local/bin/ – George Oct 5 '14 at 20:43
  • echo $PATH will tell you whether ~/bin is included. cd ~/bin && ls -la will show an -x at the end of the string for executable for that script. – jasonwryan Oct 5 '14 at 20:46
  • check if /usr/local/bin/vifm is really work. If not type "which vifm" for exact location. Indentation is also imprtant as in the below answer. – alpert Oct 5 '14 at 21:12
3

Perhaps a reformat of the desired script would be helpful here. It should look exactly like the following:

~/bin/vf

if [ -f ~/.vifm/lastdir ]; then
    rm ~/.vifm/lastdir
fi
/usr/local/bin/vifm "$@"
if [ -f ~/.vifm/lastdir ]; then
    cd "`cat ~/.vifm/lastdir`"
fi

Note in particular the reverse tick marks around the cat command on the second-to-last line, those seem to have gone missing from your version and are rather important. I've also added extra " around the argument to cd in case your current directory has spaces.

This is really a terrible hack to make your program look like it's doing something that programs can't normally do. But, if it helps you get work done, great.

3
  • This works great (!) except in cases where there are spaces in one of the folder names. – George Oct 5 '14 at 22:33
  • 1
    Spaces? You must be new to Linux indeed. :) To fix that, use more quotes. I've updated my answer to add some ". – Greg Hewgill Oct 5 '14 at 22:36
  • 1
    Or just use cd "$(cat ~/.vifm/lastdir)" so you don't need to use backticks. See Have backticks (i.e. `cmd`) in *sh shells been deprecated? – Wildcard Oct 8 '19 at 18:12
3

Maybe you need just to go to terminal? Just do this in vifm

:sh

If you need to aganing enter to vifm you need just make this

exit <OR> ctrl-D

but you enter in vifm in same dir that you entered to this terminal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.