diff --git a/etc/lfcd.fish b/etc/lfcd.fish index 6a6ada9b..9007021b 100644 --- a/etc/lfcd.fish +++ b/etc/lfcd.fish @@ -11,17 +11,8 @@ # # You may put this in a function called fish_user_key_bindings. -function lfcd - set tmp (mktemp) - # `command` is needed in case `lfcd` is aliased to `lf` - command lf -last-dir-path=$tmp $argv - if test -f "$tmp" - set dir (cat $tmp) - rm -f $tmp - if test -d "$dir" - if test "$dir" != (pwd) - cd $dir - end - end - end +function lfcd --wraps="lf" --description="lf - Terminal file manager (changing directory on exit)" + # `command` is needed in case `lfcd` is aliased to `lf`. + # Quotes will cause `cd` to not change directory if `lf` prints nothing to stdout due to an error. + cd "$(command lf -print-last-dir $argv)" end