summaryrefslogtreecommitdiff
path: root/.config/fish/functions/tide/configure/functions/_fake_tide_prompt.fish
blob: 11f20caa741efd6e3a83f84493f9c5fb8136aab0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function _fake_tide_prompt
    set -g add_prefix
    _fake_tide_side=left set -f left (for item in $fake_tide_left_prompt_items
            _fake_tide_item_$item
        end
        if not set -e add_prefix
            set_color $prev_bg_color -b normal
            echo -ns $fake_tide_left_prompt_suffix
        end)

    set -g add_prefix
    _fake_tide_side=right set -f right (for item in $fake_tide_right_prompt_items
            _fake_tide_item_$item
        end
        if not set -e add_prefix
            set_color $prev_bg_color -b normal
            echo -ns $fake_tide_right_prompt_suffix
        end)

    if set -q _fake_tide_prompt_and_frame_color # If prompt is two lines
        test "$fake_tide_left_prompt_frame_enabled" = true &&
            set left[1] "$_fake_tide_prompt_and_frame_color╭─$left[1]" &&
            set left[2] "$_fake_tide_prompt_and_frame_color╰─$left[2]"
        test "$fake_tide_right_prompt_frame_enabled" = true &&
            set right[1] "$right[1]$_fake_tide_prompt_and_frame_color─╮" &&
            set right[2] "$right[2]$_fake_tide_prompt_and_frame_color─╯"

        # 5 = @PWD@ length which will be replaced
        math $fake_columns+5-(string length --visible "$left[1]$right[1]") | read -lx dist_btwn_sides
        echo -ns "$right[2]"\n(string replace @PWD@ (_fake_tide_pwd) "$left[1]")$_fake_tide_prompt_and_frame_color

        string repeat --no-newline --max (math max 0, $dist_btwn_sides-$_tide_pwd_len) $fake_tide_prompt_icon_connection
        echo -ns "$right[1]"\n"$left[2] "
    else
        math $fake_columns+5-(string length --visible "$left[1]$right[1]") -$fake_tide_prompt_min_cols | read -lx dist_btwn_sides
        string replace @PWD@ (_fake_tide_pwd) "$right[1]" "$left[1] "
    end
end

function _fake_tide_item_pwd
    _fake_tide_print_item pwd @PWD@
end