diff --git a/CHANGELOG.md b/CHANGELOG.md index 46be75f..bb0a884 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Fish/Zsh: Aliases on `__zoxide_z` will now use completions. +- Fish/Zsh: aliases on `__zoxide_z` will now use completions. +- Nushell: add support for v0.78.0. +- Fish: plugin now works on older versions. ## [0.9.0] - 2023-01-08 diff --git a/README.md b/README.md index 3e0afd6..2070286 100644 --- a/README.md +++ b/README.md @@ -196,9 +196,6 @@ zoxide can be installed in 4 easy steps: > ```fish > zoxide init fish | source > ``` - > - > **Note** - > zoxide only supports fish v3.4.0 and above. diff --git a/man/man1/zoxide-init.1 b/man/man1/zoxide-init.1 index e3331fb..4b7d858 100644 --- a/man/man1/zoxide-init.1 +++ b/man/man1/zoxide-init.1 @@ -28,8 +28,6 @@ Add this to your configuration (usually \fB~/.config/fish/config.fish\fR): .nf \fBzoxide init fish | source\fR .fi -.sp -Note: zoxide only supports fish v3.4.0 and above. .TP .B nushell Add this to your env file (find it by running \fB$nu.env-path\fR in Nushell): diff --git a/src/cmd/init.rs b/src/cmd/init.rs index 2c7609d..60bad63 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -6,7 +6,7 @@ use askama::Template; use crate::cmd::{Init, InitShell, Run}; use crate::config; use crate::error::BrokenPipeHandler; -use crate::shell::{self, Opts}; +use crate::shell::{Bash, Elvish, Fish, Nushell, Opts, Posix, Powershell, Xonsh, Zsh}; impl Run for Init { fn run(&self) -> Result<()> { @@ -16,14 +16,14 @@ impl Run for Init { let opts = &Opts { cmd, hook: self.hook, echo, resolve_symlinks }; let source = match self.shell { - InitShell::Bash => shell::Bash(opts).render(), - InitShell::Elvish => shell::Elvish(opts).render(), - InitShell::Fish => shell::Fish(opts).render(), - InitShell::Nushell => shell::Nushell(opts).render(), - InitShell::Posix => shell::Posix(opts).render(), - InitShell::Powershell => shell::Powershell(opts).render(), - InitShell::Xonsh => shell::Xonsh(opts).render(), - InitShell::Zsh => shell::Zsh(opts).render(), + InitShell::Bash => Bash(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::Xonsh => Xonsh(opts).render(), + InitShell::Zsh => Zsh(opts).render(), } .context("could not render template")?; writeln!(io::stdout(), "{source}").pipe_exit("stdout") diff --git a/templates/fish.txt b/templates/fish.txt index 65de458..d8fc683 100644 --- a/templates/fish.txt +++ b/templates/fish.txt @@ -67,7 +67,7 @@ set __zoxide_z_prefix 'z!' # Jump to a directory using only keywords. function __zoxide_z set -l argc (count $argv) - set -l completion_regex '^'(string escape --style=regex $__zoxide_z_prefix)'(.*)$' + set -l prefix (string escape --style=regex $__zoxide_z_prefix) if test $argc -eq 0 __zoxide_cd $HOME @@ -75,7 +75,7 @@ function __zoxide_z __zoxide_cd - else if test $argc -eq 1 -a -d $argv[1] __zoxide_cd $argv[1] - else if set -l result (string match --groups-only --regex $completion_regex $argv[-1]) + else if set -l result (string replace --regex ^$prefix $argv[-1]) __zoxide_cd $result else set -l result (command zoxide query --exclude (__zoxide_pwd) -- $argv) @@ -131,5 +131,3 @@ alias {{cmd}}i=__zoxide_zi # ~/.config/fish/config.fish): # # zoxide init fish | source -# -# Note: zoxide only supports fish v3.4.0 and above.