diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 96261f1..d6427cc 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -36,17 +36,17 @@ 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
- - 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 }}
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
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 419c5ae..2089362 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,27 @@ 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
+
+- Support for Tcsh.
+- Added `--score` flag to `zoxide add`.
+- POSIX: add doctor to diagnose common issues.
+
+### Changed
+
+- Bash: zoxide will now rewrite the prompt when using Space-Tab completions.
+
+### 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`.
+
## [0.9.7] - 2025-02-10
### Added
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/README.md b/README.md
index 5559ecc..3edfaba 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@

Warp, the intelligent terminal
-Available for MacOS and Linux
+Available for MacOS, Linux, and Windows
Visit
warp.dev
@@ -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
@@ -323,7 +335,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.51.0.
4. **Import your data** (optional)
@@ -461,14 +473,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]:
@@ -518,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
@@ -528,15 +543,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 +564,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
diff --git a/contrib/completions/_zoxide b/contrib/completions/_zoxide
index 69882b4..2f3557f 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]' \
@@ -112,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 elvish fish nushell posix powershell tcsh xonsh zsh)' \
&& ret=0
;;
(query)
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..909bc57 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=()
;;
@@ -165,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 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.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..9e593d0 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",
@@ -185,6 +194,7 @@ const completion: Fig.Spec = {
"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/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/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..d25cda3 100644
--- a/src/cmd/cmd.rs
+++ b/src/cmd/cmd.rs
@@ -58,6 +58,11 @@ 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
@@ -148,6 +153,7 @@ pub enum InitShell {
#[clap(alias = "ksh")]
Posix,
Powershell,
+ Tcsh,
Xonsh,
Zsh,
}
diff --git a/src/cmd/init.rs b/src/cmd/init.rs
index 3f79ed6..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, 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<()> {
@@ -22,6 +22,7 @@ impl Run for Init {
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/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,
diff --git a/src/shell.rs b/src/shell.rs
index 721553d..83243d8 100644
--- a/src/shell.rs
+++ b/src/shell.rs
@@ -29,6 +29,7 @@ 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");
@@ -248,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/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)
})();
diff --git a/templates/bash.txt b/templates/bash.txt
index 560a050..fb037fc 100644
--- a/templates/bash.txt
+++ b/templates/bash.txt
@@ -66,8 +66,11 @@ 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
+ # shellcheck disable=SC2199
+ [[ ${PROMPT_COMMAND[@]:-} == *'__zoxide_hook'* ]] && return 0
+ # shellcheck disable=SC2199
+ [[ ${__vsc_original_prompt_command[@]:-} == *'__zoxide_hook'* ]] && return 0
_ZO_DOCTOR=0
\builtin printf '%s\n' \
@@ -144,8 +147,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 +163,20 @@ 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}" }}")" && {
+ # 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}/")
+
+ # 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
}
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"
}
diff --git a/templates/posix.txt b/templates/posix.txt
index a1793ad..b7ba9b3 100644
--- a/templates/posix.txt
+++ b/templates/posix.txt
@@ -43,6 +43,30 @@ 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 +80,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 +102,7 @@ __zoxide_z() {
# Jump to a directory using interactive search.
__zoxide_zi() {
+ __zoxide_doctor
__zoxide_result="$(\command zoxide query --interactive -- "$@")" && __zoxide_cd "${__zoxide_result}"
}
diff --git a/templates/powershell.txt b/templates/powershell.txt
index e99e361..e134ab1 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
diff --git a/templates/tcsh.txt b/templates/tcsh.txt
new file mode 100644
index 0000000..b0559a0
--- /dev/null
+++ b/templates/tcsh.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 ~/.tcshrc):
+#
+# zoxide init tcsh > ~/.zoxide.tcsh
+# source ~/.zoxide.tcsh
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."""