* 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
19 lines
792 B
Fish
19 lines
792 B
Fish
# Change working dir in fish to last dir in lf on exit (adapted from ranger).
|
|
#
|
|
# You may put this file to a directory in $fish_function_path variable:
|
|
#
|
|
# mkdir -p ~/.config/fish/functions
|
|
# ln -s "/path/to/lfcd.fish" ~/.config/fish/functions
|
|
#
|
|
# You may also like to assign a key (Ctrl-O) to this command:
|
|
#
|
|
# bind \co 'set old_tty (stty -g); stty sane; lfcd; stty $old_tty; commandline -f repaint'
|
|
#
|
|
# You may put this in a function called fish_user_key_bindings.
|
|
|
|
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
|