Rename variables

This commit is contained in:
Ilan Cosman 2021-10-01 10:52:44 -07:00
parent 9f11d9fa6b
commit 0376903ca6
4 changed files with 26 additions and 26 deletions

View File

@ -1,5 +1,5 @@
function _tide_item_newline
set_color $_tide_previous_bg_color -b normal
set_color $prev_bg_color -b normal
var=tide_"$_tide_side"_prompt_suffix echo $$var
set -g _tide_last_item_was_newline
set -g prev_item_was_newline
end

View File

@ -1,17 +1,17 @@
function _tide_print_item -a item
var=tide_"$item"_bg_color set -f item_bg_color $$var
if set -e _tide_last_item_was_newline
if set -e prev_item_was_newline
set_color $item_bg_color -b normal
var=tide_"$_tide_side"_prompt_prefix echo -ns $$var
else if test "$item_bg_color" = "$_tide_previous_bg_color"
else if test "$item_bg_color" = "$prev_bg_color"
set_color $tide_prompt_color_separator_same_color
var=tide_"$_tide_side"_prompt_separator_same_color echo -ns $$var
else if test "$_tide_side" = left
set_color $_tide_previous_bg_color -b $item_bg_color
set_color $prev_bg_color -b $item_bg_color
echo -ns $tide_left_prompt_separator_diff_color
else
set_color $item_bg_color -b $_tide_previous_bg_color
set_color $item_bg_color -b $prev_bg_color
echo -ns $tide_right_prompt_separator_diff_color
end
@ -19,5 +19,5 @@ function _tide_print_item -a item
echo -ns $_tide_pad $argv[2..] $_tide_pad
set -g _tide_previous_bg_color $item_bg_color
set -g prev_bg_color $item_bg_color
end

View File

@ -1,41 +1,41 @@
function _tide_prompt
set -g _tide_last_item_was_newline
_tide_side=left set -f left_prompt (for item in $tide_left_prompt_items
set -g prev_item_was_newline
_tide_side=left set -f left (for item in $tide_left_prompt_items
_tide_item_$item
end
if not set -e _tide_last_item_was_newline
set_color $_tide_previous_bg_color -b normal
if not set -e prev_item_was_newline
set_color $prev_bg_color -b normal
echo -ns $tide_left_prompt_suffix
end)
set -g _tide_last_item_was_newline
_tide_side=right set -f right_prompt (for item in $tide_right_prompt_items
set -g prev_item_was_newline
_tide_side=right set -f right (for item in $tide_right_prompt_items
_tide_item_$item
end
if not set -e _tide_last_item_was_newline
set_color $_tide_previous_bg_color -b normal
if not set -e prev_item_was_newline
set_color $prev_bg_color -b normal
echo -ns $tide_right_prompt_suffix
end)
if set -q _tide_prompt_and_frame_color # If prompt is two lines
if test "$tide_left_prompt_frame_enabled" = true
set left_prompt[1] "$_tide_prompt_and_frame_color╭─$left_prompt[1]"
set left_prompt[2] "$_tide_prompt_and_frame_color╰─$left_prompt[2]"
set left[1] "$_tide_prompt_and_frame_color╭─$left[1]"
set left[2] "$_tide_prompt_and_frame_color╰─$left[2]"
end
if test "$tide_right_prompt_frame_enabled" = true
set right_prompt[1] "$right_prompt[1]$_tide_prompt_and_frame_color─╮"
set right_prompt[2] "$right_prompt[2]$_tide_prompt_and_frame_color─╯"
set right[1] "$right[1]$_tide_prompt_and_frame_color─╮"
set right[2] "$right[2]$_tide_prompt_and_frame_color─╯"
end
# 5 = @PWD@ length which will be replaced
math $COLUMNS+5-(string length --visible "$left_prompt[1]$right_prompt[1]") | read -lx dist_btwn_sides
echo -ns "$right_prompt[2]"\n(string replace @PWD@ (_tide_pwd) "$left_prompt[1]")$_tide_prompt_and_frame_color
math $COLUMNS+5-(string length --visible "$left[1]$right[1]") | read -lx dist_btwn_sides
echo -ns "$right[2]"\n(string replace @PWD@ (_tide_pwd) "$left[1]")$_tide_prompt_and_frame_color
string repeat --no-newline --max (math max 0, $dist_btwn_sides-$pwd_length) $tide_prompt_icon_connection
echo -ns "$right_prompt[1]"\n"$left_prompt[2] "
echo -ns "$right[1]"\n"$left[2] "
else
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) "$right_prompt[1]" "$left_prompt[1] "
math $COLUMNS+5-(string length --visible "$left[1]$right[1]") -$tide_prompt_min_cols | read -lx dist_btwn_sides
string replace @PWD@ (_tide_pwd) "$right[1]" "$left[1] "
end
end

View File

@ -12,12 +12,12 @@ set -g _tide_prompt_var _tide_prompt_$fish_pid
set -U $_tide_prompt_var # So that if we erase $_tide_prompt_var, the bg job can't set a uvar
function _tide_refresh_prompt --on-variable $_tide_prompt_var
set -g _tide_self_repainting # prevents us from creating a second background job
set -g _tide_repaint # prevents us from creating a second background job
commandline --function repaint
end
function fish_prompt
_tide_status=$status _tide_pipestatus=$pipestatus if not set -e _tide_self_repainting
_tide_status=$status _tide_pipestatus=$pipestatus if not set -e _tide_repaint
jobs --query
fish --command "set _tide_pipestatus $_tide_pipestatus
_tide_jobs_status=$status CMD_DURATION=$CMD_DURATION COLUMNS=$COLUMNS \