From 78110a8cfb98c4e95111ded29d04bdd0fa566a4f Mon Sep 17 00:00:00 2001 From: Ilan Cosman Date: Wed, 20 May 2020 10:05:33 -0700 Subject: [PATCH] Rename functions --- ...pt_height.fish => _tide_count_left_prompt_height.fish} | 2 +- ...de_cursor_movement.fish => _tide_cursor_movement.fish} | 0 functions/{tide_decolor.fish => _tide_decolor.fish} | 2 +- ...ide_cmd_duration.fish => _tide_item_cmd_duration.fish} | 2 +- functions/{_tide_context.fish => _tide_item_context.fish} | 2 +- .../{_tide_git_prompt.fish => _tide_item_git_prompt.fish} | 2 +- functions/{_tide_jobs.fish => _tide_item_jobs.fish} | 2 +- functions/_tide_item_newline.fish | 3 +++ ..._tide_prompt_char.fish => _tide_item_prompt_char.fish} | 2 +- functions/{_tide_pwd.fish => _tide_item_pwd.fish} | 2 +- functions/{_tide_status.fish => _tide_item_status.fish} | 2 +- functions/{_tide_time.fish => _tide_item_time.fish} | 2 +- functions/_tide_left_prompt.fish | 8 ++++++++ functions/_tide_newline.fish | 3 --- .../{tide_right_prompt.fish => _tide_right_prompt.fish} | 8 ++++---- functions/fish_prompt.fish | 4 ++-- functions/tide_left_prompt.fish | 8 -------- install.fish | 4 ++-- tests/cmd_duration.fish | 2 +- tests/context.fish | 4 ++-- tests/jobs.fish | 2 +- tests/pwd.fish | 2 +- tests/status.fish | 2 +- .../configure/functions/fake_lean_right_prompt.fish | 2 +- tide_theme/functions/configure.fish | 4 ++-- 25 files changed, 38 insertions(+), 38 deletions(-) rename conf.d/{tide_count_left_prompt_height.fish => _tide_count_left_prompt_height.fish} (66%) rename conf.d/{tide_cursor_movement.fish => _tide_cursor_movement.fish} (100%) rename functions/{tide_decolor.fish => _tide_decolor.fish} (82%) rename functions/{_tide_cmd_duration.fish => _tide_item_cmd_duration.fish} (94%) rename functions/{_tide_context.fish => _tide_item_context.fish} (89%) rename functions/{_tide_git_prompt.fish => _tide_item_git_prompt.fish} (87%) rename functions/{_tide_jobs.fish => _tide_item_jobs.fish} (79%) create mode 100644 functions/_tide_item_newline.fish rename functions/{_tide_prompt_char.fish => _tide_item_prompt_char.fish} (85%) rename functions/{_tide_pwd.fish => _tide_item_pwd.fish} (98%) rename functions/{_tide_status.fish => _tide_item_status.fish} (96%) rename functions/{_tide_time.fish => _tide_item_time.fish} (75%) create mode 100644 functions/_tide_left_prompt.fish delete mode 100644 functions/_tide_newline.fish rename functions/{tide_right_prompt.fish => _tide_right_prompt.fish} (81%) delete mode 100644 functions/tide_left_prompt.fish diff --git a/conf.d/tide_count_left_prompt_height.fish b/conf.d/_tide_count_left_prompt_height.fish similarity index 66% rename from conf.d/tide_count_left_prompt_height.fish rename to conf.d/_tide_count_left_prompt_height.fish index 5a3f832..e5348bb 100644 --- a/conf.d/tide_count_left_prompt_height.fish +++ b/conf.d/_tide_count_left_prompt_height.fish @@ -1,4 +1,4 @@ -function tide_count_left_prompt_height --on-variable tide_left_prompt_items +function _tide_count_left_prompt_height --on-variable tide_left_prompt_items set -l numberOfNewlines (count (string match -a 'newline' $tide_left_prompt_items)) set -U tide_left_prompt_height (math 1+$numberOfNewlines) end \ No newline at end of file diff --git a/conf.d/tide_cursor_movement.fish b/conf.d/_tide_cursor_movement.fish similarity index 100% rename from conf.d/tide_cursor_movement.fish rename to conf.d/_tide_cursor_movement.fish diff --git a/functions/tide_decolor.fish b/functions/_tide_decolor.fish similarity index 82% rename from functions/tide_decolor.fish rename to functions/_tide_decolor.fish index bfddd6b..83a0431 100644 --- a/functions/tide_decolor.fish +++ b/functions/_tide_decolor.fish @@ -1,4 +1,4 @@ -function tide_decolor -a text +function _tide_decolor -a text set text (string replace -a (set_color normal) '' "$text") set text (string replace -ar '\e\[[0-9;]*m' '' "$text") diff --git a/functions/_tide_cmd_duration.fish b/functions/_tide_item_cmd_duration.fish similarity index 94% rename from functions/_tide_cmd_duration.fish rename to functions/_tide_item_cmd_duration.fish index 9c60671..a27c53e 100644 --- a/functions/_tide_cmd_duration.fish +++ b/functions/_tide_item_cmd_duration.fish @@ -1,4 +1,4 @@ -function _tide_cmd_duration +function _tide_item_cmd_duration if test $CMD_DURATION -gt $tide_cmd_duration_threshold set -l seconds (math --scale=$tide_cmd_duration_decimals "$CMD_DURATION/1000" % 60) set -l minutes (math -s0 "$CMD_DURATION/60000" % 60) diff --git a/functions/_tide_context.fish b/functions/_tide_item_context.fish similarity index 89% rename from functions/_tide_context.fish rename to functions/_tide_item_context.fish index 016c4ae..21139e5 100644 --- a/functions/_tide_context.fish +++ b/functions/_tide_item_context.fish @@ -1,4 +1,4 @@ -function _tide_context +function _tide_item_context if set -q SSH_TTY set_color $tide_context_ssh_color printf '%s ' $USER'@'(prompt_hostname) diff --git a/functions/_tide_git_prompt.fish b/functions/_tide_item_git_prompt.fish similarity index 87% rename from functions/_tide_git_prompt.fish rename to functions/_tide_item_git_prompt.fish index a0c7a94..7de33f0 100644 --- a/functions/_tide_git_prompt.fish +++ b/functions/_tide_item_git_prompt.fish @@ -1,4 +1,4 @@ -function _tide_git_prompt +function _tide_item_git_prompt if set -l gitPrompt (fish_git_prompt) set -l gitPrompt (string replace '(' '' $gitPrompt) diff --git a/functions/_tide_jobs.fish b/functions/_tide_item_jobs.fish similarity index 79% rename from functions/_tide_jobs.fish rename to functions/_tide_item_jobs.fish index f45e42f..bba809c 100644 --- a/functions/_tide_jobs.fish +++ b/functions/_tide_item_jobs.fish @@ -1,4 +1,4 @@ -function _tide_jobs +function _tide_item_jobs if jobs -q set_color $tide_jobs_color printf '%s ' $tide_jobs_icon diff --git a/functions/_tide_item_newline.fish b/functions/_tide_item_newline.fish new file mode 100644 index 0000000..45d1c75 --- /dev/null +++ b/functions/_tide_item_newline.fish @@ -0,0 +1,3 @@ +function _tide_item_newline + printf '%s' '\n' +end \ No newline at end of file diff --git a/functions/_tide_prompt_char.fish b/functions/_tide_item_prompt_char.fish similarity index 85% rename from functions/_tide_prompt_char.fish rename to functions/_tide_item_prompt_char.fish index ca7c412..182633d 100644 --- a/functions/_tide_prompt_char.fish +++ b/functions/_tide_item_prompt_char.fish @@ -1,4 +1,4 @@ -function _tide_prompt_char +function _tide_item_prompt_char if test $last_status -eq 0 set_color $tide_prompt_char_success_color else diff --git a/functions/_tide_pwd.fish b/functions/_tide_item_pwd.fish similarity index 98% rename from functions/_tide_pwd.fish rename to functions/_tide_item_pwd.fish index 6674944..4681fb1 100644 --- a/functions/_tide_pwd.fish +++ b/functions/_tide_item_pwd.fish @@ -1,4 +1,4 @@ -function _tide_pwd +function _tide_item_pwd set -l splitPwd (string split --no-empty '/' (_truncate_pwd)) set -l splitPwdLength (count $splitPwd) diff --git a/functions/_tide_status.fish b/functions/_tide_item_status.fish similarity index 96% rename from functions/_tide_status.fish rename to functions/_tide_item_status.fish index 96c2808..68d2276 100644 --- a/functions/_tide_status.fish +++ b/functions/_tide_item_status.fish @@ -1,4 +1,4 @@ -function _tide_status +function _tide_item_status if string match -q --invert '0' $last_pipestatus set -l fishPipestatusWithSignal (__fish_pipestatus_with_signal $last_pipestatus) diff --git a/functions/_tide_time.fish b/functions/_tide_item_time.fish similarity index 75% rename from functions/_tide_time.fish rename to functions/_tide_item_time.fish index 9ac8916..9520e58 100644 --- a/functions/_tide_time.fish +++ b/functions/_tide_item_time.fish @@ -1,4 +1,4 @@ -function _tide_time +function _tide_item_time set_color $tide_time_color printf '%s ' (date +$tide_time_format) end \ No newline at end of file diff --git a/functions/_tide_left_prompt.fish b/functions/_tide_left_prompt.fish new file mode 100644 index 0000000..61b3ba1 --- /dev/null +++ b/functions/_tide_left_prompt.fish @@ -0,0 +1,8 @@ +function _tide_left_prompt + for item in _tide_item_{$tide_left_prompt_items} + set -l itemOutput ($item) + printf '%b' "$itemOutput" + + set_color normal + end +end \ No newline at end of file diff --git a/functions/_tide_newline.fish b/functions/_tide_newline.fish deleted file mode 100644 index 12c3fde..0000000 --- a/functions/_tide_newline.fish +++ /dev/null @@ -1,3 +0,0 @@ -function _tide_newline - printf '%s' '\n' -end \ No newline at end of file diff --git a/functions/tide_right_prompt.fish b/functions/_tide_right_prompt.fish similarity index 81% rename from functions/tide_right_prompt.fish rename to functions/_tide_right_prompt.fish index 1d01604..30a14d6 100644 --- a/functions/tide_right_prompt.fish +++ b/functions/_tide_right_prompt.fish @@ -1,4 +1,4 @@ -function tide_right_prompt +function _tide_right_prompt set -l splitText (string split '\n' (_fetch_right_prompt_items)) set -l printAtEndedRightPromptHeight (count $splitText) @@ -23,8 +23,8 @@ end function _fetch_right_prompt_items printf '%s' ' ' - for item in tide_{$tide_right_prompt_items} - set -l itemOutput (_$item) + for item in _tide_item_{$tide_right_prompt_items} + set -l itemOutput ($item) printf '%s' "$itemOutput" set_color normal @@ -32,7 +32,7 @@ function _fetch_right_prompt_items end function _print_at_end -a text - set -l startLocation (math $COLUMNS -(string length (tide_decolor $text))) + set -l startLocation (math $COLUMNS -(string length (_tide_decolor $text))) _cursor_right $startLocation printf '%s' $text diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 96a087c..101d990 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -12,8 +12,8 @@ function fish_prompt --description 'Write out the prompt' set_color $fish_color_normal printf '%b' '\r' - tide_right_prompt + _tide_right_prompt printf '%b' '\r' - tide_left_prompt + _tide_left_prompt end diff --git a/functions/tide_left_prompt.fish b/functions/tide_left_prompt.fish deleted file mode 100644 index 774885f..0000000 --- a/functions/tide_left_prompt.fish +++ /dev/null @@ -1,8 +0,0 @@ -function tide_left_prompt - for item in tide_{$tide_left_prompt_items} - set -l itemOutput (_$item) - printf '%b' "$itemOutput" - - set_color normal - end -end \ No newline at end of file diff --git a/install.fish b/install.fish index d295671..5c4cbba 100644 --- a/install.fish +++ b/install.fish @@ -118,8 +118,8 @@ function _set -a var_name end function _source_tide_functions - source "$__fish_config_dir/conf.d/tide_count_left_prompt_height.fish" - source "$__fish_config_dir/conf.d/tide_cursor_movement.fish" + source "$__fish_config_dir/conf.d/_tide_count_left_prompt_height.fish" + source "$__fish_config_dir/conf.d/_tide_cursor_movement.fish" source "$__fish_config_dir/functions/fish_prompt.fish" end diff --git a/tests/cmd_duration.fish b/tests/cmd_duration.fish index acc354a..597cd6a 100644 --- a/tests/cmd_duration.fish +++ b/tests/cmd_duration.fish @@ -5,7 +5,7 @@ function _cmd_duration -a duration threshold decimals set -g tide_cmd_duration_threshold $threshold set -g tide_cmd_duration_decimals $decimals - tide_decolor (_tide_cmd_duration) + _tide_decolor (_tide_cmd_duration) end @test 'Less than threshold' (_cmd_duration 2000 3000 0) -z diff --git a/tests/context.fish b/tests/context.fish index be7adf8..46064cd 100644 --- a/tests/context.fish +++ b/tests/context.fish @@ -3,9 +3,9 @@ set -l sourceFile "$__fish_config_dir/functions/_tide_context.fish" function _context - tide_decolor (_tide_context) + _tide_decolor (_tide_context) end @test 'None' (_context) -z @test 'SSH' (set -g SSH_TTY 'true'; _context) = $USER'@'(prompt_hostname)' ' -@test 'Root' (tide_decolor (su -c "fish -c 'source $sourceFile;_tide_context'")) = 'root@'(prompt_hostname)' ' \ No newline at end of file +@test 'Root' (_tide_decolor (su -c "fish -c 'source $sourceFile;_tide_context'")) = 'root@'(prompt_hostname)' ' \ No newline at end of file diff --git a/tests/jobs.fish b/tests/jobs.fish index bccac93..b2437da 100644 --- a/tests/jobs.fish +++ b/tests/jobs.fish @@ -1,7 +1,7 @@ @mesg '-------------jobs-------------' function _jobs - tide_decolor (_tide_jobs) + _tide_decolor (_tide_jobs) end @test 'No Jobs' (_jobs) -z diff --git a/tests/pwd.fish b/tests/pwd.fish index a9bdad0..f30229f 100644 --- a/tests/pwd.fish +++ b/tests/pwd.fish @@ -2,7 +2,7 @@ function _pwd -a dir cd $dir - tide_decolor (_tide_pwd) + _tide_decolor (_tide_pwd) end set -l unwr "$tide_pwd_unwritable_icon " diff --git a/tests/status.fish b/tests/status.fish index f60f98a..5a110c6 100644 --- a/tests/status.fish +++ b/tests/status.fish @@ -3,7 +3,7 @@ function _status set -g last_pipestatus $pipestatus set -g last_status $status - tide_decolor (_tide_status) + _tide_decolor (_tide_status) end @test 'true' (true; _status) -z diff --git a/tide_theme/configure/functions/fake_lean_right_prompt.fish b/tide_theme/configure/functions/fake_lean_right_prompt.fish index 34b4c3a..f3adff5 100644 --- a/tide_theme/configure/functions/fake_lean_right_prompt.fish +++ b/tide_theme/configure/functions/fake_lean_right_prompt.fish @@ -21,7 +21,7 @@ function _fetch_right_prompt_items end function _print_at_end -a text - set -l startLocation (math $fake_columns -(string length (tide_decolor $text))) + set -l startLocation (math $fake_columns -(string length (_tide_decolor $text))) _cursor_right $startLocation printf '%s' $text diff --git a/tide_theme/functions/configure.fish b/tide_theme/functions/configure.fish index 2e24d5f..a76ec03 100644 --- a/tide_theme/functions/configure.fish +++ b/tide_theme/functions/configure.fish @@ -93,7 +93,7 @@ end function _quit --on-signal INT source "$__fish_config_dir/functions/fish_prompt.fish" - source "$__fish_config_dir/functions/tide_left_prompt.fish" - source "$__fish_config_dir/functions/tide_right_prompt.fish" + source "$__fish_config_dir/functions/_tide_left_prompt.fish" + source "$__fish_config_dir/functions/_tide_right_prompt.fish" clear end \ No newline at end of file