From 7de87a9b2c643ab6a1329666b283cab4ba9cb08e Mon Sep 17 00:00:00 2001 From: Emilio Vesprini <82109173+emivespa@users.noreply.github.com> Date: Sat, 30 Mar 2024 13:13:15 -0300 Subject: [PATCH] [shell] Make ALT-C use the absolute path to the selected directory (#3688) Rationale: this way the resulting cd command that ends up in the shell history can be reused to get to the same location regardless of the current working directory. Co-authored-by: LangLangBart <92653266+LangLangBart@users.noreply.github.com> --- shell/key-bindings.bash | 2 +- shell/key-bindings.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/key-bindings.bash b/shell/key-bindings.bash index a290e4ca..b132b179 100644 --- a/shell/key-bindings.bash +++ b/shell/key-bindings.bash @@ -41,7 +41,7 @@ __fzf_cd__() { opts="--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore --reverse --walker=dir,follow,hidden --scheme=path ${FZF_DEFAULT_OPTS-} ${FZF_ALT_C_OPTS-} +m" dir=$( FZF_DEFAULT_COMMAND=${FZF_ALT_C_COMMAND:-} FZF_DEFAULT_OPTS="$opts" $(__fzfcmd) - ) && printf 'builtin cd -- %q' "$dir" + ) && printf 'builtin cd -- %q' "$(builtin unset CDPATH && builtin cd -- "$dir" && builtin pwd)" } if command -v perl > /dev/null; then diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh index 51aa6ea0..3614dd43 100644 --- a/shell/key-bindings.zsh +++ b/shell/key-bindings.zsh @@ -78,7 +78,7 @@ fzf-cd-widget() { return 0 fi zle push-line # Clear buffer. Auto-restored on next prompt. - BUFFER="builtin cd -- ${(q)dir}" + BUFFER="builtin cd -- ${(q)dir:a}" zle accept-line local ret=$? unset dir # ensure this doesn't end up appearing in prompt expansion