From 041fb5ead33a2164840670b979ccf0279e050dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Pint=C3=A9r?= Date: Sun, 14 May 2017 15:57:55 +0200 Subject: [PATCH] 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. --- etc/lf.fish | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 etc/lf.fish diff --git a/etc/lf.fish b/etc/lf.fish new file mode 100644 index 0000000..8459000 --- /dev/null +++ b/etc/lf.fish @@ -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