From 9ff899308deb5c613640efc903e840a718592da9 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Tue, 31 Aug 2021 16:29:57 +0530 Subject: [PATCH] Use PROMPT_STRING environment variable --- CHANGELOG.md | 6 ++++++ Cargo.lock | 44 +++++++++++++++++++++---------------------- Cargo.toml | 2 +- README.md | 6 ++---- man/zoxide-init.1 | 7 ++++--- templates/elvish.txt | 2 +- templates/nushell.txt | 18 +++++++++++++----- 7 files changed, 49 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 898f9cb..0942684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Changed + +- Nushell: upgrade minimum supported version to v0.36.0. +- Nushell: easier installation instructions. + ### Fixed - Elvish: unable to `z` into directories by path. - Elvish: don't show traceback when `z` or `zi` fails. +- Elvish: nested shells do not initialize correctly. ## [0.7.4] - 2020-08-15 diff --git a/Cargo.lock b/Cargo.lock index e417b60..9c4319b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,9 +57,9 @@ dependencies = [ [[package]] name = "assert_cmd" -version = "1.0.8" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c98233c6673d8601ab23e77eb38f999c51100d46c5703b17288c57fddf3a1ffe" +checksum = "54f002ce7d0c5e809ebb02be78fd503aeed4a511fd0fcaff6e6914cbdabbfa33" dependencies = [ "bstr", "doc-comment", @@ -97,9 +97,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da1976d75adbe5fbc88130ecd119529cf1cc6a93ae1546d8696ee66f0d21af1" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitvec" @@ -115,9 +115,9 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" +checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" dependencies = [ "lazy_static", "memchr", @@ -302,21 +302,21 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.99" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" +checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21" [[package]] name = "memchr" -version = "2.3.4" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "nom" -version = "6.2.1" +version = "6.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c5c51b9083a3c620fa67a2a635d1ce7d95b897e957d6b28ff9a5da960a103a6" +checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2" dependencies = [ "bitvec", "funty", @@ -357,9 +357,9 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "predicates" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc3d91237f5de3bcd9d927e24d03b495adb6135097b001cea7403e2d573d00a9" +checksum = "c143348f141cc87aab5b950021bac6145d0e5ae754b0591de23244cee42c9308" dependencies = [ "difflib", "itertools", @@ -408,9 +408,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" +checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" dependencies = [ "unicode-xid", ] @@ -540,18 +540,18 @@ checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" [[package]] name = "serde" -version = "1.0.127" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f03b9878abf6d14e6779d3f24f07b2cfa90352cfec4acc5aab8f1ac7f146fae8" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.127" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a024926d3432516606328597e0f224a51355a493b49fdd67e9209187cbe55ecc" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -572,9 +572,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.74" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c" +checksum = "b7f58f7e8eaa0009c5fec437aabf511bd9933e4b2d7407bd05273c01a8906ea7" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index a971758..88e2b2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ rand = { version = "0.8.4", features = [ ], default-features = false } [dev-dependencies] -assert_cmd = "1.0.1" +assert_cmd = "2.0.0" rstest = "0.11.0" [build-dependencies] diff --git a/README.md b/README.md index 82e916d..d1f79df 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ Add this to your configuration (usually `~/.elvish/rc.elv`): eval (zoxide init elvish | slurp) ``` -Note that zoxide only supports elvish v0.16.0+. +Note: zoxide only supports elvish v0.16.0 and above. @@ -172,12 +172,10 @@ zoxide init fish | source Add this to your configuration (find it by running `config path` in Nushell): ```toml -prompt = "__zoxide_hook;__zoxide_prompt" startup = ["zoxide init nushell --hook prompt | save ~/.zoxide.nu", "source ~/.zoxide.nu"] ``` -You can replace `__zoxide_prompt` with a custom prompt. Note that zoxide only -supports Nushell v0.33.0+. +Note: zoxide only supports Nushell v0.36.0 and above. diff --git a/man/zoxide-init.1 b/man/zoxide-init.1 index 2a38003..be6b1a0 100644 --- a/man/zoxide-init.1 +++ b/man/zoxide-init.1 @@ -19,6 +19,7 @@ Add this to your configuration (usually \fI~/.elvish/rc.elv\fR): .nf \fBeval $(zoxide init elvish | slurp)\fR .fi +Note: zoxide only supports elvish v0.16.0 and above. .TP .B fish Add this to your configuration (usually \fI~/.config/fish/config.fish\fR): @@ -32,14 +33,14 @@ Add this to your configuration (find it by running \fBconfig path\fR in Nushell): .sp .nf - \fBprompt = "__zoxide_hook;__zoxide_prompt"\fR \fBstartup = ["zoxide init nushell --hook prompt | save ~/.zoxide.nu", "source ~/.zoxide.nu"]\fR .fi .sp -You can replace \fB__zoxide_prompt\fR with a custom prompt. +Note: zoxide only supports Nushell v0.36.0 and above. .TP .B powershell -Add this to your configuration (find it with \fIecho $profile\fR): +Add this to your configuration (find it by running \fBecho $profile\fR in +PowerShell): .sp .nf \fBInvoke-Expression (& { diff --git a/templates/elvish.txt b/templates/elvish.txt index 25c4f7b..c40e469 100644 --- a/templates/elvish.txt +++ b/templates/elvish.txt @@ -95,4 +95,4 @@ edit:add-var zi~ $__zoxide_zi~ # # eval (zoxide init elvish | slurp) # -# Note that zoxide only supports elvish v0.16.0 and above. +# Note: zoxide only supports elvish v0.16.0 and above. diff --git a/templates/nushell.txt b/templates/nushell.txt index 7929bfa..41e32ae 100644 --- a/templates/nushell.txt +++ b/templates/nushell.txt @@ -25,15 +25,25 @@ def __zoxide_prompt [] { # Hook to add new entries to the database. {%- match hook %} {%- when InitHook::None %} -def __zoxide_hook [] {} +{{ not_configured }} {%- when InitHook::Prompt %} def __zoxide_hook [] { shells | where active == $true && name == filesystem | get path | each { zoxide add -- $it } } +# Initialize hook. +if ($nu.env | select PROMPT_STRING | empty?) { + if ($nu.config | select prompt | empty?) { + let-env PROMPT_STRING = '__zoxide_hook;__zoxide_prompt' + } { + let-env PROMPT_STRING = $'__zoxide_hook;($nu.config.prompt)' + } +} { + let-env PROMPT_STRING = $'__zoxide_hook;($nu.env.PROMPT_STRING)' +} + {%- when InitHook::Pwd %} -def __zoxide_hook [] {} $'zoxide: PWD hooks are not supported on Nushell.(char nl)Use (char sq)zoxide init nushell --hook prompt(char sq) instead.(char nl)' {%- endmatch %} @@ -98,8 +108,6 @@ alias {{cmd}}i = __zoxide_zi # To initialize zoxide, add this to your configuration (find it by running # `config path` in Nushell): # -# prompt = '__zoxide_hook;__zoxide_prompt' # startup = ['zoxide init nushell --hook prompt | save ~/.zoxide.nu', 'source ~/.zoxide.nu'] # -# You can replace __zoxide_prompt with a custom prompt. Note that zoxide only -# supports Nushell v0.33.0+. +# Note: zoxide only supports Nushell v0.36.0 and above.