diff options
author | Ajeet D'Souza <98ajeet@gmail.com> | 2022-04-22 13:11:11 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 13:11:11 +0530 |
commit | 612f264dd413add537eb9dd43a1a3dfab4580715 (patch) | |
tree | 07b828c60c52fca2ad504d027446c2fbfaac1061 | |
parent | 24d21ec8ab1f091a2dd684a11e8807b7ff1428f3 (diff) |
Upgrade to Nushell 0.61 (#362)
-rw-r--r-- | CHANGELOG.md | 5 | ||||
-rw-r--r-- | Cargo.lock | 38 | ||||
-rw-r--r-- | README.md | 18 | ||||
-rw-r--r-- | contrib/completions/zoxide.ts | 4 | ||||
-rw-r--r-- | man/man1/zoxide-init.1 | 14 | ||||
-rw-r--r-- | shell.nix | 4 | ||||
-rw-r--r-- | src/shell.rs | 2 | ||||
-rw-r--r-- | templates/bash.txt | 3 | ||||
-rw-r--r-- | templates/elvish.txt | 3 | ||||
-rw-r--r-- | templates/fish.txt | 3 | ||||
-rw-r--r-- | templates/nushell.txt | 98 | ||||
-rw-r--r-- | templates/posix.txt | 3 | ||||
-rw-r--r-- | templates/powershell.txt | 3 | ||||
-rw-r--r-- | templates/xonsh.txt | 3 | ||||
-rw-r--r-- | templates/zsh.txt | 3 | ||||
-rw-r--r-- | xtask/src/main.rs | 7 |
16 files changed, 100 insertions, 111 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index e48170a..5431d99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,19 +13,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Manpages: moved to `man/man1/*.1`. - Replace `--no-aliases` with `--no-cmd`. +- Elvish: upgrade minimum supported version to v0.18.0. +- Nushell: upgrade minimum supported version to v0.61.0. ### Fixed - Bash/Zsh: rename `_z` completion function to avoid conflicts with other shell plugins. -- Elvish: upgrade to new lambda syntax. - Fzf: added `--keep-right` option by default, upgrade minimum supported version to v0.21.0. - Bash: only enable completions on 4.4+. - Fzf: bypass `ls` alias in preview window. - Retain ownership of database file. -- Elvish: upgrade to new try-catch syntax, upgrade minimum supported version to - v0.18.0. - `zoxide query --interactive` should not conflict with `--score`. ## [0.8.0] - 2021-12-25 @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" +checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" [[package]] name = "askama" @@ -131,16 +131,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "3.1.8" +version = "3.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71c47df61d9e16dc010b55dba1952a57d8c215dbb533fd13cdd13369aac73b1c" +checksum = "3124f3f75ce09e22d1410043e1e24f2ecc44fad3afe4f08408f1f7663d68da2b" dependencies = [ "atty", "bitflags", "clap_derive", + "clap_lex", "indexmap", "lazy_static", - "os_str_bytes", "strsim", "termcolor", "textwrap", @@ -148,18 +148,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "3.1.1" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df6f3613c0a3cddfd78b41b10203eb322cb29b600cbdf808a7d3db95691b8e25" +checksum = "1506b87ee866f7a53a5131f7b31fba656170d797e873d0609884cfd56b8bbda8" dependencies = [ "clap", ] [[package]] name = "clap_complete_fig" -version = "3.1.4" +version = "3.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "690eb5abb7a98df1a64a3028beaf95af7e0ceb13da3186e6d0a86161af76309e" +checksum = "3918ed0e233c37ab6055a2dc4b2bad2e113d44f56675e0140936b9bd253e4505" dependencies = [ "clap", "clap_complete", @@ -179,6 +179,15 @@ dependencies = [ ] [[package]] +name = "clap_lex" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "189ddd3b5d32a70b35e7686054371742a937b0d99128e76dde6340210e966669" +dependencies = [ + "os_str_bytes", +] + +[[package]] name = "crossbeam-utils" version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -352,9 +361,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.122" +version = "0.2.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec647867e2bf0772e28c8bcde4f0d19a9216916e890543b5a03ed8ef27b8f259" +checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" [[package]] name = "log" @@ -454,9 +463,6 @@ name = "os_str_bytes" version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" -dependencies = [ - "memchr", -] [[package]] name = "predicates" @@ -520,9 +526,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632d02bff7f874a36f33ea8bb416cd484b90cc66c1194b1a1110d067a7013f58" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" dependencies = [ "proc-macro2", ] @@ -13,6 +13,7 @@ [![crates.io][crates.io-badge]][crates.io] [![Downloads][downloads-badge]][releases] +[![License][license-badge]][license] [![Built with Nix][builtwithnix-badge]][builtwithnix] zoxide is a **smarter cd command**, inspired by z and autojump. @@ -189,13 +190,20 @@ zoxide init fish | source <details> <summary>Nushell</summary> -Add this to your configuration (find it by running `config path` in Nushell): +Add this to your env file (find it by running `$nu.env-path` in Nushell): -```toml -startup = ["zoxide init nushell --hook prompt | save ~/.zoxide.nu", "source ~/.zoxide.nu"] +```sh +zoxide init nushell --hook prompt | save ~/.zoxide.nu +``` + +Now, add this to the end of your config file (find it by running +`$nu.config-path` in Nushell): + +```sh +source ~/.zoxide.nu ``` -Note: zoxide only supports Nushell v0.37.0 and above. +Note: zoxide only supports Nushell v0.61.0 and above. </details> @@ -389,6 +397,8 @@ They must be set before `zoxide init` is called. [guru overlay]: https://github.com/gentoo-mirror/guru [homebrew]: https://formulae.brew.sh/formula/zoxide [issues]: https://github.com/ajeetdsouza/zoxide/issues/new +[license-badge]: https://img.shields.io/github/license/ajeetdsouza/zoxide?color=lightgray&style=flat-square +[license]: https://github.com/ajeetdsouza/zoxide/blob/main/LICENSE [linuxbrew]: https://formulae.brew.sh/formula-linux/zoxide [macports]: https://ports.macports.org/port/zoxide/summary [neovim]: https://github.com/neovim/neovim diff --git a/contrib/completions/zoxide.ts b/contrib/completions/zoxide.ts index d665f8c..fe986b7 100644 --- a/contrib/completions/zoxide.ts +++ b/contrib/completions/zoxide.ts @@ -142,10 +142,6 @@ const completion: Fig.Spec = { { name: ["-s", "--score"], description: "Print score with results", - exclusiveOn: [ - "-i", - "--interactive", - ], }, { name: ["-h", "--help"], diff --git a/man/man1/zoxide-init.1 b/man/man1/zoxide-init.1 index 62c0bba..79d9ee8 100644 --- a/man/man1/zoxide-init.1 +++ b/man/man1/zoxide-init.1 @@ -30,14 +30,20 @@ Add this to your configuration (usually \fB~/.config/fish/config.fish\fR): .fi .TP .B nushell -Add this to your configuration (find it by running \fBconfig path\fR in -Nushell): +Add this to your env file (find it by running \fB$nu.env-path\fR in Nushell): .sp .nf - \fBstartup = ["zoxide init nushell --hook prompt | save ~/.zoxide.nu", "source ~/.zoxide.nu"]\fR + \fBzoxide init nushell --hook prompt | save ~/.zoxide.nu\fR .fi .sp -Note: zoxide only supports Nushell v0.37.0 and above. +Now, add this to the end of your config file (find it by running +\fB$nu.config-path\fR in Nushell): +.sp +.nf + \fBsource ~/.zoxide.nu\fR +.fi +.sp +Note: zoxide only supports Nushell v0.61.0 and above. .TP .B powershell Add this to your configuration (find it by running \fBecho $profile\fR in @@ -1,8 +1,8 @@ let rust = import (builtins.fetchTarball - "https://github.com/oxalica/rust-overlay/archive/46d8d20fce510c6a25fa66f36e31f207f6ea49e4.tar.gz"); + "https://github.com/oxalica/rust-overlay/archive/6ca3338755233ddcb9bd4c80ecb17f453cfd0730.tar.gz"); pkgs = import (builtins.fetchTarball - "https://github.com/NixOS/nixpkgs/archive/d19a9162c848517cfc9437f10945b736d718b948.tar.gz") { + "https://github.com/NixOS/nixpkgs/archive/5d7c1f912f864e56de88c6f81a93173d12878f1e.tar.gz") { overlays = [ rust ]; }; in pkgs.mkShell { diff --git a/src/shell.rs b/src/shell.rs index 79554f4..5662aa0 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -149,7 +149,7 @@ mod tests { let source = Nushell(&opts).render().unwrap(); let tempdir = tempfile::tempdir().unwrap(); - let tempdir = tempdir.path().to_str().unwrap(); + let tempdir = tempdir.path(); let assert = Command::new("nu").env("HOME", tempdir).args(&["--commands", &source]).assert().success().stderr(""); diff --git a/templates/bash.txt b/templates/bash.txt index 9ee60fa..9b3c9f4 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -58,8 +58,7 @@ fi {% endif -%} {{ section }} -# When using zoxide with --no-cmd, alias these internal functions as -# desired. +# When using zoxide with --no-cmd, alias these internal functions as desired. # __zoxide_z_prefix='z#' diff --git a/templates/elvish.txt b/templates/elvish.txt index 5256756..a236c8b 100644 --- a/templates/elvish.txt +++ b/templates/elvish.txt @@ -41,8 +41,7 @@ if (builtin:not (builtin:eq $E:__zoxide_shlvl $E:SHLVL)) { {%- endif %} {{ section }} -# When using zoxide with --no-cmd, alias these internal functions as -# desired. +# When using zoxide with --no-cmd, alias these internal functions as desired. # # Jump to a directory using only keywords. diff --git a/templates/fish.txt b/templates/fish.txt index ff11078..0403f01 100644 --- a/templates/fish.txt +++ b/templates/fish.txt @@ -53,8 +53,7 @@ end {%- endif %} {{ section }} -# When using zoxide with --no-cmd, alias these internal functions as -# desired. +# When using zoxide with --no-cmd, alias these internal functions as desired. # # Jump to a directory using only keywords. diff --git a/templates/nushell.txt b/templates/nushell.txt index 0e91a42..15d2ae0 100644 --- a/templates/nushell.txt +++ b/templates/nushell.txt @@ -4,85 +4,63 @@ # Code generated by zoxide. DO NOT EDIT. {{ section }} -# Utility functions for zoxide. -# - -# Default prompt for Nushell. -def __zoxide_prompt [] { - let git = $'(do -i {git rev-parse --abbrev-ref HEAD} | str trim -rc (char newline))' - let git = (if ($git | str length) == 0 { '' } { - build-string (char lparen) (ansi cb) $git (ansi reset) (char rparen) - }) - build-string (ansi gb) (pwd) (ansi reset) $git '> ' -} - -{{ section }} # Hook configuration for zoxide. # - -# Hook to add new entries to the database. -{%- match hook %} +{% match hook %} {%- when InitHook::None %} {{ not_configured }} {%- when InitHook::Prompt %} +# Default prompt for Nushell. +let-env __zoxide_oldprompt = (if '__zoxide_oldprompt' in (env).name { + $env.__zoxide_oldprompt +} else if 'PROMPT_COMMAND' in (env).name { + $env.PROMPT_COMMAND +} else { + { $env.PWD } +}) + +# Hook to add new entries to the database. def __zoxide_hook [] { - shells | where active == $true && name == filesystem | get path | each { - zoxide add -- $it - } + zoxide add -- $env.PWD } # Initialize hook. -let-env PROMPT_COMMAND = ( - let prompt = (if ($nu.env | select PROMPT_COMMAND | empty?) { - if ($nu.config | select prompt | empty?) { '__zoxide_prompt' } { $nu.config.prompt } - } { $nu.env.PROMPT_COMMAND }); - if ($prompt | str contains '__zoxide_hook') { $prompt } { $'__zoxide_hook;($prompt)' } -) +let-env PROMPT_COMMAND = { + __zoxide_hook + do $env.__zoxide_oldprompt +} {%- when InitHook::Pwd %} -$'zoxide: PWD hooks are not supported on Nushell.(char nl)Use (char sq)zoxide init nushell --hook prompt(char sq) instead.(char nl)' +echo "zoxide: PWD hooks are not supported on Nushell.\nUse `zoxide init nushell --hook prompt` instead." + {%- endmatch %} {{ section }} -# When using zoxide with --no-cmd, alias these internal functions as -# desired. +# When using zoxide with --no-cmd, alias these internal functions as desired. # # Jump to a directory using only keywords. -def __zoxide_z [...rest:string] { - if (shells | where active == $true | get name) != filesystem { - if ($rest | length) > 1 { - $'zoxide: can only jump directories on filesystem(char nl)' - } { - cd $rest +def-env __zoxide_z [...rest:string] { + # `z -` does not work yet, see https://github.com/nushell/nushell/issues/4769 + let arg0 = ($rest | append '~').0 + let path = if ($rest | length) <= 1 && ($arg0 | path expand | path type) == dir { + $arg0 + } else { + (zoxide query --exclude $env.PWD -- $rest | str trim -r -c "\n") + } + cd $path {%- if echo %} - pwd + echo $env.PWD {%- endif %} - } - } { - let arg0 = ($rest | append '~' | first 1); - if ($rest | length) <= 1 && ($arg0 == '-' || ($arg0 | path expand | path exists)) { - cd $arg0 - } { - cd $'(zoxide query --exclude (pwd) -- $rest | str trim -rc (char newline))' - } -{%- if echo %} - pwd -{%- endif %} - } } # Jump to a directory using interactive search. -def __zoxide_zi [...rest:string] { - if (shells | where active == $true | get name) != filesystem { - $'zoxide: can only jump directories on filesystem(char nl)' - } { - cd $'(zoxide query -i -- $rest | str trim -rc (char newline))' +def-env __zoxide_zi [...rest:string] { + cd $'(zoxide query -i -- $rest | str trim -r -c "\n")' {%- if echo %} - pwd + echo $env.PWD {%- endif %} - } } {{ section }} @@ -102,9 +80,13 @@ alias {{cmd}}i = __zoxide_zi {%- endmatch %} {{ section }} -# To initialize zoxide, add this to your configuration (find it by running -# `config path` in Nushell): +# Add this to your env file (find it by running `$nu.env-path` in Nushell): +# +# zoxide init nushell --hook prompt | save ~/.zoxide.nu +# +# Now, add this to the end of your config file (find it by running +# `$nu.config-path` in Nushell): # -# startup = ['zoxide init nushell --hook prompt | save ~/.zoxide.nu', 'source ~/.zoxide.nu'] +# source ~/.zoxide.nu # -# Note: zoxide only supports Nushell v0.37.0 and above. +# Note: zoxide only supports Nushell v0.61.0 and above. diff --git a/templates/posix.txt b/templates/posix.txt index 29989d3..f9fd9a5 100644 --- a/templates/posix.txt +++ b/templates/posix.txt @@ -47,8 +47,7 @@ fi {%- endmatch %} {{ section }} -# When using zoxide with --no-cmd, alias these internal functions as -# desired. +# When using zoxide with --no-cmd, alias these internal functions as desired. # # Jump to a directory using only keywords. diff --git a/templates/powershell.txt b/templates/powershell.txt index 69e904c..6c89fc1 100644 --- a/templates/powershell.txt +++ b/templates/powershell.txt @@ -67,8 +67,7 @@ if ($__zoxide_hooked -ne 1) { } {{ section }} -# When using zoxide with --no-cmd, alias these internal functions as -# desired. +# When using zoxide with --no-cmd, alias these internal functions as desired. # # Jump to a directory using only keywords. diff --git a/templates/xonsh.txt b/templates/xonsh.txt index f6f7802..07baee5 100644 --- a/templates/xonsh.txt +++ b/templates/xonsh.txt @@ -108,8 +108,7 @@ if "__zoxide_hook" not in globals(): {% endif %} {{ section }} -# When using zoxide with --no-cmd, alias these internal functions as -# desired. +# When using zoxide with --no-cmd, alias these internal functions as desired. # diff --git a/templates/zsh.txt b/templates/zsh.txt index 545de74..ded2f34 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -46,8 +46,7 @@ fi {%- endif %} {{ section }} -# When using zoxide with --no-cmd, alias these internal functions as -# desired. +# When using zoxide with --no-cmd, alias these internal functions as desired. # __zoxide_z_prefix='z#' diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 69df33d..4af61c6 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -136,6 +136,7 @@ fn enable_nix() -> bool { } let nix_enabled = env::var_os("IN_NIX_SHELL").unwrap_or_default() == "pure"; if nix_enabled { + env::set_var("CARGO_TARGET_DIR", "target_nix"); return true; } let nix_detected = Command::new("nix-shell").arg("--version").status().map(|s| s.success()).unwrap_or(false); @@ -147,10 +148,6 @@ fn enable_nix() -> bool { let args = env::args(); let cmd = shell_words::join(args); - let status = Command::new("nix-shell") - .args(&["--pure", "--run", &cmd, "--", "shell.nix"]) - .env("CARGO_TARGET_DIR", "target_nix") - .status() - .unwrap(); + let status = Command::new("nix-shell").args(&["--pure", "--run", &cmd, "--", "shell.nix"]).status().unwrap(); process::exit(status.code().unwrap_or(1)); } |