Small nits
This commit is contained in:
parent
b1f7f7d839
commit
5c5f731c32
|
|
@ -5,19 +5,11 @@
|
||||||
# Utility functions for zoxide.
|
# Utility functions for zoxide.
|
||||||
#
|
#
|
||||||
|
|
||||||
# provide a custom __fish_cd function that is either a copy of the default fish
|
# Remove definitions.
|
||||||
# cd wrapper function, or an alias for the `builtin cd` to prevent recursively
|
function __zoxide_unset
|
||||||
# calling cd when using `alias cd=z`.
|
set --erase $argv >/dev/null 2>&1
|
||||||
#
|
abbr --erase $argv >/dev/null 2>&1
|
||||||
# only create the function `__fish_cd` if it doesn't yet exist
|
builtin functions --erase $argv >/dev/null 2>&1
|
||||||
if ! functions -q __fish_cd
|
|
||||||
if functions -q cd
|
|
||||||
# use the fish wrapper function for __fish_cd if it exists
|
|
||||||
functions -c cd __fish_cd
|
|
||||||
else
|
|
||||||
# use `builtin cd` as fallback if the cd wrapper function does not exist
|
|
||||||
alias __fish_cd="builtin cd"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# pwd based on the value of _ZO_RESOLVE_SYMLINKS.
|
# pwd based on the value of _ZO_RESOLVE_SYMLINKS.
|
||||||
|
|
@ -29,13 +21,18 @@ function __zoxide_pwd
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# A copy of fish's internal cd function. This makes it possible to use
|
||||||
|
# `alias cd=z` without causing an infinite loop.
|
||||||
|
__zoxide_unset __zoxide_cd_internal
|
||||||
|
if builtin functions -q cd
|
||||||
|
builtin functions -c cd __zoxide_cd_internal
|
||||||
|
else
|
||||||
|
alias __zoxide_cd_internal="builtin cd"
|
||||||
|
end
|
||||||
|
|
||||||
# cd + custom logic based on the value of _ZO_ECHO.
|
# cd + custom logic based on the value of _ZO_ECHO.
|
||||||
function __zoxide_cd
|
function __zoxide_cd
|
||||||
{#- We can't use `builtin cd` over here, because fish wraps its builtin cd with
|
__zoxide_cd_internal $argv
|
||||||
a function that adds extra features (such as `cd -`). Using the builtin
|
|
||||||
would make those features stop working. Instead use a custom function that is
|
|
||||||
either a copy of the cd function or an alias for `builtin cd` as fallback #}
|
|
||||||
__fish_cd $argv
|
|
||||||
{%- if echo %}
|
{%- if echo %}
|
||||||
and __zoxide_pwd
|
and __zoxide_pwd
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
@ -96,22 +93,11 @@ end
|
||||||
{%- match cmd %}
|
{%- match cmd %}
|
||||||
{%- when Some with (cmd) %}
|
{%- when Some with (cmd) %}
|
||||||
|
|
||||||
# Remove definitions.
|
|
||||||
function __zoxide_unset
|
|
||||||
set --erase $argv >/dev/null 2>&1
|
|
||||||
abbr --erase $argv >/dev/null 2>&1
|
|
||||||
builtin functions --erase $argv >/dev/null 2>&1
|
|
||||||
end
|
|
||||||
|
|
||||||
__zoxide_unset {{cmd}}
|
__zoxide_unset {{cmd}}
|
||||||
function {{cmd}}
|
alias {{cmd}}="__zoxide_z"
|
||||||
__zoxide_z $argv
|
|
||||||
end
|
|
||||||
|
|
||||||
__zoxide_unset {{cmd}}i
|
__zoxide_unset {{cmd}}i
|
||||||
function {{cmd}}i
|
alias {{cmd}}i="__zoxide_zi"
|
||||||
__zoxide_zi $argv
|
|
||||||
end
|
|
||||||
|
|
||||||
{%- when None %}
|
{%- when None %}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue