From ffb2c05dc51bba581021ca96f4abf5fb00970a34 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 16 Apr 2022 18:30:00 +0300 Subject: feat(zsh): add lfcd function --- zsh/.zshrc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'zsh') diff --git a/zsh/.zshrc b/zsh/.zshrc index 380d483..e98fd80 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -71,6 +71,18 @@ bindkey '^y' fzf-tmux-project zle -N fzf-kill-tmux-project bindkey '^x' fzf-kill-tmux-project +# Use lf to switch directories and bind it to ctrl-o +function lfcd () { + tmp="$(mktemp)" + lf -last-dir-path="$tmp" "$@" + if [ -f "$tmp" ]; then + dir="$(cat "$tmp")" + rm -f "$tmp" >/dev/null + [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" + fi +} +bindkey -s '^o' 'lfcd\n' + # Syntax highlighting, must be last source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2> /dev/null -- cgit v1.2.3