mirror of
https://github.com/IlanCosman/tide.git
synced 2025-01-03 10:02:22 +03:00
Don't edit tide_.*_prompt_items anymore, instead use internal vars
This commit is contained in:
parent
4945e83ecf
commit
13b6c60411
@ -1,11 +1,9 @@
|
||||
function _tide_init_install --on-event _tide_init_install
|
||||
set -U VIRTUAL_ENV_DISABLE_PROMPT true
|
||||
set -U _tide_var_list VIRTUAL_ENV_DISABLE_PROMPT
|
||||
|
||||
source (functions --details _tide_sub_configure)
|
||||
_load_config lean
|
||||
_tide_finish
|
||||
set -a _tide_var_list (set --names | string match -r "^tide.*")
|
||||
|
||||
status is-interactive && switch (read --prompt-str="Configure tide prompt? [Y/n] " | string lower)
|
||||
case y ye yes ''
|
||||
@ -32,7 +30,7 @@ function _tide_init_update --on-event _tide_init_update
|
||||
tide bug-report --verbose >$tmp
|
||||
|
||||
# Delete old vars
|
||||
set -e $_tide_var_list _tide_var_list $_tide_prompt_var
|
||||
set -e (set -U --names | string match --entire -r '^_?tide_')
|
||||
|
||||
# Print a warning
|
||||
set_color yellow
|
||||
@ -47,6 +45,7 @@ function _tide_init_update --on-event _tide_init_update
|
||||
end
|
||||
|
||||
function _tide_init_uninstall --on-event _tide_init_uninstall
|
||||
set -e $_tide_var_list _tide_var_list $_tide_prompt_var
|
||||
set -e VIRTUAL_ENV_DISABLE_PROMPT
|
||||
set -e (set -U --names | string match --entire -r '^_?tide_')
|
||||
functions --erase (functions --all | string match --entire -r '^_tide_')
|
||||
end
|
||||
|
@ -24,17 +24,17 @@ function _tide_cache_variables
|
||||
set -gx _tide_color_separator_same_color "$data[4]"
|
||||
|
||||
# git
|
||||
contains git $tide_left_prompt_items $tide_right_prompt_items && set -gx _tide_location_color "$data[5]"
|
||||
contains git $_tide_left_items $_tide_right_items && set -gx _tide_location_color "$data[5]"
|
||||
|
||||
# private_mode
|
||||
if contains private_mode $tide_left_prompt_items $tide_right_prompt_items && test -n "$fish_private_mode"
|
||||
if contains private_mode $_tide_left_items $_tide_right_items && test -n "$fish_private_mode"
|
||||
set -gx _tide_private_mode
|
||||
else
|
||||
set -e _tide_private_mode
|
||||
end
|
||||
|
||||
# two line prompt
|
||||
if contains newline $tide_left_prompt_items
|
||||
if contains newline $_tide_left_items
|
||||
set_color $tide_prompt_color_frame_and_connection -b normal | read -gx _tide_prompt_and_frame_color
|
||||
else
|
||||
set -e _tide_prompt_and_frame_color
|
||||
|
@ -1,7 +1,7 @@
|
||||
function _tide_item_status
|
||||
if string match --quiet --invert 0 $_tide_pipestatus # If there is a failure anywhere in the pipestatus
|
||||
if test "$_tide_pipestatus" = 1 # If simple failure
|
||||
contains character $tide_left_prompt_items || tide_status_bg_color=$tide_status_bg_color_failure \
|
||||
contains character $_tide_left_items || tide_status_bg_color=$tide_status_bg_color_failure \
|
||||
tide_status_color=$tide_status_color_failure _tide_print_item status $tide_status_icon_failure' ' 1
|
||||
else if test $_tide_status = 0
|
||||
_tide_print_item status $tide_status_icon' ' \
|
||||
@ -11,7 +11,7 @@ function _tide_item_status
|
||||
_tide_print_item status $tide_status_icon_failure' ' \
|
||||
(fish_status_to_signal $_tide_pipestatus | string replace SIG '' | string join '|')
|
||||
end
|
||||
else if not contains character $tide_left_prompt_items
|
||||
else if not contains character $_tide_left_items
|
||||
_tide_print_item status $tide_status_icon
|
||||
end
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
function _tide_prompt
|
||||
set -g prev_item_was_newline
|
||||
_tide_side=left set -f left (for item in $tide_left_prompt_items
|
||||
_tide_side=left set -f left (for item in $_tide_left_items
|
||||
_tide_item_$item
|
||||
end
|
||||
if not set -e prev_item_was_newline
|
||||
@ -9,7 +9,7 @@ function _tide_prompt
|
||||
end)
|
||||
|
||||
set -g prev_item_was_newline
|
||||
_tide_side=right set -f right (for item in $tide_right_prompt_items
|
||||
_tide_side=right set -f right (for item in $_tide_right_items
|
||||
_tide_item_$item
|
||||
end
|
||||
if not set -e prev_item_was_newline
|
||||
|
@ -1,15 +1,19 @@
|
||||
function _tide_remove_unusable_items
|
||||
# Remove tool-specific items for tools the machine doesn't have installed
|
||||
set -l removed_items
|
||||
for item in chruby git go kubectl node php rustc terraform toolbox virtual_env
|
||||
set -l cli_names $item
|
||||
switch $item
|
||||
case virtual_env
|
||||
set cli_names python python3
|
||||
end
|
||||
type --query $cli_names || set -a removed_items $item
|
||||
end
|
||||
|
||||
if not type --query $cli_names
|
||||
_tide_find_and_remove $item tide_left_prompt_items
|
||||
_tide_find_and_remove $item tide_right_prompt_items
|
||||
end
|
||||
end
|
||||
set -U _tide_left_items (for item in $tide_left_prompt_items
|
||||
contains $item $removed_items || echo $item
|
||||
end)
|
||||
set -U _tide_right_items (for item in $tide_right_prompt_items
|
||||
contains $item $removed_items || echo $item
|
||||
end)
|
||||
end
|
||||
|
@ -7,8 +7,7 @@ function _tide_sub_bug-report
|
||||
source && fisher install ilancosman/tide@v5"
|
||||
else if set -q _flag_verbose
|
||||
set --long | string match -r "^_?tide.*" | # Get only tide variables
|
||||
string match -r --invert "^_tide_prompt_var.*" | # Remove _tide_prompt_var
|
||||
string match -r --invert "^_tide_var_list.*" # Remove _tide_var_list
|
||||
string match -r --invert "^_tide_prompt_var.*" # Remove _tide_prompt_var
|
||||
else
|
||||
set -l fish_version (fish --version | string match -r "fish, version (\d\.\d\.\d)")[2]
|
||||
_tide_check_version Fish fish-shell/fish-shell "(\d\.\d\.\d)" $fish_version || return
|
||||
|
Loading…
Reference in New Issue
Block a user