People keep running into an infinite loop and being confused. See https://github.com/gokcehan/lf/issues/140#issuecomment-1256368250 and https://github.com/gokcehan/lf/discussions/1043. This fixes the issues in `lfcd.sh` and `lfcd.fish`. For the other scripts, I'm not sure whether this issue exists or is fixable. One of the discussions above also suggested the need to document the key binding better.
28 lines
810 B
Fish
28 lines
810 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
|
|
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
|
|
end
|