diff --git a/templates/bash.txt b/templates/bash.txt index f96edb0..0768bd9 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 6219b58..b3f660c 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() {