From 77dce0d36252813322e047e5b94a4268d850b825 Mon Sep 17 00:00:00 2001 From: Kid <44045911+kidonng@users.noreply.github.com> Date: Sun, 25 Jul 2021 21:00:59 +0800 Subject: [PATCH] Use single underscore for fish function/variables --- templates/fish.txt | 54 +++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/templates/fish.txt b/templates/fish.txt index 6cae56a..27a9c4e 100644 --- a/templates/fish.txt +++ b/templates/fish.txt @@ -6,7 +6,7 @@ # # pwd based on the value of _ZO_RESOLVE_SYMLINKS. -function __zoxide_pwd +function _zoxide_pwd {%- if resolve_symlinks %} builtin pwd -P {%- else %} @@ -16,19 +16,19 @@ end # A copy of fish's internal cd function. This makes it possible to use # `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 - builtin functions -c cd __zoxide_cd_internal + builtin functions -c cd _zoxide_cd_internal else - alias __zoxide_cd_internal="builtin cd" + alias _zoxide_cd_internal="builtin cd" end end # cd + custom logic based on the value of _ZO_ECHO. -function __zoxide_cd - __zoxide_cd_internal $argv +function _zoxide_cd + _zoxide_cd_internal $argv {%- if echo %} - and __zoxide_pwd + and _zoxide_pwd {%- endif %} and builtin commandline -f repaint end @@ -38,18 +38,18 @@ end # # Initialize hook to add new entries to the database. -if test "$__zoxide_hooked" != 1 - set __zoxide_hooked 1 +if test "$_zoxide_hooked" != 1 + set _zoxide_hooked 1 {%- match hook %} {%- when InitHook::None %} - function __zoxide_hook + function _zoxide_hook {%- when InitHook::Prompt %} - function __zoxide_hook --on-event fish_prompt + function _zoxide_hook --on-event fish_prompt {%- when InitHook::Pwd %} - function __zoxide_hook --on-variable PWD + function _zoxide_hook --on-variable PWD {%- endmatch %} test -z "$fish_private_mode" - and command zoxide add -- (__zoxide_pwd) + and command zoxide add -- (_zoxide_pwd) end end @@ -59,26 +59,26 @@ end # # Jump to a directory using only keywords. -function __zoxide_z +function _zoxide_z set argc (count $argv) if test $argc -eq 0 - __zoxide_cd $HOME + _zoxide_cd $HOME else if test "$argv" = - - __zoxide_cd - + _zoxide_cd - else if begin test $argc -eq 1; and test -d $argv[1] end - __zoxide_cd $argv[1] + _zoxide_cd $argv[1] else - set -l __zoxide_result (command zoxide query --exclude (__zoxide_pwd) -- $argv) - and __zoxide_cd $__zoxide_result + set -l _zoxide_result (command zoxide query --exclude (_zoxide_pwd) -- $argv) + and _zoxide_cd $_zoxide_result end end # Jump to a directory using interactive search. -function __zoxide_zi - set -l __zoxide_result (command zoxide query -i -- $argv) - and __zoxide_cd $__zoxide_result +function _zoxide_zi + set -l _zoxide_result (command zoxide query -i -- $argv) + and _zoxide_cd $_zoxide_result end {{ section }} @@ -89,17 +89,17 @@ end {%- when Some with (cmd) %} # Remove definitions. -function __zoxide_unset +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}} -alias {{cmd}}="__zoxide_z" +_zoxide_unset {{cmd}} +alias {{cmd}}="_zoxide_z" -__zoxide_unset {{cmd}}i -alias {{cmd}}i="__zoxide_zi" +_zoxide_unset {{cmd}}i +alias {{cmd}}i="_zoxide_zi" {%- when None %}