home-config/fish/functions/tide/configure/functions/_fake_tide_prompt.fish

335ac274c11c6b28bb17672629fd671c0ba423e2 · 1.8 KB · 42 lines raw

1 function _fake_tide_prompt
2 set -g add_prefix
3 _fake_tide_side=left set -f left (for item in $fake_tide_left_prompt_items
4 _fake_tide_item_$item
5 end
6 if not set -e add_prefix
7 set_color $prev_bg_color -b normal
8 echo -ns $fake_tide_left_prompt_suffix
9 end)
10
11 set -g add_prefix
12 _fake_tide_side=right set -f right (for item in $fake_tide_right_prompt_items
13 _fake_tide_item_$item
14 end
15 if not set -e add_prefix
16 set_color $prev_bg_color -b normal
17 echo -ns $fake_tide_right_prompt_suffix
18 end)
19
20 if set -q _fake_tide_prompt_and_frame_color # If prompt is two lines
21 test "$fake_tide_left_prompt_frame_enabled" = true &&
22 set left[1] "$_fake_tide_prompt_and_frame_color╭─$left[1]" &&
23 set left[2] "$_fake_tide_prompt_and_frame_color╰─$left[2]"
24 test "$fake_tide_right_prompt_frame_enabled" = true &&
25 set right[1] "$right[1]$_fake_tide_prompt_and_frame_color─╮" &&
26 set right[2] "$right[2]$_fake_tide_prompt_and_frame_color─╯"
27
28 # 5 = @PWD@ length which will be replaced
29 math $fake_columns+5-(string length --visible "$left[1]$right[1]") | read -lx dist_btwn_sides
30 echo -ns "$right[2]"\n(string replace @PWD@ (_fake_tide_pwd) "$left[1]")$_fake_tide_prompt_and_frame_color
31
32 string repeat --no-newline --max (math max 0, $dist_btwn_sides-$_tide_pwd_len) $fake_tide_prompt_icon_connection
33 echo -ns "$right[1]"\n"$left[2] "
34 else
35 math $fake_columns+5-(string length --visible "$left[1]$right[1]") -$fake_tide_prompt_min_cols | read -lx dist_btwn_sides
36 string replace @PWD@ (_fake_tide_pwd) "$right[1]" "$left[1] "
37 end
38 end
39
40 function _fake_tide_item_pwd
41 _fake_tide_print_item pwd @PWD@
42 end