mirror of
https://github.com/Llewellynvdm/zoxide.git
synced 2025-02-03 03:58:25 +00:00
Define completions on __zoxide_z
This commit is contained in:
parent
2555870c31
commit
86741bbe6a
@ -7,6 +7,12 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Fish/Zsh: Aliases on `__zoxide_z` will now use completions.
|
||||||
|
|
||||||
## [0.9.0] - 2023-01-08
|
## [0.9.0] - 2023-01-08
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -83,7 +83,7 @@ function __zoxide_z
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Completions for `z`.
|
# Completions.
|
||||||
function __zoxide_z_complete
|
function __zoxide_z_complete
|
||||||
set -l tokens (commandline --current-process --tokenize)
|
set -l tokens (commandline --current-process --tokenize)
|
||||||
set -l curr_tokens (commandline --cut-at-cursor --current-process --tokenize)
|
set -l curr_tokens (commandline --cut-at-cursor --current-process --tokenize)
|
||||||
@ -99,6 +99,7 @@ function __zoxide_z_complete
|
|||||||
commandline --function repaint
|
commandline --function repaint
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
complete --command __zoxide_z --no-files --arguments '(__zoxide_z_complete)'
|
||||||
|
|
||||||
# Jump to a directory using interactive search.
|
# Jump to a directory using interactive search.
|
||||||
function __zoxide_zi
|
function __zoxide_zi
|
||||||
@ -114,17 +115,10 @@ end
|
|||||||
{%- when Some with (cmd) %}
|
{%- when Some with (cmd) %}
|
||||||
|
|
||||||
abbr --erase {{cmd}} &>/dev/null
|
abbr --erase {{cmd}} &>/dev/null
|
||||||
complete --command {{cmd}} --erase
|
alias {{cmd}}=__zoxide_z
|
||||||
function {{cmd}}
|
|
||||||
__zoxide_z $argv
|
|
||||||
end
|
|
||||||
complete --command {{cmd}} --no-files --arguments '(__zoxide_z_complete)'
|
|
||||||
|
|
||||||
abbr --erase {{cmd}}i &>/dev/null
|
abbr --erase {{cmd}}i &>/dev/null
|
||||||
complete --command {{cmd}}i --erase
|
alias {{cmd}}i=__zoxide_zi
|
||||||
function {{cmd}}i
|
|
||||||
__zoxide_zi $argv
|
|
||||||
end
|
|
||||||
|
|
||||||
{%- when None %}
|
{%- when None %}
|
||||||
|
|
||||||
|
@ -79,23 +79,7 @@ function __zoxide_zi() {
|
|||||||
result="$(\command zoxide query -i -- "$@")" && __zoxide_cd "${result}"
|
result="$(\command zoxide query -i -- "$@")" && __zoxide_cd "${result}"
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ section }}
|
# Completions.
|
||||||
# Commands for zoxide. Disable these using --no-cmd.
|
|
||||||
#
|
|
||||||
|
|
||||||
{%- match cmd %}
|
|
||||||
{%- when Some with (cmd) %}
|
|
||||||
|
|
||||||
\builtin unalias {{cmd}} &>/dev/null || \builtin true
|
|
||||||
function {{cmd}}() {
|
|
||||||
__zoxide_z "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
\builtin unalias {{cmd}}i &>/dev/null || \builtin true
|
|
||||||
function {{cmd}}i() {
|
|
||||||
__zoxide_zi "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ -o zle ]]; then
|
if [[ -o zle ]]; then
|
||||||
function __zoxide_z_complete() {
|
function __zoxide_z_complete() {
|
||||||
# Only show completions when the cursor is at the end of the line.
|
# Only show completions when the cursor is at the end of the line.
|
||||||
@ -118,13 +102,19 @@ if [[ -o zle ]]; then
|
|||||||
}
|
}
|
||||||
|
|
||||||
\builtin bindkey '\e[0n' 'reset-prompt'
|
\builtin bindkey '\e[0n' 'reset-prompt'
|
||||||
if [[ "${+functions[compdef]}" -ne 0 ]]; then
|
[[ "${+functions[compdef]}" -ne 0 ]] && \compdef __zoxide_z_complete __zoxide_z
|
||||||
\compdef -d {{cmd}}
|
|
||||||
\compdef -d {{cmd}}i
|
|
||||||
\compdef __zoxide_z_complete {{cmd}}
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
{{ section }}
|
||||||
|
# Commands for zoxide. Disable these using --no-cmd.
|
||||||
|
#
|
||||||
|
|
||||||
|
{%- match cmd %}
|
||||||
|
{%- when Some with (cmd) %}
|
||||||
|
|
||||||
|
\builtin alias {{cmd}}=__zoxide_z
|
||||||
|
\builtin alias {{cmd}}i=__zoxide_zi
|
||||||
|
|
||||||
{%- when None %}
|
{%- when None %}
|
||||||
|
|
||||||
{{ not_configured }}
|
{{ not_configured }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user