041fb5ead3
* 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.
19 lines
426 B
Fish
19 lines
426 B
Fish
# 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
|