Compact math for greater speed

This commit is contained in:
Ilan Cosman 2021-09-07 20:51:16 -07:00
parent 0a93b0b8fc
commit 04b37f45a4
3 changed files with 7 additions and 7 deletions

View File

@ -1,7 +1,7 @@
function _tide_item_cmd_duration
if test $CMD_DURATION -gt $tide_cmd_duration_threshold
math --scale=$tide_cmd_duration_decimals "$CMD_DURATION/1000" % 60 | read -l seconds
math --scale=0 "$CMD_DURATION/60000" % 60 | read -l minutes
math --scale=$tide_cmd_duration_decimals "$CMD_DURATION/1000"%60 | read -l seconds
math --scale=0 "$CMD_DURATION/60000"%60 | read -l minutes
math --scale=0 "$CMD_DURATION/3600000" | read -l hours
if test $hours != 0

View File

@ -12,15 +12,15 @@ function _tide_prompt
echo $right_prompt[2]
# 5 = @PWD@ length which will be replaced
math $COLUMNS + 5 - (string length --visible "$left_prompt[1]""$right_prompt[1]") | read -lx dist_btwn_sides
math $COLUMNS+5-(string length --visible "$left_prompt[1]""$right_prompt[1]") | read -lx dist_btwn_sides
printf '%s' (string replace @PWD@ (_tide_pwd) "$left_prompt[1]") $_tide_prompt_and_frame_color
string repeat --no-newline --max (math max 0, $dist_btwn_sides - $pwd_length) $tide_prompt_icon_connection
string repeat --no-newline --max (math max 0, $dist_btwn_sides-$pwd_length) $tide_prompt_icon_connection
printf '%s' $right_prompt[1] \n $left_prompt[2]' '
else
echo $right_prompt[1]
math $COLUMNS + 5 -$tide_prompt_min_cols - (string length --visible "$left_prompt[1]""$right_prompt[1]") | read -lx dist_btwn_sides
math $COLUMNS+5-(string length --visible "$left_prompt[1]""$right_prompt[1]") -$tide_prompt_min_cols | read -lx dist_btwn_sides
string replace @PWD@ (_tide_pwd) "$left_prompt[1] "
end
end

View File

@ -22,13 +22,13 @@ function _tide_pwd
i=1 for dir_section in $split_pwd[2..-2]
string join -- / $split_pwd[..$i] | string replace '~' $HOME | read -l parent_dir # Uses i before increment
math $i + 1 | read i
math $i+1 | read i
# Returns true if any markers exist in dir_section
if test -z false (string split --max 2 " " -- "-o -e "$parent_dir/$dir_section/$tide_pwd_markers)
set split_pwd_for_output[$i] $_tide_color_anchors$dir_section$_tide_reset_to_color_dirs
else if test $pwd_length -gt $dist_btwn_sides
while set -l truncation_length (math $truncation_length + 1) &&
while set -l truncation_length (math $truncation_length +1) &&
set -l truncated (string sub --length $truncation_length -- $dir_section) &&
test $truncated != $dir_section -a (count $parent_dir/$truncated*/) -gt 1
end