Skip to content

Commit

Permalink
Enable completions and add description for lfcd.fish and simplify the…
Browse files Browse the repository at this point in the history
… code (#1503)

* Enable completions and add description for lfcd.fish

A simple addition of `--wraps=lf` to the function definition will enable the standard lf completions to be used for `lfcd` function as well.

* Simplify lfcd.fish

* lfcd.fish: unquote $argv

* lfcd.fish: further simplify

* lfcd.fish: cd only on clean exit

* lfcd.fish: further simplify and add a coment on quoting semantics

* lfcd.fish: amend comment style
  • Loading branch information
postsolar authored Dec 11, 2023
1 parent 31f4a4e commit e9571ab
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions etc/lfcd.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e9571ab

Please sign in to comment.