From 8cfebb1165d3d74c6e4c96d16030c1a8cd2bfbff Mon Sep 17 00:00:00 2001 From: eug-vs Date: Wed, 20 Apr 2022 16:01:54 +0300 Subject: feat(zsh): use vifm for CTRL-O binding --- vifm/.config/vifm/vifmrc | 1 + zsh/.zshrc | 18 ++++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/vifm/.config/vifm/vifmrc b/vifm/.config/vifm/vifmrc index a199c8e..314e2ee 100644 --- a/vifm/.config/vifm/vifmrc +++ b/vifm/.config/vifm/vifmrc @@ -401,6 +401,7 @@ set vifminfo=dhistory,savedirs,chistory,state,tui,shistory, " Start shell in current directory nnoremap s :shell +nnoremap q :execute '!echo %d > ~/.config/vifm/lastdir' | quit " Display sorting dialog nnoremap S :sort diff --git a/zsh/.zshrc b/zsh/.zshrc index e98fd80..2bc552c 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -71,17 +71,15 @@ 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 +# Use vifm to switch directories and bind it to ctrl-o +function vifmcd () { + vifm . + + if [ -f ~/.config/vifm/lastdir ]; then + cd $(cat ~/.config/vifm/lastdir) + fi } -bindkey -s '^o' 'lfcd\n' +bindkey -s '^o' 'vifmcd\n' # Syntax highlighting, must be last -- cgit v1.2.3