From 8772cde987ccc50c8f1d10404d343e1cec1690c4 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Tue, 18 Nov 2025 11:25:29 -0500 Subject: [PATCH] Fix #1147 and #1148 --- templates/bash.txt | 25 +++++++++++++++++++------ templates/posix.txt | 25 +++++++++++++++++++------ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/templates/bash.txt b/templates/bash.txt index f96edb00..0768bd92 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -8,15 +8,28 @@ # # pwd based on the value of _ZO_RESOLVE_SYMLINKS. -function __zoxide_pwd() { +{%- let pwd -%} +{%- if resolve_symlinks -%} +{%- let pwd = "\\builtin pwd -P" -%} +{%- else -%} +{%- let pwd = "\\builtin pwd -L" -%} +{%- endif -%} {%- if cfg!(windows) %} - \command cygpath -w "$(\builtin pwd -P)" -{%- else if resolve_symlinks %} - \builtin pwd -P +if \command -v cygpath >/dev/null +then + function __zoxide_pwd() { + \command cygpath -w "$({{ pwd }})" + } +else + function __zoxide_pwd() { + {{ pwd }} + } +fi {%- else %} - \builtin pwd -L -{%- endif %} +function __zoxide_pwd() { + {{ pwd }} } +{%- endif %} # cd + custom logic based on the value of _ZO_ECHO. function __zoxide_cd() { diff --git a/templates/posix.txt b/templates/posix.txt index 6219b58b..b3f660c5 100644 --- a/templates/posix.txt +++ b/templates/posix.txt @@ -8,15 +8,28 @@ # # pwd based on the value of _ZO_RESOLVE_SYMLINKS. -__zoxide_pwd() { +{%- let pwd -%} +{%- if resolve_symlinks -%} +{%- let pwd = "\\command pwd -P" -%} +{%- else -%} +{%- let pwd = "\\command pwd -L" -%} +{%- endif -%} {%- if cfg!(windows) %} - \command cygpath -w "$(\command pwd -P)" -{%- else if resolve_symlinks %} - \command pwd -P +if \command -v cygpath >/dev/null +then + __zoxide_pwd() { + \command cygpath -w "$({{ pwd }})" + } +else + __zoxide_pwd() { + {{ pwd }} + } +fi {%- else %} - \command pwd -L -{%- endif %} +__zoxide_pwd() { + {{ pwd }} } +{%- endif %} # cd + custom logic based on the value of _ZO_ECHO. __zoxide_cd() {