2

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?

George
  • 1,809
  • 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 05 '14 at 20:39
  • I'm a linux newbie and don't know off hand how to verify these things. – George Oct 05 '14 at 20:41
  • Except I can verify that that vifm is indeed installed in /usr/local/bin/ – George Oct 05 '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 05 '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 05 '14 at 21:12

3 Answers3

5

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.

lazzlo
  • 51
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.

Greg Hewgill
  • 7,053
  • 2
  • 32
  • 34
  • This works great (!) except in cases where there are spaces in one of the folder names. – George Oct 05 '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 05 '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?](https://unix.stackexchange.com/q/126927/135943) – Wildcard Oct 08 '19 at 18:12
0

Navigate to the directory you want in vifm. And enter :e. Then you might want to use :terminal.