Support symlinks on Windows (#1149)

This commit is contained in:
Andrew Bradley 2026-02-02 00:37:36 -05:00 committed by GitHub
parent 9cdc6aa374
commit d7458b756e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 53 additions and 18 deletions

View File

@ -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

View File

@ -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 %}
}

View File

@ -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

View File

@ -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() {

View File

@ -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 %}
}