diff --git a/nushell/modules/pj_zoxide.nu b/nushell/modules/pj_zoxide.nu index db24da7..862e09b 100644 --- a/nushell/modules/pj_zoxide.nu +++ b/nushell/modules/pj_zoxide.nu @@ -41,6 +41,20 @@ export-env { # When using zoxide with --no-cmd, alias these internal functions as desired. # +def _pj_normalize_windows_drive [path: string] { + if (($nu.os-info.name | str downcase) != "windows") { + return $path + } + + let parsed = ($path | parse --regex '^(?[a-zA-Z]):(?.*)$') + if ($parsed | is-empty) { + return $path + } + + let item = ($parsed | first) + $"(($item.drive | str upcase)):($item.rest)" +} + # Jump to a directory using only keywords. def --env --wrapped __zoxide_z [...rest: string] { let path = match $rest { @@ -51,12 +65,13 @@ def --env --wrapped __zoxide_z [...rest: string] { zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n" } } - cd $path + cd (_pj_normalize_windows_drive $path) } # Jump to a directory using interactive search. def --env --wrapped __zoxide_zi [...rest:string] { - cd $'(zoxide query --interactive -- ...$rest | str trim -r -c "\n")' + let path = (zoxide query --interactive -- ...$rest | str trim -r -c "\n") + cd (_pj_normalize_windows_drive $path) } # Jump to git repository root when currently inside a repository. @@ -72,7 +87,7 @@ def --env __zoxide_zg [] { let root = ($top.stdout | str trim -r -c "\n") if ($root != "") { - cd $root + cd (_pj_normalize_windows_drive $root) } }