From d7458b756ee218e6f597218a8d9065b2032601f1 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Mon, 2 Feb 2026 00:37:36 -0500 Subject: [PATCH] Support symlinks on Windows (#1149) --- CHANGELOG.md | 10 ++++++++++ templates/bash.txt | 12 ++++++++---- templates/fish.txt | 12 ++++++++---- templates/posix.txt | 25 +++++++++++++++++++------ templates/zsh.txt | 12 ++++++++---- 5 files changed, 53 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffcaafd..6b38fe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Added + +- POSIX: support for non-Cygwin Windows environments (e.g. Busybox). + +### Fixed + +- Bash/Fish/POSIX/Zsh: resolve symlinks on Windows. + ## [0.9.9] - 2026-01-31 ### Added diff --git a/templates/bash.txt b/templates/bash.txt index f96edb0..86a2884 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -9,12 +9,16 @@ # 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 + \command cygpath -w "{{ pwd }}" {%- else %} - \builtin pwd -L + {{ pwd }} {%- endif %} } diff --git a/templates/fish.txt b/templates/fish.txt index 36ca833..a13edc7 100644 --- a/templates/fish.txt +++ b/templates/fish.txt @@ -7,12 +7,16 @@ # 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 + command cygpath -w ({{ pwd }}) {%- else %} - builtin pwd -L + {{ pwd }} {%- endif %} end 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() { diff --git a/templates/zsh.txt b/templates/zsh.txt index 80cd428..a66f960 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -9,12 +9,16 @@ # 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 + \command cygpath -w "{{ pwd }}" {%- else %} - \builtin pwd -L + {{ pwd }} {%- endif %} }