Use single underscore for fish function/variables

This commit is contained in:
Kid 2021-07-25 21:00:59 +08:00 committed by GitHub
parent 712d3403ef
commit 77dce0d362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 27 deletions

View File

@ -6,7 +6,7 @@
# #
# pwd based on the value of _ZO_RESOLVE_SYMLINKS. # pwd based on the value of _ZO_RESOLVE_SYMLINKS.
function __zoxide_pwd function _zoxide_pwd
{%- if resolve_symlinks %} {%- if resolve_symlinks %}
builtin pwd -P builtin pwd -P
{%- else %} {%- else %}
@ -16,19 +16,19 @@ end
# A copy of fish's internal cd function. This makes it possible to use # A copy of fish's internal cd function. This makes it possible to use
# `alias cd=z` without causing an infinite loop. # `alias cd=z` without causing an infinite loop.
if ! builtin functions -q __zoxide_cd_internal if ! builtin functions -q _zoxide_cd_internal
if builtin functions -q cd if builtin functions -q cd
builtin functions -c cd __zoxide_cd_internal builtin functions -c cd _zoxide_cd_internal
else else
alias __zoxide_cd_internal="builtin cd" alias _zoxide_cd_internal="builtin cd"
end end
end 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
__zoxide_cd_internal $argv _zoxide_cd_internal $argv
{%- if echo %} {%- if echo %}
and __zoxide_pwd and _zoxide_pwd
{%- endif %} {%- endif %}
and builtin commandline -f repaint and builtin commandline -f repaint
end end
@ -38,18 +38,18 @@ end
# #
# Initialize hook to add new entries to the database. # Initialize hook to add new entries to the database.
if test "$__zoxide_hooked" != 1 if test "$_zoxide_hooked" != 1
set __zoxide_hooked 1 set _zoxide_hooked 1
{%- match hook %} {%- match hook %}
{%- when InitHook::None %} {%- when InitHook::None %}
function __zoxide_hook function _zoxide_hook
{%- when InitHook::Prompt %} {%- when InitHook::Prompt %}
function __zoxide_hook --on-event fish_prompt function _zoxide_hook --on-event fish_prompt
{%- when InitHook::Pwd %} {%- when InitHook::Pwd %}
function __zoxide_hook --on-variable PWD function _zoxide_hook --on-variable PWD
{%- endmatch %} {%- endmatch %}
test -z "$fish_private_mode" test -z "$fish_private_mode"
and command zoxide add -- (__zoxide_pwd) and command zoxide add -- (_zoxide_pwd)
end end
end end
@ -59,26 +59,26 @@ end
# #
# Jump to a directory using only keywords. # Jump to a directory using only keywords.
function __zoxide_z function _zoxide_z
set argc (count $argv) set argc (count $argv)
if test $argc -eq 0 if test $argc -eq 0
__zoxide_cd $HOME _zoxide_cd $HOME
else if test "$argv" = - else if test "$argv" = -
__zoxide_cd - _zoxide_cd -
else if begin else if begin
test $argc -eq 1; and test -d $argv[1] test $argc -eq 1; and test -d $argv[1]
end end
__zoxide_cd $argv[1] _zoxide_cd $argv[1]
else else
set -l __zoxide_result (command zoxide query --exclude (__zoxide_pwd) -- $argv) set -l _zoxide_result (command zoxide query --exclude (_zoxide_pwd) -- $argv)
and __zoxide_cd $__zoxide_result and _zoxide_cd $_zoxide_result
end end
end end
# Jump to a directory using interactive search. # Jump to a directory using interactive search.
function __zoxide_zi function _zoxide_zi
set -l __zoxide_result (command zoxide query -i -- $argv) set -l _zoxide_result (command zoxide query -i -- $argv)
and __zoxide_cd $__zoxide_result and _zoxide_cd $_zoxide_result
end end
{{ section }} {{ section }}
@ -89,17 +89,17 @@ end
{%- when Some with (cmd) %} {%- when Some with (cmd) %}
# Remove definitions. # Remove definitions.
function __zoxide_unset function _zoxide_unset
set --erase $argv >/dev/null 2>&1 set --erase $argv >/dev/null 2>&1
abbr --erase $argv >/dev/null 2>&1 abbr --erase $argv >/dev/null 2>&1
builtin functions --erase $argv >/dev/null 2>&1 builtin functions --erase $argv >/dev/null 2>&1
end end
__zoxide_unset {{cmd}} _zoxide_unset {{cmd}}
alias {{cmd}}="__zoxide_z" alias {{cmd}}="_zoxide_z"
__zoxide_unset {{cmd}}i _zoxide_unset {{cmd}}i
alias {{cmd}}i="__zoxide_zi" alias {{cmd}}i="_zoxide_zi"
{%- when None %} {%- when None %}