Use string tests instead of numbers, slight speed improvement

This commit is contained in:
Ilan Cosman 2021-03-13 17:19:32 -08:00
parent d2e672165e
commit acf89909f6
6 changed files with 8 additions and 8 deletions

View File

@ -8,11 +8,11 @@ function _tide_item_cmd_duration
printf '%s' $tide_cmd_duration_icon' '
if test $hours -gt 0
if test $hours != 0
printf '%s' $hours'h ' $minutes'm ' $seconds's'
else if test $minutes -gt 0
else if test $minutes != 0
printf '%s' $minutes'm ' $seconds's'
else if test $seconds -gt 0
else if test $seconds != 0
printf '%s' $seconds's'
end
end

View File

@ -1,5 +1,5 @@
function _tide_item_jobs
if test $_tide_jobs_number -gt 0
if test $_tide_jobs_number != 0
set_color $tide_jobs_color
if test "$tide_jobs_verbose" = true

View File

@ -1,5 +1,5 @@
function _tide_item_prompt_char
if test $_tide_last_pipestatus[-1] -eq 0
if test $_tide_last_pipestatus[-1] = 0
set_color $tide_prompt_char_success_color
else
set_color $tide_prompt_char_failure_color

View File

@ -24,7 +24,7 @@ function _tide_item_pwd
set splitPwdForOutput[$i] $colorAnchors$splitPwd[$i]$keepBackgroundColor$colorDirs
else if test (string join -- '/' $splitPwdForLength | string length) -gt $pwdMaxLength
while set -l truncationLength (math $truncationLength + 1) &&
test $truncationLength -lt (string length -- $splitPwdForLength[$i]) &&
test $truncationLength != (string length -- $splitPwdForLength[$i]) &&
set -l truncated (string sub --length $truncationLength -- $splitPwd[$i]) &&
test (count $parentDir/$truncated*/) -gt 1
end

View File

@ -7,7 +7,7 @@ function _tide_item_status
printf '%s' $tide_status_failure_icon' ' 1
end
else
if test $_tide_last_pipestatus[-1] -eq 0
if test $_tide_last_pipestatus[-1] = 0
set -g tide_status_bg_color $tide_status_success_bg_color
set_color $tide_status_success_color
printf '%s' $tide_status_success_icon' '

View File

@ -8,7 +8,7 @@ function _tide_prompt
set -l leftPromptHeight (count $leftPrompt)
set -l rightPrompt (_tide_right_prompt)
if test $leftPromptHeight -gt 1
if test $leftPromptHeight = 2
if test "$tide_left_prompt_frame_enabled" = true
set -l frameColor (set_color $tide_left_prompt_frame_color -b normal || echo)
set leftPrompt[1] $frameColor╭─"$leftPrompt[1]"