Dotfiles/shells/zsh/includes/lfcd.zsh
2020-02-19 12:07:52 +00:00

12 lines
302 B
Bash

# Use lf to switch directories and bind it to ctrl-o
lfcd () {
tmp="$(mktemp)"
lf -last-dir-path="$tmp" "$@"
if [ -f "$tmp" ]; then
dir="$(cat "$tmp")"
rm -f "$tmp"
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
fi
}
alias lf="lfcd"
bindkey -s '^o' 'lf\n'