mirror of
https://github.com/IlanCosman/tide.git
synced 2024-12-23 12:03:48 +03:00
Convert many items to _tide_print_item
This commit is contained in:
parent
8f506f9f0d
commit
5592e225c9
@ -1,6 +1,3 @@
|
|||||||
function _tide_item_chruby
|
function _tide_item_chruby
|
||||||
if test -n "$RUBY_VERSION"
|
test -n "$RUBY_VERSION" && _tide_print_item ruby $RUBY_VERSION
|
||||||
set_color $tide_chruby_color
|
|
||||||
printf '%s' $tide_chruby_icon' ' $RUBY_VERSION
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@ -4,14 +4,12 @@ function _tide_item_cmd_duration
|
|||||||
set -l minutes (math --scale=0 "$CMD_DURATION/60000" % 60)
|
set -l minutes (math --scale=0 "$CMD_DURATION/60000" % 60)
|
||||||
set -l hours (math --scale=0 "$CMD_DURATION/3600000")
|
set -l hours (math --scale=0 "$CMD_DURATION/3600000")
|
||||||
|
|
||||||
set_color $tide_cmd_duration_color
|
|
||||||
|
|
||||||
if test $hours != 0
|
if test $hours != 0
|
||||||
printf '%s' $tide_cmd_duration_icon' ' $hours'h ' $minutes'm ' $seconds's'
|
_tide_print_item cmd_duration $hours'h ' $minutes'm ' $seconds's'
|
||||||
else if test $minutes != 0
|
else if test $minutes != 0
|
||||||
printf '%s' $tide_cmd_duration_icon' ' $minutes'm ' $seconds's'
|
_tide_print_item cmd_duration $minutes'm ' $seconds's'
|
||||||
else if test $seconds != 0
|
else if test $seconds != 0
|
||||||
printf '%s' $tide_cmd_duration_icon' ' $seconds's'
|
_tide_print_item cmd_duration $seconds's'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
function _tide_item_context
|
function _tide_item_context
|
||||||
if set -q SSH_TTY
|
if set -q SSH_TTY
|
||||||
set_color $tide_context_ssh_color
|
set -g tide_context_color $tide_context_ssh_color
|
||||||
printf '%s' $USER'@'$hostname
|
_tide_print_item context $USER'@'$hostname
|
||||||
else if contains -- $USER root toor Administrator
|
else if contains -- $USER root toor Administrator
|
||||||
set_color $tide_context_root_color
|
set -g tide_context_color $tide_context_root_color
|
||||||
printf '%s' $USER'@'$hostname
|
_tide_print_item context $USER'@'$hostname
|
||||||
else if test "$tide_context_always_display" = true
|
else if test "$tide_context_always_display" = true
|
||||||
set_color $tide_context_default_color
|
set -g tide_context_color $tide_context_default_color
|
||||||
printf '%s' $USER'@'$hostname
|
_tide_print_item context $USER'@'$hostname
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -58,7 +58,7 @@ function _tide_item_git
|
|||||||
set -l untracked (string match --regex '^\?\?' $gitInfo | count) || set -e untracked
|
set -l untracked (string match --regex '^\?\?' $gitInfo | count) || set -e untracked
|
||||||
|
|
||||||
# Print the information
|
# Print the information
|
||||||
printf '%s' \
|
_tide_print_item git \
|
||||||
(set_color $tide_git_branch_color) $location \
|
(set_color $tide_git_branch_color) $location \
|
||||||
(set_color $tide_git_operation_color) ' '$operation ' '$step/$totalSteps \
|
(set_color $tide_git_operation_color) ' '$operation ' '$step/$totalSteps \
|
||||||
(set_color $tide_git_upstream_color) ' ⇣'$upstreamBehind ' ⇡'$upstreamAhead \
|
(set_color $tide_git_upstream_color) ' ⇣'$upstreamBehind ' ⇡'$upstreamAhead \
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
function _tide_item_jobs
|
function _tide_item_jobs
|
||||||
if test $_tide_jobs_number != 0
|
if test $_tide_jobs_number != 0
|
||||||
set_color $tide_jobs_color
|
|
||||||
|
|
||||||
if test "$tide_jobs_verbose" = true
|
if test "$tide_jobs_verbose" = true
|
||||||
printf '%s' $tide_jobs_icon' ' $_tide_jobs_number
|
_tide_print_item jobs $_tide_jobs_number
|
||||||
else
|
else
|
||||||
printf '%s' $tide_jobs_icon
|
_tide_print_item jobs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
function _tide_item_nvm
|
function _tide_item_nvm
|
||||||
set -l nvmCurrent (nvm current)
|
set -l nvmCurrent (nvm current)
|
||||||
if test "$nvmCurrent" != system
|
test "$nvmCurrent" != system && _tide_print_item nvm $nvmCurrent
|
||||||
set_color $tide_nvm_color
|
|
||||||
printf '%s' $tide_nvm_icon' ' $nvmCurrent
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
function _tide_item_os
|
function _tide_item_os
|
||||||
set_color $tide_os_color
|
_tide_print_item os
|
||||||
printf '%s' $_tide_os_icon
|
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
function _tide_item_php
|
function _tide_item_php
|
||||||
if test -e composer.json
|
test -e composer.json && _tide_print_item php (php --version | string match --regex 'PHP ([\d.]+)')[2]
|
||||||
set_color $tide_php_color
|
|
||||||
printf '%s' $tide_php_icon' ' (php --version | string match --regex 'PHP ([\d.]+)')[2]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
function _tide_item_prompt_char
|
function _tide_item_prompt_char
|
||||||
if test $_tide_last_status = 0
|
if test $_tide_last_status = 0
|
||||||
set_color $tide_prompt_char_success_color
|
set -g tide_prompt_char_color $tide_prompt_char_success_color
|
||||||
else
|
else
|
||||||
set_color $tide_prompt_char_failure_color
|
set -g tide_prompt_char_color $tide_prompt_char_failure_color
|
||||||
end
|
end
|
||||||
|
|
||||||
if test "$fish_key_bindings" = fish_default_key_bindings
|
if test "$fish_key_bindings" = fish_default_key_bindings
|
||||||
printf '%s' $tide_prompt_char_icon
|
_tide_print_item prompt_char
|
||||||
else
|
else
|
||||||
switch $fish_bind_mode
|
switch $fish_bind_mode
|
||||||
case default
|
case default
|
||||||
printf '%s' $tide_prompt_char_vi_default_icon
|
tide_prompt_char_icon=$tide_prompt_char_vi_default_icon _tide_print_item prompt_char
|
||||||
case insert
|
case insert
|
||||||
printf '%s' $tide_prompt_char_vi_insert_icon
|
tide_prompt_char_icon=$tide_prompt_char_vi_insert_icon _tide_print_item prompt_char
|
||||||
case replace replace_one
|
case replace replace_one
|
||||||
printf '%s' $tide_prompt_char_vi_replace_icon
|
tide_prompt_char_icon=$tide_prompt_char_vi_replace_icon _tide_print_item prompt_char
|
||||||
case visual
|
case visual
|
||||||
printf '%s' $tide_prompt_char_vi_visual_icon
|
tide_prompt_char_icon=$tide_prompt_char_vi_visual_icon _tide_print_item prompt_char
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -35,14 +35,15 @@ function _tide_item_pwd
|
|||||||
|
|
||||||
# All the actual printing
|
# All the actual printing
|
||||||
if not test -w $PWD
|
if not test -w $PWD
|
||||||
printf '%s' $colorDirs $tide_pwd_unwritable_icon' '
|
set -g tide_pwd_icon $colorDirs$tide_pwd_unwritable_icon
|
||||||
else if test $PWD = $HOME
|
else if test $PWD = $HOME
|
||||||
printf '%s' $colorDirs $tide_pwd_home_icon' '
|
set -g tide_pwd_icon $colorDirs $tide_pwd_home_icon
|
||||||
else
|
else
|
||||||
printf '%s' $colorDirs $tide_pwd_dir_icon' '
|
set -g tide_pwd_icon $colorDirs$tide_pwd_dir_icon
|
||||||
end
|
end
|
||||||
|
|
||||||
test "$splitPwd[1]" = '~' || printf '%s' /
|
set -l blah $splitPwdForOutput
|
||||||
|
test "$splitPwd[1]" = '~' || set -p blah '/'
|
||||||
|
|
||||||
string join -- / $splitPwdForOutput
|
_tide_print_item pwd (string join -- / $blah)
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
function _tide_item_rust
|
function _tide_item_rust
|
||||||
if test -e Cargo.toml
|
test -e Cargo.toml && _tide_print_item rust (rustc --version | string split ' ')[2]
|
||||||
set_color $tide_rust_color
|
|
||||||
printf '%s' $tide_rust_icon' ' (rustc --version | string split ' ')[2]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@ -3,25 +3,25 @@ function _tide_item_status
|
|||||||
if test "$_tide_last_pipestatus" = 1 # If simple failure
|
if test "$_tide_last_pipestatus" = 1 # If simple failure
|
||||||
if not contains prompt_char $tide_left_prompt_items
|
if not contains prompt_char $tide_left_prompt_items
|
||||||
set -g tide_status_bg_color $tide_status_failure_bg_color
|
set -g tide_status_bg_color $tide_status_failure_bg_color
|
||||||
set_color $tide_status_failure_color
|
set -g tide_status_color $tide_status_failure_color
|
||||||
printf '%s' $tide_status_failure_icon' ' 1
|
tide_status_icon=$tide_status_failure_icon _tide_print_item status 1
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if test $_tide_last_status = 0
|
if test $_tide_last_status = 0
|
||||||
set -g tide_status_bg_color $tide_status_success_bg_color
|
set -g tide_status_bg_color $tide_status_success_bg_color
|
||||||
set_color $tide_status_success_color
|
set -g tide_status_color $tide_status_success_color
|
||||||
printf '%s' $tide_status_success_icon' '
|
tide_status_icon=$tide_status_success_icon _tide_print_item status \
|
||||||
|
(fish_status_to_signal $_tide_last_pipestatus | string replace SIG '' | string join '|')
|
||||||
else
|
else
|
||||||
set -g tide_status_bg_color $tide_status_failure_bg_color
|
set -g tide_status_bg_color $tide_status_failure_bg_color
|
||||||
set_color $tide_status_failure_color
|
set -g tide_status_color $tide_status_failure_color
|
||||||
printf '%s' $tide_status_failure_icon' '
|
tide_status_icon=$tide_status_failure_icon _tide_print_item status \
|
||||||
|
(fish_status_to_signal $_tide_last_pipestatus | string replace SIG '' | string join '|')
|
||||||
end
|
end
|
||||||
|
|
||||||
fish_status_to_signal $_tide_last_pipestatus | string replace SIG '' | string join '|'
|
|
||||||
end
|
end
|
||||||
else if not contains prompt_char $tide_left_prompt_items
|
else if not contains prompt_char $tide_left_prompt_items
|
||||||
set -g tide_status_bg_color $tide_status_success_bg_color
|
set -g tide_status_bg_color $tide_status_success_bg_color
|
||||||
set_color $tide_status_success_color
|
set -g tide_status_color $tide_status_success_color
|
||||||
printf '%s' $tide_status_success_icon
|
tide_status_icon=$tide_status_success_icon _tide_print_item status
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
function _tide_item_time
|
function _tide_item_time
|
||||||
set_color $tide_time_color
|
_tide_print_item time (date +$tide_time_format)
|
||||||
date +$tide_time_format
|
|
||||||
end
|
end
|
||||||
|
@ -1,45 +1,16 @@
|
|||||||
function _tide_left_prompt
|
function _tide_left_prompt
|
||||||
set -l lastItem newline
|
|
||||||
|
|
||||||
for item in $tide_left_prompt_items
|
for item in $tide_left_prompt_items
|
||||||
if test "$item" = newline
|
if test "$item" = newline
|
||||||
set_color $previousColor -b normal
|
set_color $previousColor -b normal
|
||||||
printf '%s' $tide_left_prompt_suffix\n
|
printf '%s' $tide_left_prompt_suffix\n
|
||||||
|
set -g tide_last_item newline
|
||||||
else
|
else
|
||||||
set -l output (_tide_item_$item)
|
_tide_item_$item
|
||||||
test -n "$output" || continue
|
|
||||||
|
|
||||||
set -l colorName tide_"$item"_bg_color
|
|
||||||
set -l color $$colorName
|
|
||||||
|
|
||||||
if test "$lastItem" = newline
|
|
||||||
if test "$item" != prompt_char
|
|
||||||
set_color $color -b normal
|
|
||||||
printf '%s' $tide_left_prompt_prefix
|
|
||||||
end
|
|
||||||
else if test "$color" = "$previousColor"
|
|
||||||
set_color $tide_left_prompt_item_separator_same_color_color
|
|
||||||
printf '%s' $tide_left_prompt_item_separator_same_color
|
|
||||||
else
|
|
||||||
set_color $previousColor -b $color
|
|
||||||
printf '%s' $tide_left_prompt_item_separator_diff_color
|
|
||||||
end
|
|
||||||
|
|
||||||
set_color -b $color
|
|
||||||
|
|
||||||
if test "$tide_left_prompt_pad_items" = true -a "$item" != prompt_char
|
|
||||||
printf '%s' " $output "
|
|
||||||
else
|
|
||||||
printf '%s' "$output"
|
|
||||||
end
|
|
||||||
|
|
||||||
set previousColor $color
|
|
||||||
end
|
end
|
||||||
set lastItem $item
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if test "$lastItem" != newline -a "$lastItem" != prompt_char
|
if test "$tide_last_item" != newline -a "$tide_last_item" != prompt_char
|
||||||
set_color $previousColor -b normal
|
set_color $tide_previous_bg_color -b normal
|
||||||
printf '%s' $tide_left_prompt_suffix
|
printf '%s' $tide_left_prompt_suffix
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ function _tide_print_item -a item
|
|||||||
set_color $itemColor -b $itemBgColor
|
set_color $itemColor -b $itemBgColor
|
||||||
|
|
||||||
test "$tide_left_prompt_pad_items" = true -a "$item" != prompt_char && set -l padItem ' '
|
test "$tide_left_prompt_pad_items" = true -a "$item" != prompt_char && set -l padItem ' '
|
||||||
itemIconName=tide_"$item"_icon printf '%s' $padItem $$itemIconName $argv[2..] $padItem
|
itemIconName=tide_"$item"_icon printf '%s' $padItem $$itemIconName' ' $argv[2..] $padItem
|
||||||
|
|
||||||
set -g tide_previous_bg_color $itemBgColor
|
set -g tide_previous_bg_color $itemBgColor
|
||||||
set -g tide_last_item $item
|
set -g tide_last_item $item
|
||||||
|
Loading…
Reference in New Issue
Block a user