From 0042b8596325294776ac387d4ab9fe47606bebf1 Mon Sep 17 00:00:00 2001 From: Yax <1949284+kianby@users.noreply.github.com> Date: Wed, 2 Oct 2024 11:52:10 +0200 Subject: [PATCH] Bind CTRL-P to find project. Deprecate p function --- dot_zshrc.tmpl | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl index 493f48b..d781f04 100644 --- a/dot_zshrc.tmpl +++ b/dot_zshrc.tmpl @@ -119,16 +119,14 @@ zi snippet OMZP::tmux if command -v fzf &>/dev/null; then - __fzf_cd__ () { - local cmd dir - cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune -o -type d -print 2> /dev/null | cut -b3-"}" - dir=$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m) && printf 'cd %q' "$dir" - } - - # quickly find a project - p(){ - cd {{ .projectdir }} && `__fzf_cd__` && [[ -d ".git" ]] && git fetch - } + change_path_and_find_project() { + cd {{ .projectdir }} + zle fzf-cd-widget + zle reset-prompt + } + + zle -N change_path_and_find_project + bindkey '^P' change_path_and_find_project fi