Avoid accidentally redefining hook on Nushell
This commit is contained in:
parent
6c1da6ec96
commit
55a509f520
|
|
@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Nushell: upgrade minimum supported version to v0.73.0.
|
- Nushell: upgrade minimum supported version to v0.73.0.
|
||||||
- Zsh: fix extra space in interactive completions when no match is found.
|
- Zsh: fix extra space in interactive completions when no match is found.
|
||||||
- Fzf: various improvements.
|
- Fzf: various improvements.
|
||||||
|
- Nushell: Accidental redefinition of hooks when initialized twice.
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ Note: zoxide only supports fish v3.4.0 and above.
|
||||||
Add this to your env file (find it by running \fB$nu.env-path\fR in Nushell):
|
Add this to your env file (find it by running \fB$nu.env-path\fR in Nushell):
|
||||||
.sp
|
.sp
|
||||||
.nf
|
.nf
|
||||||
\fBzoxide init nushell --hook prompt | save -f ~/.zoxide.nu\fR
|
\fBzoxide init nushell | save -f ~/.zoxide.nu\fR
|
||||||
.fi
|
.fi
|
||||||
.sp
|
.sp
|
||||||
Now, add this to the end of your config file (find it by running
|
Now, add this to the end of your config file (find it by running
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use std::path::PathBuf;
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use glob::Pattern;
|
use glob::Pattern;
|
||||||
|
|
||||||
use crate::db2::Rank;
|
use crate::db::Rank;
|
||||||
|
|
||||||
pub fn data_dir() -> Result<PathBuf> {
|
pub fn data_dir() -> Result<PathBuf> {
|
||||||
let path = match env::var_os("_ZO_DATA_DIR") {
|
let path = match env::var_os("_ZO_DATA_DIR") {
|
||||||
|
|
|
||||||
|
|
@ -12,22 +12,25 @@
|
||||||
|
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
# Initialize hook to add new entries to the database.
|
# Initialize hook to add new entries to the database.
|
||||||
|
if (not ($env | default false __zoxide_hooked | get __zoxide_hooked)) {
|
||||||
|
let-env __zoxide_hooked = true
|
||||||
{%- if hook == InitHook::Prompt %}
|
{%- if hook == InitHook::Prompt %}
|
||||||
let-env config = ($env | default {} config).config
|
let-env config = ($env | default {} config).config
|
||||||
let-env config = ($env.config | default {} hooks)
|
let-env config = ($env.config | default {} hooks)
|
||||||
let-env config = ($env.config | update hooks ($env.config.hooks | default [] pre_prompt))
|
let-env config = ($env.config | update hooks ($env.config.hooks | default [] pre_prompt))
|
||||||
let-env config = ($env.config | update hooks.pre_prompt ($env.config.hooks.pre_prompt | append {
|
let-env config = ($env.config | update hooks.pre_prompt ($env.config.hooks.pre_prompt | append {
|
||||||
zoxide add -- $env.PWD
|
zoxide add -- $env.PWD
|
||||||
}))
|
}))
|
||||||
{%- else if hook == InitHook::Pwd %}
|
{%- else if hook == InitHook::Pwd %}
|
||||||
let-env config = ($env | default {} config).config
|
let-env config = ($env | default {} config).config
|
||||||
let-env config = ($env.config | default {} hooks)
|
let-env config = ($env.config | default {} hooks)
|
||||||
let-env config = ($env.config | update hooks ($env.config.hooks | default {} env_change))
|
let-env config = ($env.config | update hooks ($env.config.hooks | default {} env_change))
|
||||||
let-env config = ($env.config | update hooks.env_change ($env.config.hooks.env_change | default [] PWD))
|
let-env config = ($env.config | update hooks.env_change ($env.config.hooks.env_change | default [] PWD))
|
||||||
let-env config = ($env.config | update hooks.env_change.PWD ($env.config.hooks.env_change.PWD | append {|_, dir|
|
let-env config = ($env.config | update hooks.env_change.PWD ($env.config.hooks.env_change.PWD | append {|_, dir|
|
||||||
zoxide add -- $dir
|
zoxide add -- $dir
|
||||||
}))
|
}))
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
}
|
||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
|
@ -77,7 +80,7 @@ alias {{cmd}}i = __zoxide_zi
|
||||||
{{ section }}
|
{{ section }}
|
||||||
# Add this to your env file (find it by running `$nu.env-path` in Nushell):
|
# Add this to your env file (find it by running `$nu.env-path` in Nushell):
|
||||||
#
|
#
|
||||||
# zoxide init nushell --hook prompt | save -f ~/.zoxide.nu
|
# zoxide init nushell | save -f ~/.zoxide.nu
|
||||||
#
|
#
|
||||||
# Now, add this to the end of your config file (find it by running
|
# Now, add this to the end of your config file (find it by running
|
||||||
# `$nu.config-path` in Nushell):
|
# `$nu.config-path` in Nushell):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue