diff --git a/templates/bash.txt b/templates/bash.txt index cb44cef..0080b2d 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -93,6 +93,12 @@ function __zoxide_zi() { result="$(\command zoxide query -i -- "$@")" && __zoxide_cd "${result}" } +# Jump to sub directories of current directory. +function __zoxide_zw() { + \builtin local result + result="$(\command zoxide query --workingdir --exclude "$(__zoxide_pwd)" -- "$@")" && __zoxide_cd "${result}" +} + {{ section }} # Commands for zoxide. Disable these using --no-cmd. # @@ -110,6 +116,11 @@ function {{cmd}}i() { __zoxide_zi "$@" } +\builtin unalias {{cmd}}w &>/dev/null || \builtin true +function {{cmd}}w() { + __zoxide_zw "$@" +} + # Load completions. # - Bash 4.4+ is required to use `@Q`. # - Completions require line editing. Since Bash supports only two modes of diff --git a/templates/fish.txt b/templates/fish.txt index 4a8a5bf..f182a7e 100644 --- a/templates/fish.txt +++ b/templates/fish.txt @@ -106,6 +106,12 @@ function __zoxide_zi and __zoxide_cd $result end +# Jump to sub directories of current directory. +function __zoxide_zw + set -l result (command zoxide query --workingdir -- $argv) + and __zoxide_cd $result +end + {{ section }} # Commands for zoxide. Disable these using --no-cmd. # @@ -126,6 +132,12 @@ function {{cmd}}i __zoxide_zi $argv end +abbr --erase {{cmd}}w &>/dev/null +complete --command {{cmd}}w --erase +function {{cmd}}w + __zoxide_zw $argv +end + {%- when None %} {{ not_configured }} diff --git a/templates/zsh.txt b/templates/zsh.txt index c850847..176b22c 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -79,6 +79,12 @@ function __zoxide_zi() { result="$(\command zoxide query -i -- "$@")" && __zoxide_cd "${result}" } +# Jump to sub directories of current directory. +function __zoxide_zw() { + \builtin local result + result="$(\command zoxide query --workingdir -- "$@")" && __zoxide_cd "${result}" +} + {{ section }} # Commands for zoxide. Disable these using --no-cmd. # @@ -96,6 +102,11 @@ function {{cmd}}i() { __zoxide_zi "$@" } +\builtin unalias {{cmd}}w &>/dev/null || \builtin true +function {{cmd}}w() { + __zoxide_zw "$@" +} + if [[ -o zle ]]; then function __zoxide_z_complete() { # Only show completions when the cursor is at the end of the line.