Remove icon responsibilty from _tide_print_item

This commit is contained in:
Ilan Cosman 2021-05-04 08:47:32 -07:00
parent 6d2e90ab9f
commit bbee4139d0
13 changed files with 32 additions and 34 deletions

View File

@ -6,17 +6,17 @@ function _tide_item_character
end
if test "$fish_key_bindings" = fish_default_key_bindings
_tide_print_item character
_tide_print_item character $tide_character_icon
else
switch $fish_bind_mode
case default
tide_character_icon=$tide_character_vi_default_icon _tide_print_item character
_tide_print_item character $tide_character_vi_default_icon
case insert
tide_character_icon=$tide_character_vi_insert_icon _tide_print_item character
_tide_print_item character $tide_character_vi_insert_icon
case replace replace_one
tide_character_icon=$tide_character_vi_replace_icon _tide_print_item character
_tide_print_item character $tide_character_vi_replace_icon
case visual
tide_character_icon=$tide_character_vi_visual_icon _tide_print_item character
_tide_print_item character $tide_character_vi_visual_icon
end
end
end

View File

@ -1,3 +1,3 @@
function _tide_item_chruby
test -n "$RUBY_VERSION" && _tide_print_item chruby $RUBY_VERSION
test -n "$RUBY_VERSION" && _tide_print_item chruby $tide_chruby_icon' ' $RUBY_VERSION
end

View File

@ -5,11 +5,11 @@ function _tide_item_cmd_duration
set -l hours (math --scale=0 "$CMD_DURATION/3600000")
if test $hours != 0
_tide_print_item cmd_duration $hours'h ' $minutes'm ' $seconds's'
_tide_print_item cmd_duration $tide_cmd_duration_icon' ' $hours'h ' $minutes'm ' $seconds's'
else if test $minutes != 0
_tide_print_item cmd_duration $minutes'm ' $seconds's'
_tide_print_item cmd_duration $tide_cmd_duration_icon' ' $minutes'm ' $seconds's'
else if test $seconds != 0
_tide_print_item cmd_duration $seconds's'
_tide_print_item cmd_duration $tide_cmd_duration_icon' ' $seconds's'
end
end
end

View File

@ -1,9 +1,9 @@
function _tide_item_jobs
if test $_tide_jobs_number != 0
if test "$tide_jobs_verbose" = true
_tide_print_item jobs $_tide_jobs_number
_tide_print_item jobs $tide_jobs_icon' ' $_tide_jobs_number
else
_tide_print_item jobs
_tide_print_item jobs $tide_jobs_icon
end
end
end

View File

@ -1,4 +1,4 @@
function _tide_item_nvm
set -l nvmCurrent (nvm current)
test "$nvmCurrent" != system && _tide_print_item nvm $nvmCurrent
test "$nvmCurrent" != system && _tide_print_item nvm $tide_nvm_icon' ' $nvmCurrent
end

View File

@ -1,3 +1,3 @@
function _tide_item_os
_tide_print_item os
_tide_print_item os $tide_os_icon
end

View File

@ -1,3 +1,3 @@
function _tide_item_php
test -e composer.json && _tide_print_item php (php --version | string match --regex 'PHP ([\d.]+)')[2]
test -e composer.json && _tide_print_item php $tide_php_icon' ' (php --version | string match --regex 'PHP ([\d.]+)')[2]
end

View File

@ -33,16 +33,14 @@ function _tide_item_pwd
end
end
# All the actual printing
if not test -w $PWD
set -g tide_pwd_icon $colorDirs$tide_pwd_unwritable_icon
else if test $PWD = $HOME
set -g tide_pwd_icon $colorDirs$tide_pwd_home_icon
else
set -g tide_pwd_icon $colorDirs$tide_pwd_dir_icon
end
# Printing logic
test "$splitPwd[1]" = '~' || set splitPwdForOutput[1] '/'$splitPwdForOutput[1]
_tide_print_item pwd (string join -- / $splitPwdForOutput)
if not test -w $PWD
_tide_print_item pwd $colorDirs$tide_pwd_unwritable_icon' ' (string join -- / $splitPwdForOutput)
else if test $PWD = $HOME
_tide_print_item pwd $colorDirs$tide_pwd_home_icon' ' (string join -- / $splitPwdForOutput)
else
_tide_print_item pwd $colorDirs$tide_pwd_dir_icon' ' (string join -- / $splitPwdForOutput)
end
end

View File

@ -1,3 +1,3 @@
function _tide_item_rustc
test -e Cargo.toml && _tide_print_item rustc (rustc --version | string split ' ')[2]
test -e Cargo.toml && _tide_print_item rustc $tide_rustc_icon' ' (rustc --version | string split ' ')[2]
end

View File

@ -4,24 +4,24 @@ function _tide_item_status
if not contains character $tide_left_prompt_items
set -g tide_status_bg_color $tide_status_failure_bg_color
set -g tide_status_color $tide_status_failure_color
tide_status_icon=$tide_status_failure_icon _tide_print_item status 1
_tide_print_item status $tide_status_failure_icon' ' 1
end
else
if test $_tide_last_status = 0
set -g tide_status_bg_color $tide_status_success_bg_color
set -g tide_status_color $tide_status_success_color
tide_status_icon=$tide_status_success_icon _tide_print_item status \
_tide_print_item status $tide_status_success_icon' ' \
(fish_status_to_signal $_tide_last_pipestatus | string replace SIG '' | string join '|')
else
set -g tide_status_bg_color $tide_status_failure_bg_color
set -g tide_status_color $tide_status_failure_color
tide_status_icon=$tide_status_failure_icon _tide_print_item status \
_tide_print_item status $tide_status_failure_icon' ' \
(fish_status_to_signal $_tide_last_pipestatus | string replace SIG '' | string join '|')
end
end
else if not contains character $tide_left_prompt_items
set -g tide_status_bg_color $tide_status_success_bg_color
set -g tide_status_color $tide_status_success_color
tide_status_icon=$tide_status_success_icon _tide_print_item status
_tide_print_item status $tide_status_success_icon
end
end

View File

@ -1,3 +1,3 @@
function _tide_item_time
_tide_print_item time (date +$tide_time_format)
_tide_print_item time $tide_time_icon' ' (date +$tide_time_format)
end

View File

@ -2,9 +2,9 @@ function _tide_item_virtual_env
if set -l splitVirtualEnv (string split '/' "$VIRTUAL_ENV")
# Avoid printing a generic name
if contains -- $splitVirtualEnv[-1] virtualenv venv .venv env
_tide_print_item virtual_env $splitVirtualEnv[-2]
_tide_print_item virtual_env $tide_virual_env_icon' ' $splitVirtualEnv[-2]
else
_tide_print_item virtual_env $splitVirtualEnv[-1]
_tide_print_item virtual_env $tide_virual_env_icon' ' $splitVirtualEnv[-1]
end
end
end

View File

@ -31,9 +31,9 @@ function _tide_print_item -a item
set_color $itemColor -b $itemBgColor
if test "$tide_prompt_pad_items" = true -a "$item" != character
itemIconName=tide_"$item"_icon printf '%s' ' ' $$itemIconName' ' $argv[2..] ' '
printf '%s' ' ' $argv[2..] ' '
else
itemIconName=tide_"$item"_icon printf '%s' $$itemIconName' ' $argv[2..]
printf '%s' $argv[2..]
end
set -g tide_previous_bg_color $itemBgColor