add Fish version of working dir change function (#75)

* add Fish version of working dir change function

* Fix error with the two conditions

Not empty part is important otherwise arguments like -help or -doc, when lf is
not started actually and there is no *last-dir* will result the `dir` variable
empty and cd to home as `cd` changes directory to home.
This commit is contained in:
Gergő Pintér 2017-05-14 15:57:55 +02:00 committed by gokcehan
parent 3eca9059bf
commit 041fb5ead3

18
etc/lf.fish Normal file
View File

@ -0,0 +1,18 @@
# Change working dir in Fish to last dir in lf on exit (adapted from Bash version)
#
# You need to copy the content of this file to ~/.config/fish/config.fish
#
function lf
set tmp (mktemp)
command lf -last-dir-path=$tmp $argv
if test -f "$tmp"
set dir (cat $tmp)
if test -n "$dir"
if test "$dir" != (pwd)
cd $dir
end
end
end
rm -f $tmp
end