Simplify lfcd

This commit is contained in:
Nawar9 2023-11-23 22:02:49 +01:00 committed by GitHub
parent 0795202675
commit de1f15f92c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,13 +53,7 @@ preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
# Use lf to switch directories and bind it to ctrl-o
lfcd () {
tmp="$(mktemp -uq)"
trap 'rm -f $tmp >/dev/null 2>&1 && trap - HUP INT QUIT TERM PWR EXIT' HUP INT QUIT TERM PWR EXIT
lf -last-dir-path="$tmp" "$@"
if [ -f "$tmp" ]; then
dir="$(cat "$tmp")"
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
fi
cd "$(command lf -print-last-dir "$@")"
}
bindkey -s '^o' '^ulfcd\n'