From 0f07314d33f635e2fb324c08aa691a597dad2417 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Thu, 27 Feb 2025 00:06:36 +0530 Subject: [PATCH 01/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5559ecc..f0893a2 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@
Warp
Warp, the intelligent terminal
-
Available for MacOS and Linux
+
Available for MacOS, Linux, and Windows
Visit warp.dev From 2ecb310108771302162f7775c7114ba80eaafd4b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Mar 2025 12:55:35 +0530 Subject: [PATCH 02/23] Bump cachix/install-nix-action from 30 to 31 (#1012) Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 30 to 31. - [Release notes](https://github.com/cachix/install-nix-action/releases) - [Commits](https://github.com/cachix/install-nix-action/compare/v30...v31) --- updated-dependencies: - dependency-name: cachix/install-nix-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96261f1..c044cba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: components: rustfmt profile: minimal toolchain: nightly - - uses: cachix/install-nix-action@v30 + - uses: cachix/install-nix-action@v31 if: ${{ matrix.os != 'windows-latest' }} with: nix_path: nixpkgs=channel:nixos-unstable From 6679619c00c2ca7381f2ed72b29581a2f2750f2c Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Wed, 19 Mar 2025 06:01:14 +0530 Subject: [PATCH 03/23] bash: rewrite prompt after space-tab --- CHANGELOG.md | 6 ++++++ templates/bash.txt | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 419c5ae..d47ae49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ 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 + +### Changed + +- Bash: zoxide will now rewrite the prompt when using Space-Tab completions. + ## [0.9.7] - 2025-02-10 ### Added diff --git a/templates/bash.txt b/templates/bash.txt index 560a050..a4177a8 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -86,8 +86,6 @@ function __zoxide_doctor() { # When using zoxide with --no-cmd, alias these internal functions as desired. # -__zoxide_z_prefix='z#' - # Jump to a directory using only keywords. function __zoxide_z() { __zoxide_doctor @@ -101,10 +99,6 @@ function __zoxide_z() { __zoxide_cd "$1" elif [[ $# -eq 2 && $1 == '--' ]]; then __zoxide_cd "$2" - elif [[ ${@: -1} == "${__zoxide_z_prefix}"?* ]]; then - # shellcheck disable=SC2124 - \builtin local result="${@: -1}" - __zoxide_cd "{{ "${result:${#__zoxide_z_prefix}}" }}" else \builtin local result # shellcheck disable=SC2312 @@ -144,8 +138,11 @@ function {{cmd}}i() { # - Completions don't work on `dumb` terminals. if [[ ${BASH_VERSINFO[0]:-0} -eq 4 && ${BASH_VERSINFO[1]:-0} -ge 4 || ${BASH_VERSINFO[0]:-0} -ge 5 ]] && [[ :"${SHELLOPTS}": =~ :(vi|emacs): && ${TERM} != 'dumb' ]]; then - # Use `printf '\e[5n'` to redraw line after fzf closes. - \builtin bind '"\e[0n": redraw-current-line' &>/dev/null + + function __zoxide_z_complete_helper() { + READLINE_LINE="{{ cmd }} ${__zoxide_result@Q}" + READLINE_POINT={{ "${#READLINE_LINE}" }} + } function __zoxide_z_complete() { # Only show completions when the cursor is at the end of the line. @@ -157,12 +154,15 @@ if [[ ${BASH_VERSINFO[0]:-0} -eq 4 && ${BASH_VERSINFO[1]:-0} -ge 4 || ${BASH_VER \builtin compgen -A directory -- "${COMP_WORDS[-1]}" || \builtin true ) # If there is a space after the last word, use interactive selection. - elif [[ -z ${COMP_WORDS[-1]} ]] && [[ ${COMP_WORDS[-2]} != "${__zoxide_z_prefix}"?* ]]; then - \builtin local result + elif [[ -z ${COMP_WORDS[-1]} ]]; then # shellcheck disable=SC2312 - result="$(\command zoxide query --exclude "$(__zoxide_pwd)" --interactive -- "{{ "${COMP_WORDS[@]:1:${#COMP_WORDS[@]}-2}" }}")" && - COMPREPLY=("${__zoxide_z_prefix}${result}/") - \builtin printf '\e[5n' + __zoxide_result="$(\command zoxide query --exclude "$(__zoxide_pwd)" --interactive -- "{{ "${COMP_WORDS[@]:1:${#COMP_WORDS[@]}-2}" }}")" && { + \builtin bind '"\e[0n": redraw-current-line' + \builtin printf '\e[5n' + + \builtin bind -x '"\e[0n": __zoxide_z_complete_helper "${result}"' + \builtin printf '\e[5n' + } fi } From 8118af567c49a3b14a7ed150e08d7a562569f415 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Thu, 20 Mar 2025 11:46:13 +0530 Subject: [PATCH 04/23] Update integrations --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f0893a2..3c7f043 100644 --- a/README.md +++ b/README.md @@ -461,14 +461,17 @@ Environment variables[^2] can be used for configuration. They must be set before | [lf] | File manager | See the [wiki][lf-wiki] | | [nnn] | File manager | [nnn-autojump] | | [ranger] | File manager | [ranger-zoxide] | +| [rfm] | File manager | Natively supported | +| [sesh] | `tmux` session manager | Natively supported | | [telescope.nvim] | Fuzzy finder for Neovim | [telescope-zoxide] | -| [t] | `tmux` session manager | Natively supported | | [tmux-session-wizard] | `tmux` session manager | Natively supported | +| [tmux-sessionx] | `tmux` session manager | Natively supported | | [vim] / [neovim] | Text editor | [zoxide.vim] | | [xplr] | File manager | [zoxide.xplr] | | [xxh] | Transports shell configuration over SSH | [xxh-plugin-prerun-zoxide] | | [yazi] | File manager | Natively supported | | [zabb] | Finds the shortest possible query for a path | Natively supported | +| [zesh] | `zellij` session manager | Natively supported | | [zsh-autocomplete] | Realtime completions for zsh | Natively supported | [^1]: @@ -528,15 +531,17 @@ Environment variables[^2] can be used for configuration. They must be set before [ranger]: https://github.com/ranger/ranger [raspbian packages]: https://archive.raspbian.org/raspbian/pool/main/r/rust-zoxide/ [releases]: https://github.com/ajeetdsouza/zoxide/releases +[rfm]: https://github.com/dsxmachina/rfm [scoop]: https://github.com/ScoopInstaller/Main/tree/master/bucket/zoxide.json +[sesh]: https://github.com/joshmedeski/sesh [slackbuilds]: https://slackbuilds.org/repository/15.0/system/zoxide/ [slackbuilds-howto]: https://slackbuilds.org/howto/ [solus packages]: https://github.com/getsolus/packages/tree/main/packages/z/zoxide/ -[t]: https://github.com/joshmedeski/t-smart-tmux-session-manager [telescope-zoxide]: https://github.com/jvgrootveld/telescope-zoxide [telescope.nvim]: https://github.com/nvim-telescope/telescope.nvim [termux]: https://github.com/termux/termux-packages/tree/master/packages/zoxide [tmux-session-wizard]: https://github.com/27medkamal/tmux-session-wizard +[tmux-sessionx]: https://github.com/omerxx/tmux-sessionx [tutorial]: contrib/tutorial.webp [ubuntu packages]: https://packages.ubuntu.com/jammy/zoxide [vim]: https://github.com/vim/vim @@ -547,6 +552,7 @@ Environment variables[^2] can be used for configuration. They must be set before [xxh]: https://github.com/xxh/xxh [yazi]: https://github.com/sxyazi/yazi [zabb]: https://github.com/Mellbourn/zabb +[zesh]: https://github.com/roberte777/zesh [zoxide.el]: https://gitlab.com/Vonfry/zoxide.el [zoxide.vim]: https://github.com/nanotee/zoxide.vim [zoxide.xplr]: https://github.com/sayanarijit/zoxide.xplr From 2480ed085304b452f0fb4771d87c232998e48bbf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 11:47:18 +0530 Subject: [PATCH 05/23] Bump cachix/cachix-action from 15 to 16 (#1018) Bumps [cachix/cachix-action](https://github.com/cachix/cachix-action) from 15 to 16. - [Release notes](https://github.com/cachix/cachix-action/releases) - [Commits](https://github.com/cachix/cachix-action/compare/v15...v16) --- updated-dependencies: - dependency-name: cachix/cachix-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c044cba..6370409 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: if: ${{ matrix.os != 'windows-latest' }} with: nix_path: nixpkgs=channel:nixos-unstable - - uses: cachix/cachix-action@v15 + - uses: cachix/cachix-action@v16 if: ${{ matrix.os != 'windows-latest' && env.CACHIX_AUTH_TOKEN != '' }} with: authToken: ${{ env.CACHIX_AUTH_TOKEN }} From 7617799eb58f69aa525aaab924f8a0eb52b02d26 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Mar 2025 01:33:55 +0530 Subject: [PATCH 06/23] Bump Swatinem/rust-cache from 2.7.7 to 2.7.8 (#1025) Bumps [Swatinem/rust-cache](https://github.com/swatinem/rust-cache) from 2.7.7 to 2.7.8. - [Release notes](https://github.com/swatinem/rust-cache/releases) - [Changelog](https://github.com/Swatinem/rust-cache/blob/master/CHANGELOG.md) - [Commits](https://github.com/swatinem/rust-cache/compare/v2.7.7...v2.7.8) --- updated-dependencies: - dependency-name: Swatinem/rust-cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6370409..d6427cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: authToken: ${{ env.CACHIX_AUTH_TOKEN }} name: zoxide - name: Setup cache - uses: Swatinem/rust-cache@v2.7.7 + uses: Swatinem/rust-cache@v2.7.8 with: key: ${{ matrix.os }} - name: Install just diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3631552..6a23046 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,7 +59,7 @@ jobs: override: true target: ${{ matrix.target }} - name: Setup cache - uses: Swatinem/rust-cache@v2.7.7 + uses: Swatinem/rust-cache@v2.7.8 with: key: ${{ matrix.target }} - name: Install cross From e1e2f41ecbaceac855dd48c5064dc2b7aed8b0e6 Mon Sep 17 00:00:00 2001 From: Azalea Colburn <62953415+azaleacolburn@users.noreply.github.com> Date: Sun, 30 Mar 2025 23:13:40 -0700 Subject: [PATCH 07/23] feat: add --score option (#1030) --- contrib/completions/_zoxide | 2 ++ contrib/completions/_zoxide.ps1 | 2 ++ contrib/completions/zoxide.bash | 10 +++++++++- contrib/completions/zoxide.elv | 2 ++ contrib/completions/zoxide.fish | 1 + contrib/completions/zoxide.ts | 9 +++++++++ src/cmd/add.rs | 4 +++- src/cmd/cmd.rs | 4 ++++ 8 files changed, 32 insertions(+), 2 deletions(-) diff --git a/contrib/completions/_zoxide b/contrib/completions/_zoxide index 69882b4..dbf0196 100644 --- a/contrib/completions/_zoxide +++ b/contrib/completions/_zoxide @@ -30,6 +30,8 @@ _zoxide() { case $line[1] in (add) _arguments "${_arguments_options[@]}" : \ +'-s+[The rank to increment the entry if it exists or initialize it with if it doesn'\''t]:SCORE: ' \ +'--score=[The rank to increment the entry if it exists or initialize it with if it doesn'\''t]:SCORE: ' \ '-h[Print help]' \ '--help[Print help]' \ '-V[Print version]' \ diff --git a/contrib/completions/_zoxide.ps1 b/contrib/completions/_zoxide.ps1 index af15c66..a26adda 100644 --- a/contrib/completions/_zoxide.ps1 +++ b/contrib/completions/_zoxide.ps1 @@ -34,6 +34,8 @@ Register-ArgumentCompleter -Native -CommandName 'zoxide' -ScriptBlock { break } 'zoxide;add' { + [CompletionResult]::new('-s', '-s', [CompletionResultType]::ParameterName, 'The rank to increment the entry if it exists or initialize it with if it doesn''t') + [CompletionResult]::new('--score', '--score', [CompletionResultType]::ParameterName, 'The rank to increment the entry if it exists or initialize it with if it doesn''t') [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') diff --git a/contrib/completions/zoxide.bash b/contrib/completions/zoxide.bash index 73dbd45..8c524aa 100644 --- a/contrib/completions/zoxide.bash +++ b/contrib/completions/zoxide.bash @@ -63,12 +63,20 @@ _zoxide() { return 0 ;; zoxide__add) - opts="-h -V --help --version ..." + opts="-s -h -V --score --help --version ..." if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi case "${prev}" in + --score) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -s) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; *) COMPREPLY=() ;; diff --git a/contrib/completions/zoxide.elv b/contrib/completions/zoxide.elv index 6183d37..e4cb36b 100644 --- a/contrib/completions/zoxide.elv +++ b/contrib/completions/zoxide.elv @@ -30,6 +30,8 @@ set edit:completion:arg-completer[zoxide] = {|@words| cand remove 'Remove a directory from the database' } &'zoxide;add'= { + cand -s 'The rank to increment the entry if it exists or initialize it with if it doesn''t' + cand --score 'The rank to increment the entry if it exists or initialize it with if it doesn''t' cand -h 'Print help' cand --help 'Print help' cand -V 'Print version' diff --git a/contrib/completions/zoxide.fish b/contrib/completions/zoxide.fish index 96dd86e..108508b 100644 --- a/contrib/completions/zoxide.fish +++ b/contrib/completions/zoxide.fish @@ -32,6 +32,7 @@ complete -c zoxide -n "__fish_zoxide_needs_command" -f -a "import" -d 'Import en complete -c zoxide -n "__fish_zoxide_needs_command" -f -a "init" -d 'Generate shell configuration' complete -c zoxide -n "__fish_zoxide_needs_command" -f -a "query" -d 'Search for a directory in the database' complete -c zoxide -n "__fish_zoxide_needs_command" -f -a "remove" -d 'Remove a directory from the database' +complete -c zoxide -n "__fish_zoxide_using_subcommand add" -s s -l score -d 'The rank to increment the entry if it exists or initialize it with if it doesn\'t' -r complete -c zoxide -n "__fish_zoxide_using_subcommand add" -s h -l help -d 'Print help' complete -c zoxide -n "__fish_zoxide_using_subcommand add" -s V -l version -d 'Print version' complete -c zoxide -n "__fish_zoxide_using_subcommand edit; and not __fish_seen_subcommand_from decrement delete increment reload" -s h -l help -d 'Print help' diff --git a/contrib/completions/zoxide.ts b/contrib/completions/zoxide.ts index 0200591..87003b9 100644 --- a/contrib/completions/zoxide.ts +++ b/contrib/completions/zoxide.ts @@ -6,6 +6,15 @@ const completion: Fig.Spec = { name: "add", description: "Add a new directory or increment its rank", options: [ + { + name: ["-s", "--score"], + description: "The rank to increment the entry if it exists or initialize it with if it doesn't", + isRepeatable: true, + args: { + name: "score", + isOptional: true, + }, + }, { name: ["-h", "--help"], description: "Print help", diff --git a/src/cmd/add.rs b/src/cmd/add.rs index e7d6e0b..302ae0a 100644 --- a/src/cmd/add.rs +++ b/src/cmd/add.rs @@ -33,7 +33,9 @@ impl Run for Add { if !Path::new(path).is_dir() { bail!("not a directory: {path}"); } - db.add_update(path, 1.0, now); + + let by = self.score.unwrap_or(1.0); + db.add_update(path, by, now); } if db.dirty() { diff --git a/src/cmd/cmd.rs b/src/cmd/cmd.rs index cff7e79..184a5f2 100644 --- a/src/cmd/cmd.rs +++ b/src/cmd/cmd.rs @@ -58,6 +58,10 @@ pub enum Cmd { pub struct Add { #[clap(num_args = 1.., required = true, value_hint = ValueHint::DirPath)] pub paths: Vec, + + /// The rank to increment the entry if it exists or initialize it with if it doesn't + #[clap(short, long)] + pub score: Option, } /// Edit the database From b193a84eb0991728ebaf2b4b03c7bd27c2189bb2 Mon Sep 17 00:00:00 2001 From: "Y.D.X." <73375426+YDX-2147483647@users.noreply.github.com> Date: Fri, 4 Apr 2025 23:19:14 +0800 Subject: [PATCH 08/23] docs: Update minimum supported fzf version (#1034) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before v0.51.0, fzf generates redundant escaping of backslashes for Windows, which breaks `zoxide edit`. https://github.com/junegunn/fzf/releases/tag/0.51.0 Closes #539 Co-authored-by: Loïc Riegel --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c7f043..fd20f32 100644 --- a/README.md +++ b/README.md @@ -323,7 +323,7 @@ zoxide can be installed in 4 easy steps: interactive selection. It can be installed from [here][fzf-installation]. > **Note** - > zoxide only supports fzf v0.33.0 and above. + > The minimum supported fzf version is v0.33.0 on most platforms and v0.51.0 on Windows. 4. **Import your data** (optional) From 6902d375c5ef6caa4ad8f74034cb43b3ee27345f Mon Sep 17 00:00:00 2001 From: Brian <18603393+brian6932@users.noreply.github.com> Date: Thu, 10 Apr 2025 06:16:57 -0400 Subject: [PATCH 09/23] powershell: Ignore errors from `__zoxide_hooked` (#1038) --- templates/powershell.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/powershell.txt b/templates/powershell.txt index 86b1966..7744338 100644 --- a/templates/powershell.txt +++ b/templates/powershell.txt @@ -80,7 +80,7 @@ function global:__zoxide_hook { {%- endif %} # Initialize hook. -$global:__zoxide_hooked = (Get-Variable __zoxide_hooked -ErrorAction SilentlyContinue -ValueOnly) +$global:__zoxide_hooked = (Get-Variable __zoxide_hooked -ErrorAction Ignore -ValueOnly) if ($global:__zoxide_hooked -ne 1) { $global:__zoxide_hooked = 1 $global:__zoxide_prompt_old = $function:prompt From 7691d7e9a53290daf9b6456de379bd31c61fb597 Mon Sep 17 00:00:00 2001 From: Lisa FS Date: Sun, 13 Apr 2025 07:46:27 -0600 Subject: [PATCH 10/23] nushell: fix jumping to symlinks that are not in the database (#1032) Expand path before checking for its type. This solves the issue of ignoring symlinks. --- templates/nushell.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/nushell.txt b/templates/nushell.txt index 67285f7..3ab49ce 100644 --- a/templates/nushell.txt +++ b/templates/nushell.txt @@ -60,7 +60,7 @@ def --env --wrapped __zoxide_z [...rest: string] { let path = match $rest { [] => {'~'}, [ '-' ] => {'-'}, - [ $arg ] if ($arg | path type) == 'dir' => {$arg} + [ $arg ] if ($arg | path expand | path type) == 'dir' => {$arg} _ => { zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n" } From 09aa626a8653e758cda3f3cab8a6d8188e10cbd7 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Mon, 5 May 2025 22:58:54 -0700 Subject: [PATCH 11/23] Add support for csh (#1047) --- CHANGELOG.md | 11 +++++ README.md | 2 +- contrib/completions/_zoxide | 2 +- contrib/completions/zoxide.bash | 2 +- contrib/completions/zoxide.ts | 1 + shell.nix | 5 ++- src/cmd/cmd.rs | 5 ++- src/cmd/init.rs | 3 +- src/shell.rs | 15 +++++++ templates/bash.txt | 1 + templates/csh.txt | 74 +++++++++++++++++++++++++++++++++ templates/xonsh.txt | 2 +- 12 files changed, 115 insertions(+), 8 deletions(-) create mode 100644 templates/csh.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index d47ae49..4d67b22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Support for Csh. +- Added `--score` flag to `zoxide add`. + ### Changed - Bash: zoxide will now rewrite the prompt when using Space-Tab completions. +### Fixed + +- Nushell: stop ignoring symlinks when `cd`-ing into a directory. +- Fzf: updated minimum supported version to v0.51.0. +- PowerShell: avoid setting `$error` when defining `__zoxide_hooked`. + ## [0.9.7] - 2025-02-10 ### Added diff --git a/README.md b/README.md index fd20f32..5e3d883 100644 --- a/README.md +++ b/README.md @@ -323,7 +323,7 @@ zoxide can be installed in 4 easy steps: interactive selection. It can be installed from [here][fzf-installation]. > **Note** - > The minimum supported fzf version is v0.33.0 on most platforms and v0.51.0 on Windows. + > The minimum supported fzf version is v0.51.0. 4. **Import your data** (optional) diff --git a/contrib/completions/_zoxide b/contrib/completions/_zoxide index dbf0196..3bbb5cf 100644 --- a/contrib/completions/_zoxide +++ b/contrib/completions/_zoxide @@ -114,7 +114,7 @@ _arguments "${_arguments_options[@]}" : \ '--help[Print help]' \ '-V[Print version]' \ '--version[Print version]' \ -':shell:(bash elvish fish nushell posix powershell xonsh zsh)' \ +':shell:(bash csh elvish fish nushell posix powershell xonsh zsh)' \ && ret=0 ;; (query) diff --git a/contrib/completions/zoxide.bash b/contrib/completions/zoxide.bash index 8c524aa..2601198 100644 --- a/contrib/completions/zoxide.bash +++ b/contrib/completions/zoxide.bash @@ -173,7 +173,7 @@ _zoxide() { return 0 ;; zoxide__init) - opts="-h -V --no-cmd --cmd --hook --help --version bash elvish fish nushell posix powershell xonsh zsh" + opts="-h -V --no-cmd --cmd --hook --help --version bash csh elvish fish nushell posix powershell xonsh zsh" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 diff --git a/contrib/completions/zoxide.ts b/contrib/completions/zoxide.ts index 87003b9..88f034b 100644 --- a/contrib/completions/zoxide.ts +++ b/contrib/completions/zoxide.ts @@ -189,6 +189,7 @@ const completion: Fig.Spec = { name: "shell", suggestions: [ "bash", + "csh", "elvish", "fish", "nushell", diff --git a/shell.nix b/shell.nix index b63d44c..b7b7400 100644 --- a/shell.nix +++ b/shell.nix @@ -1,10 +1,10 @@ let pkgs = import (builtins.fetchTarball - "https://github.com/NixOS/nixpkgs/archive/056faf24027e12f0ba6edebe299ed136e030d29a.tar.gz") { + "https://github.com/NixOS/nixpkgs/archive/ec9ef366451af88284d7dfd18ee017b7e86a0710.tar.gz") { overlays = [ rust ]; }; rust = import (builtins.fetchTarball - "https://github.com/oxalica/rust-overlay/archive/f61820fa2c3844d6940cce269a6afdec30aa2e6c.tar.gz"); + "https://github.com/oxalica/rust-overlay/archive/026e8fedefd6b167d92ed04b195c658d95ffc7a5.tar.gz"); rust-nightly = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal); @@ -27,6 +27,7 @@ in pkgs.mkShell { pkgs.ksh pkgs.nushell pkgs.powershell + pkgs.tcsh pkgs.xonsh pkgs.zsh diff --git a/src/cmd/cmd.rs b/src/cmd/cmd.rs index 184a5f2..6b79c5c 100644 --- a/src/cmd/cmd.rs +++ b/src/cmd/cmd.rs @@ -59,7 +59,8 @@ pub struct Add { #[clap(num_args = 1.., required = true, value_hint = ValueHint::DirPath)] pub paths: Vec, - /// The rank to increment the entry if it exists or initialize it with if it doesn't + /// The rank to increment the entry if it exists or initialize it with if it + /// doesn't #[clap(short, long)] pub score: Option, } @@ -146,6 +147,8 @@ pub enum InitHook { #[derive(ValueEnum, Clone, Debug)] pub enum InitShell { Bash, + #[clap(alias = "tcsh")] + Csh, Elvish, Fish, Nushell, diff --git a/src/cmd/init.rs b/src/cmd/init.rs index 3f79ed6..6c15831 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -6,7 +6,7 @@ use rinja::Template; use crate::cmd::{Init, InitShell, Run}; use crate::config; use crate::error::BrokenPipeHandler; -use crate::shell::{Bash, Elvish, Fish, Nushell, Opts, Posix, Powershell, Xonsh, Zsh}; +use crate::shell::{Bash, Csh, Elvish, Fish, Nushell, Opts, Posix, Powershell, Xonsh, Zsh}; impl Run for Init { fn run(&self) -> Result<()> { @@ -17,6 +17,7 @@ impl Run for Init { let source = match self.shell { InitShell::Bash => Bash(opts).render(), + InitShell::Csh => Csh(opts).render(), InitShell::Elvish => Elvish(opts).render(), InitShell::Fish => Fish(opts).render(), InitShell::Nushell => Nushell(opts).render(), diff --git a/src/shell.rs b/src/shell.rs index 721553d..78bf2f3 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -24,6 +24,7 @@ macro_rules! make_template { } make_template!(Bash, "bash.txt"); +make_template!(Csh, "csh.txt"); make_template!(Elvish, "elvish.txt"); make_template!(Fish, "fish.txt"); make_template!(Nushell, "nushell.txt"); @@ -93,6 +94,20 @@ mod tests { .stderr(""); } + #[apply(opts)] + fn csh_tcsh(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) { + let opts = Opts { cmd, hook, echo, resolve_symlinks }; + let source = Csh(&opts).render().unwrap(); + + Command::new("tcsh") + .args(["-e", "-f", "-s"]) + .write_stdin(source) + .assert() + .success() + .stdout("") + .stderr(""); + } + #[apply(opts)] fn elvish_elvish(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) { let opts = Opts { cmd, hook, echo, resolve_symlinks }; diff --git a/templates/bash.txt b/templates/bash.txt index a4177a8..162ca6c 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -160,6 +160,7 @@ if [[ ${BASH_VERSINFO[0]:-0} -eq 4 && ${BASH_VERSINFO[1]:-0} -ge 4 || ${BASH_VER \builtin bind '"\e[0n": redraw-current-line' \builtin printf '\e[5n' + # shellcheck disable=SC2016 \builtin bind -x '"\e[0n": __zoxide_z_complete_helper "${result}"' \builtin printf '\e[5n' } diff --git a/templates/csh.txt b/templates/csh.txt new file mode 100644 index 0000000..1145052 --- /dev/null +++ b/templates/csh.txt @@ -0,0 +1,74 @@ +{%- let section = "# =============================================================================\n#" -%} +{%- let not_configured = "# -- not configured --" -%} + +{%- let pwd_cmd -%} +{%- if resolve_symlinks -%} +{%- let pwd_cmd = "pwd -P" -%} +{%- else -%} +{%- let pwd_cmd = "pwd -L" -%} +{%- endif -%} + +{{ section }} +# Hook configuration for zoxide. +# +{%- if hook != InitHook::None %} + +# Hook to add new entries to the database. +{%- if hook == InitHook::Prompt %} +alias __zoxide_hook 'zoxide add -- "`{{ pwd_cmd }}`"' + +{%- else if hook == InitHook::Pwd %} +set __zoxide_pwd_old = `{{ pwd_cmd }}` +alias __zoxide_hook 'set __zoxide_pwd_tmp = "`{{ pwd_cmd }}`"; test "$__zoxide_pwd_tmp" != "$__zoxide_pwd_old" && zoxide add -- "$__zoxide_pwd_tmp"; set __zoxide_pwd_old = "$__zoxide_pwd_tmp"' +{%- endif %} + +# Initialize hook. +alias precmd ';__zoxide_hook' + +{%- endif %} + +{{ section }} +# When using zoxide with --no-cmd, alias these internal functions as desired. +# + +# Jump to a directory using only keywords. +alias __zoxide_z 'set __zoxide_args = (\!*)\ +if ("$#__zoxide_args" == 0) then\ + cd ~\ +else\ + if ("$#__zoxide_args" == 1 && "$__zoxide_args[1]" == "-") then\ + cd -\ + else if ("$#__zoxide_args" == 1 && -d "$__zoxide_args[1]") then\ + cd "$__zoxide_args[1]"\ + else\ + set __zoxide_pwd = `{{ pwd_cmd }}`\ + set __zoxide_result = "`zoxide query --exclude '"'"'$__zoxide_pwd'"'"' -- $__zoxide_args`" && cd "$__zoxide_result"\ + endif\ +endif' + +# Jump to a directory using interactive search. +alias __zoxide_zi 'set __zoxide_args = (\!*)\ +set __zoxide_pwd = `{{ pwd_cmd }}`\ +set __zoxide_result = "`zoxide query --exclude '"'"'$__zoxide_pwd'"'"' --interactive -- $__zoxide_args`" && cd "$__zoxide_result"' + +{{ section }} +# Commands for zoxide. Disable these using --no-cmd. +# + +{%- match cmd %} +{%- when Some with (cmd) %} + +alias {{cmd}} __zoxide_z +alias {{cmd}}i __zoxide_zi + +{%- when None %} + +{{ not_configured }} + +{%- endmatch %} + +{{ section }} +# To initialize zoxide, add this to your shell configuration file (usually ~/.cshrc or ~/.tcshrc): +# +# zoxide init csh > ~/.zoxide.csh +# source ~/.zoxide.csh diff --git a/templates/xonsh.txt b/templates/xonsh.txt index c769795..f5c92f2 100644 --- a/templates/xonsh.txt +++ b/templates/xonsh.txt @@ -64,7 +64,7 @@ class ZoxideSilentException(Exception): def __zoxide_errhandler( - func: typing.Callable[[list[str]], None] + func: typing.Callable[[list[str]], None], ) -> typing.Callable[[list[str]], int]: """Print exception and exit with error code 1.""" From 095b270fea283ed0a9d147c2b154a80030f19a4c Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Tue, 6 May 2025 00:26:07 -0700 Subject: [PATCH 12/23] csh -> tcsh --- CHANGELOG.md | 2 +- README.md | 12 ++++++++++++ contrib/completions/_zoxide | 2 +- contrib/completions/zoxide.bash | 2 +- contrib/completions/zoxide.ts | 2 +- man/man1/zoxide-init.1 | 8 ++++++++ src/cmd/cmd.rs | 3 +-- src/cmd/init.rs | 4 ++-- src/shell.rs | 30 +++++++++++++++--------------- templates/{csh.txt => tcsh.txt} | 6 +++--- 10 files changed, 45 insertions(+), 26 deletions(-) rename templates/{csh.txt => tcsh.txt} (95%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d67b22..87d47ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Support for Csh. +- Support for Tcsh. - Added `--score` flag to `zoxide add`. ### Changed diff --git a/README.md b/README.md index 5e3d883..09faada 100644 --- a/README.md +++ b/README.md @@ -280,6 +280,18 @@ zoxide can be installed in 4 easy steps: +
+ Tcsh + + > Add this to the **end** of your config file (usually `~/.tcshrc`): + > + > ```sh + > zoxide init tcsh > ~/.zoxide.tcsh + > source ~/.zoxide.tcsh + > ``` + +
+
Xonsh diff --git a/contrib/completions/_zoxide b/contrib/completions/_zoxide index 3bbb5cf..2f3557f 100644 --- a/contrib/completions/_zoxide +++ b/contrib/completions/_zoxide @@ -114,7 +114,7 @@ _arguments "${_arguments_options[@]}" : \ '--help[Print help]' \ '-V[Print version]' \ '--version[Print version]' \ -':shell:(bash csh elvish fish nushell posix powershell xonsh zsh)' \ +':shell:(bash elvish fish nushell posix powershell tcsh xonsh zsh)' \ && ret=0 ;; (query) diff --git a/contrib/completions/zoxide.bash b/contrib/completions/zoxide.bash index 2601198..909bc57 100644 --- a/contrib/completions/zoxide.bash +++ b/contrib/completions/zoxide.bash @@ -173,7 +173,7 @@ _zoxide() { return 0 ;; zoxide__init) - opts="-h -V --no-cmd --cmd --hook --help --version bash csh elvish fish nushell posix powershell xonsh zsh" + opts="-h -V --no-cmd --cmd --hook --help --version bash elvish fish nushell posix powershell tcsh xonsh zsh" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 diff --git a/contrib/completions/zoxide.ts b/contrib/completions/zoxide.ts index 88f034b..9e593d0 100644 --- a/contrib/completions/zoxide.ts +++ b/contrib/completions/zoxide.ts @@ -189,12 +189,12 @@ const completion: Fig.Spec = { name: "shell", suggestions: [ "bash", - "csh", "elvish", "fish", "nushell", "posix", "powershell", + "tcsh", "xonsh", "zsh", ], diff --git a/man/man1/zoxide-init.1 b/man/man1/zoxide-init.1 index 387c318..ebf1ed1 100644 --- a/man/man1/zoxide-init.1 +++ b/man/man1/zoxide-init.1 @@ -55,6 +55,14 @@ $profile\fR in PowerShell): \fBInvoke-Expression (& { (zoxide init powershell | Out-String) })\fR .fi .TP +.B tcsh +Add this to the \fBend\fR of your config file (usually \fB~/.tcshrc\fR): +.sp +.nf + \fBzoxide init tcsh > ~/.zoxide.tcsh\fR + \fBsource ~/.zoxide.tcsh\fR +.fi +.TP .B xonsh Add this to the \fBend\fR of your config file (usually \fB~/.xonshrc\fR): .sp diff --git a/src/cmd/cmd.rs b/src/cmd/cmd.rs index 6b79c5c..d25cda3 100644 --- a/src/cmd/cmd.rs +++ b/src/cmd/cmd.rs @@ -147,14 +147,13 @@ pub enum InitHook { #[derive(ValueEnum, Clone, Debug)] pub enum InitShell { Bash, - #[clap(alias = "tcsh")] - Csh, Elvish, Fish, Nushell, #[clap(alias = "ksh")] Posix, Powershell, + Tcsh, Xonsh, Zsh, } diff --git a/src/cmd/init.rs b/src/cmd/init.rs index 6c15831..506bd29 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -6,7 +6,7 @@ use rinja::Template; use crate::cmd::{Init, InitShell, Run}; use crate::config; use crate::error::BrokenPipeHandler; -use crate::shell::{Bash, Csh, Elvish, Fish, Nushell, Opts, Posix, Powershell, Xonsh, Zsh}; +use crate::shell::{Bash, Elvish, Fish, Nushell, Opts, Posix, Powershell, Tcsh, Xonsh, Zsh}; impl Run for Init { fn run(&self) -> Result<()> { @@ -17,12 +17,12 @@ impl Run for Init { let source = match self.shell { InitShell::Bash => Bash(opts).render(), - InitShell::Csh => Csh(opts).render(), InitShell::Elvish => Elvish(opts).render(), InitShell::Fish => Fish(opts).render(), InitShell::Nushell => Nushell(opts).render(), InitShell::Posix => Posix(opts).render(), InitShell::Powershell => Powershell(opts).render(), + InitShell::Tcsh => Tcsh(opts).render(), InitShell::Xonsh => Xonsh(opts).render(), InitShell::Zsh => Zsh(opts).render(), } diff --git a/src/shell.rs b/src/shell.rs index 78bf2f3..83243d8 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -24,12 +24,12 @@ macro_rules! make_template { } make_template!(Bash, "bash.txt"); -make_template!(Csh, "csh.txt"); make_template!(Elvish, "elvish.txt"); make_template!(Fish, "fish.txt"); make_template!(Nushell, "nushell.txt"); make_template!(Posix, "posix.txt"); make_template!(Powershell, "powershell.txt"); +make_template!(Tcsh, "tcsh.txt"); make_template!(Xonsh, "xonsh.txt"); make_template!(Zsh, "zsh.txt"); @@ -94,20 +94,6 @@ mod tests { .stderr(""); } - #[apply(opts)] - fn csh_tcsh(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) { - let opts = Opts { cmd, hook, echo, resolve_symlinks }; - let source = Csh(&opts).render().unwrap(); - - Command::new("tcsh") - .args(["-e", "-f", "-s"]) - .write_stdin(source) - .assert() - .success() - .stdout("") - .stderr(""); - } - #[apply(opts)] fn elvish_elvish(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) { let opts = Opts { cmd, hook, echo, resolve_symlinks }; @@ -263,6 +249,20 @@ mod tests { .stderr(""); } + #[apply(opts)] + fn tcsh_tcsh(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) { + let opts = Opts { cmd, hook, echo, resolve_symlinks }; + let source = Tcsh(&opts).render().unwrap(); + + Command::new("tcsh") + .args(["-e", "-f", "-s"]) + .write_stdin(source) + .assert() + .success() + .stdout("") + .stderr(""); + } + #[apply(opts)] fn xonsh_black(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) { let opts = Opts { cmd, hook, echo, resolve_symlinks }; diff --git a/templates/csh.txt b/templates/tcsh.txt similarity index 95% rename from templates/csh.txt rename to templates/tcsh.txt index 1145052..b0559a0 100644 --- a/templates/csh.txt +++ b/templates/tcsh.txt @@ -68,7 +68,7 @@ alias {{cmd}}i __zoxide_zi {%- endmatch %} {{ section }} -# To initialize zoxide, add this to your shell configuration file (usually ~/.cshrc or ~/.tcshrc): +# To initialize zoxide, add this to your shell configuration file (usually ~/.tcshrc): # -# zoxide init csh > ~/.zoxide.csh -# source ~/.zoxide.csh +# zoxide init tcsh > ~/.zoxide.tcsh +# source ~/.zoxide.tcsh From f1d848820a5229596b590b924125f2c4df61f448 Mon Sep 17 00:00:00 2001 From: XTY Date: Sat, 10 May 2025 02:49:12 +0800 Subject: [PATCH 13/23] docs(install): fix broken Nixpkgs link (#1051) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 09faada..3edfaba 100644 --- a/README.md +++ b/README.md @@ -533,7 +533,7 @@ Environment variables[^2] can be used for configuration. They must be set before [linuxbrew]: https://formulae.brew.sh/formula-linux/zoxide [macports]: https://ports.macports.org/port/zoxide/summary [neovim]: https://github.com/neovim/neovim -[nixpkgs]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/misc/zoxide/default.nix +[nixpkgs]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/zo/zoxide/package.nix [nnn-autojump]: https://github.com/jarun/nnn/blob/master/plugins/autojump [nnn]: https://github.com/jarun/nnn [opensuse factory]: https://build.opensuse.org/package/show/openSUSE:Factory/zoxide From 6ec0436859bb40f4d4908be55970ff6c3c31c782 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 10 May 2025 16:51:47 +0900 Subject: [PATCH 14/23] Add fixes to Bash integration (#1048) --- templates/bash.txt | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/templates/bash.txt b/templates/bash.txt index 162ca6c..4075ec2 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -86,6 +86,8 @@ function __zoxide_doctor() { # When using zoxide with --no-cmd, alias these internal functions as desired. # +__zoxide_z_prefix='z#' + # Jump to a directory using only keywords. function __zoxide_z() { __zoxide_doctor @@ -99,6 +101,10 @@ function __zoxide_z() { __zoxide_cd "$1" elif [[ $# -eq 2 && $1 == '--' ]]; then __zoxide_cd "$2" + elif [[ ${@: -1} == "${__zoxide_z_prefix}"?* ]]; then + # shellcheck disable=SC2124 + \builtin local result="${@: -1}" + __zoxide_cd "{{ "${result:${#__zoxide_z_prefix}}" }}" else \builtin local result # shellcheck disable=SC2312 @@ -157,12 +163,16 @@ if [[ ${BASH_VERSINFO[0]:-0} -eq 4 && ${BASH_VERSINFO[1]:-0} -ge 4 || ${BASH_VER elif [[ -z ${COMP_WORDS[-1]} ]]; then # shellcheck disable=SC2312 __zoxide_result="$(\command zoxide query --exclude "$(__zoxide_pwd)" --interactive -- "{{ "${COMP_WORDS[@]:1:${#COMP_WORDS[@]}-2}" }}")" && { - \builtin bind '"\e[0n": redraw-current-line' - \builtin printf '\e[5n' + # In case the terminal does not respond to \e[5n or another + # mechanism steals the response, it is still worth completing + # the directory in the command line. + COMPREPLY=("${__zoxide_z_prefix}${__zoxide_result}/") - # shellcheck disable=SC2016 - \builtin bind -x '"\e[0n": __zoxide_z_complete_helper "${result}"' - \builtin printf '\e[5n' + # Note: We here call "bind" without prefixing "\builtin" to be + # compatible with frameworks like ble.sh, which emulates Bash's + # builtin "bind". + bind -x '"\e[0n": __zoxide_z_complete_helper' + \builtin printf '\e[5n' >/dev/tty } fi } From 8f0288b0c97dbc7c615e32cf073896d080914ee4 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Sat, 10 May 2025 10:22:20 -0700 Subject: [PATCH 15/23] Check if zoxide is running under VS Code --- templates/bash.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/templates/bash.txt b/templates/bash.txt index 4075ec2..b2331a8 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -66,8 +66,9 @@ function __zoxide_doctor() { return 0 {%- else %} - [[ ${_ZO_DOCTOR:-1} -ne 0 ]] || return 0 - [[ ${PROMPT_COMMAND:=} != *'__zoxide_hook'* ]] || return 0 + [[ "${_ZO_DOCTOR:-1}" -eq 0 ]] && return 0 + [[ "${PROMPT_COMMAND:-}" == *'__zoxide_hook'* ]] && return 0 + [[ "${__vsc_original_prompt_command[@]:-}" == *'__zoxide_hook'* ]] && return 0 _ZO_DOCTOR=0 \builtin printf '%s\n' \ From 9768e645c724df9bbb2c76e4b5ea22ef9a30e9fa Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Sat, 10 May 2025 11:27:02 -0700 Subject: [PATCH 16/23] Remove unneeded quotes --- templates/bash.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/bash.txt b/templates/bash.txt index b2331a8..7c571d5 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -66,9 +66,9 @@ function __zoxide_doctor() { return 0 {%- else %} - [[ "${_ZO_DOCTOR:-1}" -eq 0 ]] && return 0 - [[ "${PROMPT_COMMAND:-}" == *'__zoxide_hook'* ]] && return 0 - [[ "${__vsc_original_prompt_command[@]:-}" == *'__zoxide_hook'* ]] && return 0 + [[ ${_ZO_DOCTOR:-1} -eq 0 ]] && return 0 + [[ ${PROMPT_COMMAND:-} == *'__zoxide_hook'* ]] && return 0 + [[ ${__vsc_original_prompt_command[@]:-} == *'__zoxide_hook'* ]] && return 0 _ZO_DOCTOR=0 \builtin printf '%s\n' \ From 306d7ae143586d26779907acad3f7cab91b38c48 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Sat, 10 May 2025 21:52:39 -0700 Subject: [PATCH 17/23] Fix shellcheck lint --- templates/bash.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/bash.txt b/templates/bash.txt index 7c571d5..8ac19bd 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -68,6 +68,7 @@ function __zoxide_doctor() { {%- else %} [[ ${_ZO_DOCTOR:-1} -eq 0 ]] && return 0 [[ ${PROMPT_COMMAND:-} == *'__zoxide_hook'* ]] && return 0 + # shellcheck disable=SC2199 [[ ${__vsc_original_prompt_command[@]:-} == *'__zoxide_hook'* ]] && return 0 _ZO_DOCTOR=0 From 36537410cd423cb3e99022cd21183c87555cf715 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Sat, 10 May 2025 23:41:55 -0700 Subject: [PATCH 18/23] Doctor should handle PROMPT_COMMAND being an array --- CHANGELOG.md | 3 +++ templates/bash.txt | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d47ad..af55e34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Bash: doctor now handles `PROMPT_COMMAND` being an array. +- Bash: doctor now handles Visual Studio Code's shell integration. +- Bash: completions now work with `ble.sh`. - Nushell: stop ignoring symlinks when `cd`-ing into a directory. - Fzf: updated minimum supported version to v0.51.0. - PowerShell: avoid setting `$error` when defining `__zoxide_hooked`. diff --git a/templates/bash.txt b/templates/bash.txt index 8ac19bd..fb037fc 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -67,7 +67,8 @@ function __zoxide_doctor() { {%- else %} [[ ${_ZO_DOCTOR:-1} -eq 0 ]] && return 0 - [[ ${PROMPT_COMMAND:-} == *'__zoxide_hook'* ]] && return 0 + # shellcheck disable=SC2199 + [[ ${PROMPT_COMMAND[@]:-} == *'__zoxide_hook'* ]] && return 0 # shellcheck disable=SC2199 [[ ${__vsc_original_prompt_command[@]:-} == *'__zoxide_hook'* ]] && return 0 From 1d08fe2b84772aadbfddf48fd590231d48511673 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Sun, 11 May 2025 23:24:30 -0700 Subject: [PATCH 19/23] Add doctor for POSIX shells --- CHANGELOG.md | 1 + templates/posix.txt | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index af55e34..2089362 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for Tcsh. - Added `--score` flag to `zoxide add`. +- POSIX: add doctor to diagnose common issues. ### Changed diff --git a/templates/posix.txt b/templates/posix.txt index a1793ad..474eebe 100644 --- a/templates/posix.txt +++ b/templates/posix.txt @@ -43,6 +43,29 @@ if [ "${PS1:=}" = "${PS1#*\$(__zoxide_hook)}" ]; then PS1="${PS1}\$(__zoxide_hook)" fi +# Report common issues. +__zoxide_doctor() { +{%- if hook != InitHook::Prompt %} + return 0 +{%- else %} + [ "${_ZO_DOCTOR:-1}" -eq 0 ] && return 0 + case "${PS1:-}" in + *__zoxide_hook*) return 0 ;; + esac + + _ZO_DOCTOR=0 + \command printf '%s\n' \ + 'zoxide: detected a possible configuration issue.' \ + 'Please ensure that zoxide is initialized right at the end of your shell configuration file.' \ + '' \ + 'If the issue persists, consider filing an issue at:' \ + 'https://github.com/ajeetdsouza/zoxide/issues' \ + '' \ + 'Disable this message by setting _ZO_DOCTOR=0.' \ + '' >&2 +{%- endif %} +} + {%- when InitHook::Pwd -%} \command printf "%s\n%s\n" \ "zoxide: PWD hooks are not supported on POSIX shells." \ @@ -56,6 +79,8 @@ fi # Jump to a directory using only keywords. __zoxide_z() { + __zoxide_doctor + if [ "$#" -eq 0 ]; then __zoxide_cd ~ elif [ "$#" -eq 1 ] && [ "$1" = '-' ]; then @@ -76,6 +101,7 @@ __zoxide_z() { # Jump to a directory using interactive search. __zoxide_zi() { + __zoxide_doctor __zoxide_result="$(\command zoxide query --interactive -- "$@")" && __zoxide_cd "${__zoxide_result}" } From 8e14038811da2abf5da9de37c2c458410fe462c5 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Mon, 12 May 2025 06:22:54 -0700 Subject: [PATCH 20/23] Fix lints --- templates/posix.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/posix.txt b/templates/posix.txt index 474eebe..b7ba9b3 100644 --- a/templates/posix.txt +++ b/templates/posix.txt @@ -50,7 +50,8 @@ __zoxide_doctor() { {%- else %} [ "${_ZO_DOCTOR:-1}" -eq 0 ] && return 0 case "${PS1:-}" in - *__zoxide_hook*) return 0 ;; + *__zoxide_hook*) return 0 ;; + *) ;; esac _ZO_DOCTOR=0 From 4807518c4bd7fcaf47a7f110d9027a6957ced9b8 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Mon, 12 May 2025 09:37:04 -0700 Subject: [PATCH 21/23] Call fsync before close --- src/util.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util.rs b/src/util.rs index 9f6689d..7bee368 100644 --- a/src/util.rs +++ b/src/util.rs @@ -179,6 +179,12 @@ pub fn write(path: impl AsRef, contents: impl AsRef<[u8]>) -> Result<()> { } // Close and rename the tmpfile. + // In some cases, errors from the last write() are reported only on close(). + // Rust ignores errors from close(), since it occurs inside `Drop`. To + // catch these errors, we manually call `File::sync_all()` first. + tmp_file + .sync_all() + .with_context(|| format!("could not sync writes to file: {}", tmp_path.display()))?; mem::drop(tmp_file); rename(&tmp_path, path) })(); From 3d9f928e01c84c7dd4aa618102a7b894cf7ab21e Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Mon, 12 May 2025 09:42:37 -0700 Subject: [PATCH 22/23] Upgrade to Rust 2024 --- Cargo.toml | 4 ++-- src/main.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7835ccc..12ed8d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,14 +2,14 @@ authors = ["Ajeet D'Souza <98ajeet@gmail.com>"] categories = ["command-line-utilities", "filesystem"] description = "A smarter cd command for your terminal" -edition = "2021" +edition = "2024" homepage = "https://github.com/ajeetdsouza/zoxide" keywords = ["cli", "filesystem", "shell", "tool", "utility"] license = "MIT" name = "zoxide" readme = "README.md" repository = "https://github.com/ajeetdsouza/zoxide" -rust-version = "1.74.1" +rust-version = "1.85.0" version = "0.9.7" [badges] diff --git a/src/main.rs b/src/main.rs index 1ff26f3..d4ddd6e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,8 +18,8 @@ use crate::error::SilentExit; pub fn main() -> ExitCode { // Forcibly disable backtraces. - env::remove_var("RUST_LIB_BACKTRACE"); - env::remove_var("RUST_BACKTRACE"); + unsafe { env::remove_var("RUST_LIB_BACKTRACE") }; + unsafe { env::remove_var("RUST_BACKTRACE") }; match Cmd::parse().run() { Ok(()) => ExitCode::SUCCESS, From 628f8542a01813e36edde2fba42bf0eafb9dfb05 Mon Sep 17 00:00:00 2001 From: benz Date: Tue, 13 May 2025 13:18:55 +0100 Subject: [PATCH 23/23] Fixes #995: Wildcard expansion for PowerShell (#1001) Co-authored-by: Ajeet D'Souza <98ajeet@gmail.com> --- templates/powershell.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/powershell.txt b/templates/powershell.txt index 7744338..e134ab1 100644 --- a/templates/powershell.txt +++ b/templates/powershell.txt @@ -106,9 +106,12 @@ function global:__zoxide_z { elseif ($args.Length -eq 1 -and ($args[0] -eq '-' -or $args[0] -eq '+')) { __zoxide_cd $args[0] $false } - elseif ($args.Length -eq 1 -and (Test-Path $args[0] -PathType Container)) { + elseif ($args.Length -eq 1 -and (Test-Path $args[0] -PathType Container -LiteralPath)) { __zoxide_cd $args[0] $true } + elseif ($args.Length -eq 1 -and (Test-Path $args[0] -PathType Container -Path)) { + __zoxide_cd $args[0] $false + } else { $result = __zoxide_pwd if ($null -ne $result) {