Add support for Elvish
This commit is contained in:
parent
3398cc721d
commit
638d804613
|
|
@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Support for [Nushell](https://www.nushell.sh/).
|
- Support for [Nushell](https://www.nushell.sh/).
|
||||||
|
- Support for [Elvish](https://elv.sh/).
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `z` now excludes the current directory from search results.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ in
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
pkgs-master.cargo-audit
|
pkgs-master.cargo-audit
|
||||||
|
pkgs-master.elvish
|
||||||
pkgs-master.nushell
|
pkgs-master.nushell
|
||||||
pkgs-python
|
pkgs-python
|
||||||
pkgs.bash
|
pkgs.bash
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ impl Cmd for Init {
|
||||||
|
|
||||||
let source = match self.shell {
|
let source = match self.shell {
|
||||||
Shell::Bash => shell::Bash(opts).render(),
|
Shell::Bash => shell::Bash(opts).render(),
|
||||||
|
Shell::Elvish => shell::Elvish(opts).render(),
|
||||||
Shell::Fish => shell::Fish(opts).render(),
|
Shell::Fish => shell::Fish(opts).render(),
|
||||||
Shell::Nushell => shell::Nushell(opts).render(),
|
Shell::Nushell => shell::Nushell(opts).render(),
|
||||||
Shell::Posix => shell::Posix(opts).render(),
|
Shell::Posix => shell::Posix(opts).render(),
|
||||||
|
|
@ -65,6 +66,7 @@ impl Cmd for Init {
|
||||||
#[derive(ArgEnum, Debug)]
|
#[derive(ArgEnum, Debug)]
|
||||||
enum Shell {
|
enum Shell {
|
||||||
Bash,
|
Bash,
|
||||||
|
Elvish,
|
||||||
Fish,
|
Fish,
|
||||||
Nushell,
|
Nushell,
|
||||||
Posix,
|
Posix,
|
||||||
|
|
|
||||||
32
src/shell.rs
32
src/shell.rs
|
|
@ -24,6 +24,7 @@ macro_rules! make_template {
|
||||||
}
|
}
|
||||||
|
|
||||||
make_template!(Bash, "bash.txt");
|
make_template!(Bash, "bash.txt");
|
||||||
|
make_template!(Elvish, "elvish.txt");
|
||||||
make_template!(Fish, "fish.txt");
|
make_template!(Fish, "fish.txt");
|
||||||
make_template!(Nushell, "nushell.txt");
|
make_template!(Nushell, "nushell.txt");
|
||||||
make_template!(Posix, "posix.txt");
|
make_template!(Posix, "posix.txt");
|
||||||
|
|
@ -123,8 +124,7 @@ mod tests {
|
||||||
let opts = dbg!(&opts()[i]);
|
let opts = dbg!(&opts()[i]);
|
||||||
let mut source = Bash(opts).render().unwrap();
|
let mut source = Bash(opts).render().unwrap();
|
||||||
source.push('\n');
|
source.push('\n');
|
||||||
// FIXME: caused by <https://github.com/djc/askama/issues/377>
|
|
||||||
let source = source.as_str().trim_start();
|
|
||||||
Command::new("shfmt")
|
Command::new("shfmt")
|
||||||
.args(&["-d", "-s", "-ln", "bash", "-i", "4", "-ci", "-"])
|
.args(&["-d", "-s", "-ln", "bash", "-i", "4", "-ci", "-"])
|
||||||
.write_stdin(source)
|
.write_stdin(source)
|
||||||
|
|
@ -134,6 +134,31 @@ mod tests {
|
||||||
.stderr("");
|
.stderr("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn elvish_elvish_#i() {
|
||||||
|
let opts = dbg!(&opts()[i]);
|
||||||
|
let mut source = String::new();
|
||||||
|
|
||||||
|
// Filter out lines using edit:add-var, since that function
|
||||||
|
// is only available in the interactive editor.
|
||||||
|
for line in Elvish(opts)
|
||||||
|
.render()
|
||||||
|
.unwrap()
|
||||||
|
.split('\n')
|
||||||
|
.filter(|line| !line.starts_with("edit:add-var"))
|
||||||
|
{
|
||||||
|
source.push_str(line);
|
||||||
|
source.push('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
Command::new("elvish")
|
||||||
|
.args(&["-c", &source, "-norc"])
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout("")
|
||||||
|
.stderr("");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fish_fish_#i() {
|
fn fish_fish_#i() {
|
||||||
let opts = dbg!(&opts()[i]);
|
let opts = dbg!(&opts()[i]);
|
||||||
|
|
@ -238,8 +263,7 @@ mod tests {
|
||||||
let opts = dbg!(&opts()[i]);
|
let opts = dbg!(&opts()[i]);
|
||||||
let mut source = Posix(opts).render().unwrap();
|
let mut source = Posix(opts).render().unwrap();
|
||||||
source.push('\n');
|
source.push('\n');
|
||||||
// FIXME: caused by <https://github.com/djc/askama/issues/377>
|
|
||||||
let source = source.as_str().trim_start();
|
|
||||||
Command::new("shfmt")
|
Command::new("shfmt")
|
||||||
.args(&["-d", "-s", "-ln", "posix", "-i", "4", "-ci", "-"])
|
.args(&["-d", "-s", "-ln", "posix", "-i", "4", "-ci", "-"])
|
||||||
.write_stdin(source)
|
.write_stdin(source)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{%- let SECTION = "# =============================================================================\n#" -%}
|
{%- let section = "# =============================================================================\n#" -%}
|
||||||
{%- let NOT_CONFIGURED = "# -- not configured --" -%}
|
{%- let not_configured = "# -- not configured --" -%}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Utility functions for zoxide.
|
# Utility functions for zoxide.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -20,14 +20,14 @@ function __zoxide_cd() {
|
||||||
\builtin cd "$@" {%- if echo %} && __zoxide_pwd {%- endif %}
|
\builtin cd "$@" {%- if echo %} && __zoxide_pwd {%- endif %}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Hook configuration for zoxide.
|
# Hook configuration for zoxide.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Hook to add new entries to the database.
|
# Hook to add new entries to the database.
|
||||||
{%- match hook %}
|
{%- match hook %}
|
||||||
{%- when Hook::None %}
|
{%- when Hook::None %}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
|
|
||||||
{%- when Hook::Prompt %}
|
{%- when Hook::Prompt %}
|
||||||
function __zoxide_hook() {
|
function __zoxide_hook() {
|
||||||
|
|
@ -50,13 +50,13 @@ function __zoxide_hook() {
|
||||||
if [ "${__zoxide_hooked}" != '1' ]; then
|
if [ "${__zoxide_hooked}" != '1' ]; then
|
||||||
__zoxide_hooked='1'
|
__zoxide_hooked='1'
|
||||||
{%- if hook == Hook::None %}
|
{%- if hook == Hook::None %}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
{%- else %}
|
{%- else %}
|
||||||
PROMPT_COMMAND="__zoxide_hook;${PROMPT_COMMAND:+${PROMPT_COMMAND}}"
|
PROMPT_COMMAND="__zoxide_hook;${PROMPT_COMMAND:+${PROMPT_COMMAND}}"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# When using zoxide with --no-aliases, alias these internal functions as
|
# When using zoxide with --no-aliases, alias these internal functions as
|
||||||
# desired.
|
# desired.
|
||||||
#
|
#
|
||||||
|
|
@ -87,7 +87,7 @@ function __zoxide_zi() {
|
||||||
__zoxide_result="$(zoxide query -i -- "$@")" && __zoxide_cd "${__zoxide_result}"
|
__zoxide_result="$(zoxide query -i -- "$@")" && __zoxide_cd "${__zoxide_result}"
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -113,11 +113,11 @@ function {{cmd}}i() {
|
||||||
}
|
}
|
||||||
|
|
||||||
{%- when None %}
|
{%- when None %}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
|
|
||||||
{%- endmatch %}
|
{%- endmatch %}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# To initialize zoxide with bash, add the following line to your bash
|
# To initialize zoxide with bash, add the following line to your bash
|
||||||
# configuration file (usually ~/.bashrc):
|
# configuration file (usually ~/.bashrc):
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
{%- let section = "# =============================================================================\n#" -%}
|
||||||
|
{%- let not_configured = "# -- not configured --" -%}
|
||||||
|
|
||||||
|
use builtin
|
||||||
|
use path
|
||||||
|
|
||||||
|
{{ section }}
|
||||||
|
# Utility functions for zoxide.
|
||||||
|
#
|
||||||
|
|
||||||
|
# cd + custom logic based on the value of _ZO_ECHO.
|
||||||
|
fn __zoxide_cd [path]{
|
||||||
|
builtin:cd $path
|
||||||
|
{%- if echo %}
|
||||||
|
builtin:echo $pwd
|
||||||
|
{%- endif %}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{ section }}
|
||||||
|
# Hook configuration for zoxide.
|
||||||
|
#
|
||||||
|
|
||||||
|
if (not (and (builtin:has-env __zoxide_hooked) (builtin:eq (builtin:get-env __zoxide_hooked) 1))) {
|
||||||
|
builtin:set-env __zoxide_hooked 1
|
||||||
|
|
||||||
|
# Initialize hook to track previous directory.
|
||||||
|
builtin:set-env __zoxide_oldpwd $pwd
|
||||||
|
before-chdir = [$@before-chdir [_]{ builtin:set-env __zoxide_oldpwd $pwd }]
|
||||||
|
|
||||||
|
# edit:before-readline = [{ echo 'going to read' }]
|
||||||
|
# after-chdir = [[dir]{ zoxide add $pwd }]
|
||||||
|
}
|
||||||
|
|
||||||
|
{{ section }}
|
||||||
|
# When using zoxide with --no-aliases, alias these internal functions as
|
||||||
|
# desired.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Jump to a directory using only keywords.
|
||||||
|
fn __zoxide_z [@rest]{
|
||||||
|
if (builtin:eq [] $rest) {
|
||||||
|
__zoxide_cd ~
|
||||||
|
} elif (builtin:eq [-] $rest) {
|
||||||
|
__zoxide_cd (builtin:get-env __zoxide_oldpwd)
|
||||||
|
} elif (and (builtin:eq (builtin:count $rest) 1) (path:is-dir $rest[0])) {
|
||||||
|
__zoxide_cd $rest[0]
|
||||||
|
} else {
|
||||||
|
__zoxide_cd (zoxide query --exclude $pwd -- $@rest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
edit:add-var __zoxide_z~ $__zoxide_z~
|
||||||
|
|
||||||
|
# Jump to a directory using interactive search.
|
||||||
|
fn __zoxide_zi [@rest]{
|
||||||
|
__zoxide_cd (zoxide query -i -- $@rest)
|
||||||
|
}
|
||||||
|
edit:add-var __zoxide_zi~ $__zoxide_zi~
|
||||||
|
|
||||||
|
{{ section }}
|
||||||
|
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
||||||
|
#
|
||||||
|
|
||||||
|
{%- match cmd %}
|
||||||
|
{%- when Some with (cmd) %}
|
||||||
|
|
||||||
|
edit:add-var z~ $__zoxide_z~
|
||||||
|
edit:add-var zi~ $__zoxide_zi~
|
||||||
|
|
||||||
|
{%- when None %}
|
||||||
|
{{ not_configured }}
|
||||||
|
|
||||||
|
{%- endmatch %}
|
||||||
|
|
||||||
|
{{ section }}
|
||||||
|
# To initialize zoxide with xonsh, add the following line to your elvish
|
||||||
|
# configuration file (usually ~/.elvish/rc.elv):
|
||||||
|
#
|
||||||
|
# eval $(zoxide init elvish | slurp)
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{%- let SECTION = "# =============================================================================\n#" -%}
|
{%- let section = "# =============================================================================\n#" -%}
|
||||||
{%- let NOT_CONFIGURED = "# -- not configured --" -%}
|
{%- let not_configured = "# -- not configured --" -%}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Utility functions for zoxide.
|
# Utility functions for zoxide.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -25,7 +25,7 @@ function __zoxide_cd
|
||||||
and builtin commandline -f repaint
|
and builtin commandline -f repaint
|
||||||
end
|
end
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Hook configuration for zoxide.
|
# Hook configuration for zoxide.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ if test "$__zoxide_hooked" != 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# When using zoxide with --no-aliases, alias these internal functions as
|
# When using zoxide with --no-aliases, alias these internal functions as
|
||||||
# desired.
|
# desired.
|
||||||
#
|
#
|
||||||
|
|
@ -74,7 +74,7 @@ function __zoxide_zi
|
||||||
and __zoxide_cd $__zoxide_result
|
and __zoxide_cd $__zoxide_result
|
||||||
end
|
end
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -99,11 +99,11 @@ function {{cmd}}i
|
||||||
end
|
end
|
||||||
|
|
||||||
{%- when None %}
|
{%- when None %}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
|
|
||||||
{%- endmatch %}
|
{%- endmatch %}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# To initialize zoxide with fish, add the following line to your fish
|
# To initialize zoxide with fish, add the following line to your fish
|
||||||
# configuration file (usually ~/.config/fish/config.fish):
|
# configuration file (usually ~/.config/fish/config.fish):
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{%- let SECTION = "# =============================================================================\n#" -%}
|
{%- let section = "# =============================================================================\n#" -%}
|
||||||
{%- let NOT_CONFIGURED = "# -- not configured --" -%}
|
{%- let not_configured = "# -- not configured --" -%}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Hook configuration for zoxide.
|
# Hook configuration for zoxide.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@ printf "zoxide: PWD hooks are not supported on Nushell.\n Use 'zoxide ini
|
||||||
|
|
||||||
{%- endmatch %}
|
{%- endmatch %}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# When using zoxide with --no-aliases, alias these internal functions as
|
# When using zoxide with --no-aliases, alias these internal functions as
|
||||||
# desired.
|
# desired.
|
||||||
#
|
#
|
||||||
|
|
@ -62,7 +62,7 @@ def __zoxide_zi [...rest:string] {
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -73,11 +73,11 @@ alias {{cmd}} = __zoxide_z ''
|
||||||
alias {{cmd}}i = __zoxide_zi ''
|
alias {{cmd}}i = __zoxide_zi ''
|
||||||
|
|
||||||
{%- when None %}
|
{%- when None %}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
|
|
||||||
{%- endmatch %}
|
{%- endmatch %}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# To initialize zoxide with Nushell:
|
# To initialize zoxide with Nushell:
|
||||||
#
|
#
|
||||||
# Initialize zoxide's Nushell script:
|
# Initialize zoxide's Nushell script:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{%- let SECTION = "# =============================================================================\n#" -%}
|
{%- let section = "# =============================================================================\n#" -%}
|
||||||
{%- let NOT_CONFIGURED = "# -- not configured --" -%}
|
{%- let not_configured = "# -- not configured --" -%}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Utility functions for zoxide.
|
# Utility functions for zoxide.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -20,14 +20,14 @@ __zoxide_cd() {
|
||||||
\cd "$@" {%- if echo %} && __zoxide_pwd {%- endif %}
|
\cd "$@" {%- if echo %} && __zoxide_pwd {%- endif %}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Hook configuration for zoxide.
|
# Hook configuration for zoxide.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Hook to add new entries to the database.
|
# Hook to add new entries to the database.
|
||||||
{%- match hook %}
|
{%- match hook %}
|
||||||
{%- when Hook::None %}
|
{%- when Hook::None %}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
|
|
||||||
{%- when Hook::Prompt %}
|
{%- when Hook::Prompt %}
|
||||||
__zoxide_hook() {
|
__zoxide_hook() {
|
||||||
|
|
@ -35,7 +35,7 @@ __zoxide_hook() {
|
||||||
}
|
}
|
||||||
|
|
||||||
{%- when Hook::Pwd %}
|
{%- when Hook::Pwd %}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
|
|
||||||
{%- endmatch %}
|
{%- endmatch %}
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ if [ "${__zoxide_hooked}" != '1' ]; then
|
||||||
__zoxide_hooked='1'
|
__zoxide_hooked='1'
|
||||||
{%- match hook %}
|
{%- match hook %}
|
||||||
{%- when Hook::None %}
|
{%- when Hook::None %}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
{%- when Hook::Prompt %}
|
{%- when Hook::Prompt %}
|
||||||
PS1="${PS1}\$(__zoxide_hook)"
|
PS1="${PS1}\$(__zoxide_hook)"
|
||||||
{%- when Hook::Pwd %}
|
{%- when Hook::Pwd %}
|
||||||
|
|
@ -54,7 +54,7 @@ if [ "${__zoxide_hooked}" != '1' ]; then
|
||||||
{%- endmatch %}
|
{%- endmatch %}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# When using zoxide with --no-aliases, alias these internal functions as
|
# When using zoxide with --no-aliases, alias these internal functions as
|
||||||
# desired.
|
# desired.
|
||||||
#
|
#
|
||||||
|
|
@ -83,7 +83,7 @@ __zoxide_zi() {
|
||||||
__zoxide_result="$(zoxide query -i -- "$@")" && __zoxide_cd "${__zoxide_result}"
|
__zoxide_result="$(zoxide query -i -- "$@")" && __zoxide_cd "${__zoxide_result}"
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -109,11 +109,11 @@ __zoxide_unset '{{cmd}}i'
|
||||||
}
|
}
|
||||||
|
|
||||||
{%- when None %}
|
{%- when None %}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
|
|
||||||
{%- endmatch %}
|
{%- endmatch %}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# To initialize zoxide with your POSIX shell, add the following line to your
|
# To initialize zoxide with your POSIX shell, add the following line to your
|
||||||
# shell configuration file:
|
# shell configuration file:
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{%- let SECTION = "# =============================================================================\n#" -%}
|
{%- let section = "# =============================================================================\n#" -%}
|
||||||
{%- let NOT_CONFIGURED = "# -- not configured --" -%}
|
{%- let not_configured = "# -- not configured --" -%}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Utility functions for zoxide.
|
# Utility functions for zoxide.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -18,7 +18,7 @@ function __zoxide_cd($dir) {
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Hook configuration for zoxide.
|
# Hook configuration for zoxide.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ if ($__zoxide_hooked -ne '1') {
|
||||||
$__zoxide_hooked = '1'
|
$__zoxide_hooked = '1'
|
||||||
{%- match hook %}
|
{%- match hook %}
|
||||||
{%- when Hook::None %}
|
{%- when Hook::None %}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
{%- when Hook::Prompt %}
|
{%- when Hook::Prompt %}
|
||||||
$__zoxide_prompt_old = $function:prompt
|
$__zoxide_prompt_old = $function:prompt
|
||||||
function prompt {
|
function prompt {
|
||||||
|
|
@ -52,7 +52,7 @@ if ($__zoxide_hooked -ne '1') {
|
||||||
{%- endmatch %}
|
{%- endmatch %}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# When using zoxide with --no-aliases, alias these internal functions as
|
# When using zoxide with --no-aliases, alias these internal functions as
|
||||||
# desired.
|
# desired.
|
||||||
#
|
#
|
||||||
|
|
@ -84,7 +84,7 @@ function __zoxide_zi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -95,11 +95,11 @@ Set-Alias {{cmd}} __zoxide_z
|
||||||
Set-Alias {{cmd}}i __zoxide_zi
|
Set-Alias {{cmd}}i __zoxide_zi
|
||||||
|
|
||||||
{%- when None %}
|
{%- when None %}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
|
|
||||||
{%- endmatch %}
|
{%- endmatch %}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# To initialize zoxide with powershell, add the following line to your
|
# To initialize zoxide with powershell, add the following line to your
|
||||||
# powershell configuration file (the location is stored in $profile):
|
# powershell configuration file (the location is stored in $profile):
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{%- let SECTION = "# =============================================================================\n#" -%}
|
{%- let section = "# =============================================================================\n#" -%}
|
||||||
{%- let NOT_CONFIGURED = "# -- not configured --" -%}
|
{%- let not_configured = "# -- not configured --" -%}
|
||||||
|
|
||||||
"""Initialize zoxide on Xonsh."""
|
"""Initialize zoxide on Xonsh."""
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ from typing import AnyStr, List, Optional
|
||||||
import xonsh.dirstack # type: ignore # pylint: disable=import-error
|
import xonsh.dirstack # type: ignore # pylint: disable=import-error
|
||||||
import xonsh.environ # type: ignore # pylint: disable=import-error
|
import xonsh.environ # type: ignore # pylint: disable=import-error
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Utility functions for zoxide.
|
# Utility functions for zoxide.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ def __zoxide_errhandler(func):
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Hook configuration for zoxide.
|
# Hook configuration for zoxide.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ if globals().get("__zoxide_hooked") is not True:
|
||||||
|
|
||||||
{% match hook -%}
|
{% match hook -%}
|
||||||
{%- when Hook::None -%}
|
{%- when Hook::None -%}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
{%- when Hook::Prompt -%}
|
{%- when Hook::Prompt -%}
|
||||||
@events.on_post_prompt # type: ignore # pylint:disable=undefined-variable
|
@events.on_post_prompt # type: ignore # pylint:disable=undefined-variable
|
||||||
{%- when Hook::Pwd -%}
|
{%- when Hook::Pwd -%}
|
||||||
|
|
@ -103,7 +103,7 @@ if globals().get("__zoxide_hooked") is not True:
|
||||||
subprocess.run([zoxide, "add", "--", pwd], check=False)
|
subprocess.run([zoxide, "add", "--", pwd], check=False)
|
||||||
|
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# When using zoxide with --no-aliases, alias these internal functions as
|
# When using zoxide with --no-aliases, alias these internal functions as
|
||||||
# desired.
|
# desired.
|
||||||
#
|
#
|
||||||
|
|
@ -147,7 +147,7 @@ def __zoxide_zi(args: List[str]):
|
||||||
__zoxide_cd(__zoxide_result)
|
__zoxide_cd(__zoxide_result)
|
||||||
|
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -158,11 +158,11 @@ aliases["{{cmd}}"] = __zoxide_z
|
||||||
aliases["{{cmd}}i"] = __zoxide_zi
|
aliases["{{cmd}}i"] = __zoxide_zi
|
||||||
|
|
||||||
{%- when None %}
|
{%- when None %}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
|
|
||||||
{%- endmatch %}
|
{%- endmatch %}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# To initialize zoxide with xonsh, add the following line to your xonsh
|
# To initialize zoxide with xonsh, add the following line to your xonsh
|
||||||
# configuration file (usually ~/.xonshrc):
|
# configuration file (usually ~/.xonshrc):
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{%- let SECTION = "# =============================================================================\n#" -%}
|
{%- let section = "# =============================================================================\n#" -%}
|
||||||
{%- let NOT_CONFIGURED = "# -- not configured --" -%}
|
{%- let not_configured = "# -- not configured --" -%}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Utility functions for zoxide.
|
# Utility functions for zoxide.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@ function __zoxide_cd() {
|
||||||
\builtin cd "$@" {%- if echo %} && __zoxide_pwd {%- endif %}
|
\builtin cd "$@" {%- if echo %} && __zoxide_pwd {%- endif %}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Hook configuration for zoxide.
|
# Hook configuration for zoxide.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -34,7 +34,7 @@ if [ "${__zoxide_hooked}" != '1' ]; then
|
||||||
__zoxide_hooked='1'
|
__zoxide_hooked='1'
|
||||||
{%- match hook %}
|
{%- match hook %}
|
||||||
{%- when Hook::None %}
|
{%- when Hook::None %}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
{%- when Hook::Prompt %}
|
{%- when Hook::Prompt %}
|
||||||
precmd_functions+=(__zoxide_hook)
|
precmd_functions+=(__zoxide_hook)
|
||||||
{%- when Hook::Pwd %}
|
{%- when Hook::Pwd %}
|
||||||
|
|
@ -42,7 +42,7 @@ if [ "${__zoxide_hooked}" != '1' ]; then
|
||||||
{%- endmatch %}
|
{%- endmatch %}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# When using zoxide with --no-aliases, alias these internal functions as
|
# When using zoxide with --no-aliases, alias these internal functions as
|
||||||
# desired.
|
# desired.
|
||||||
#
|
#
|
||||||
|
|
@ -74,7 +74,7 @@ function __zoxide_zi() {
|
||||||
__zoxide_result="$(zoxide query -i -- "$@")" && __zoxide_cd "${__zoxide_result}"
|
__zoxide_result="$(zoxide query -i -- "$@")" && __zoxide_cd "${__zoxide_result}"
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
# Convenient aliases for zoxide. Disable these using --no-aliases.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -99,11 +99,11 @@ function {{cmd}}i() {
|
||||||
}
|
}
|
||||||
|
|
||||||
{%- when None %}
|
{%- when None %}
|
||||||
{{ NOT_CONFIGURED }}
|
{{ not_configured }}
|
||||||
|
|
||||||
{%- endmatch %}
|
{%- endmatch %}
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ section }}
|
||||||
# To initialize zoxide with zsh, add the following line to your zsh
|
# To initialize zoxide with zsh, add the following line to your zsh
|
||||||
# configuration file (usually ~/.zshrc):
|
# configuration file (usually ~/.zshrc):
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue