Make lfcd examples safer for people who alias lf to lfcd (#1049)
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.
This commit is contained in:
1 parent
b47cf6d5a5
commit
a4fa5d36c9
2 files changed
+6
-4
No files matched your search
+3
-2
@@ -8,7 +8,7 @@
|
||||
# source "$LFCD"
|
||||
# fi
|
||||
#
|
||||
# You may also like to assign a key to this command:
|
||||
# You may also like to assign a key (Ctrl-O) to this command:
|
||||
#
|
||||
# bind '"\C-o":"lfcd\C-m"' # bash
|
||||
# bindkey -s '^o' 'lfcd\n' # zsh
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
lfcd () {
|
||||
tmp="$(mktemp)"
|
||||
lf -last-dir-path="$tmp" "$@"
|
||||
# `command` is needed in case `lfcd` is aliased to `lf`
|
||||
command lf -last-dir-path="$tmp" "$@"
|
||||
if [ -f "$tmp" ]; then
|
||||
dir="$(cat "$tmp")"
|
||||
rm -f "$tmp"
|
||||
|
||||
Reference in new issue
Block a user