etc/script/lf.sh

22 lines
414 B
Bash
Raw Normal View History

2024-07-12 18:40:54 +03:00
if test "$OS" = "Windows_NT" ; then
2023-08-24 12:48:42 +03:00
lf() {
winpty lf
}
fi
2024-07-12 18:40:54 +03:00
2023-08-24 12:48:42 +03:00
lfcd () {
tmp="$(mktemp)"
# `command` is needed in case `lfcd` is aliased to `lf`
command lf -last-dir-path="$tmp" "$@"
2024-07-12 18:40:54 +03:00
if test -f "$tmp" ; then
2023-08-24 12:48:42 +03:00
dir="$(cat "$tmp")"
rm -f "$tmp"
if [ -d "$dir" ]; then
if [ "$dir" != "$(pwd)" ]; then
cd "$dir"
fi
fi
fi
2024-07-12 18:40:54 +03:00
pwd
2023-08-24 12:48:42 +03:00
}