mirror of
https://github.com/IlanCosman/tide.git
synced 2024-11-22 23:03:26 +03:00
Rename functions
This commit is contained in:
parent
609ac07b04
commit
78110a8cfb
@ -1,4 +1,4 @@
|
||||
function tide_count_left_prompt_height --on-variable tide_left_prompt_items
|
||||
function _tide_count_left_prompt_height --on-variable tide_left_prompt_items
|
||||
set -l numberOfNewlines (count (string match -a 'newline' $tide_left_prompt_items))
|
||||
set -U tide_left_prompt_height (math 1+$numberOfNewlines)
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
function tide_decolor -a text
|
||||
function _tide_decolor -a text
|
||||
set text (string replace -a (set_color normal) '' "$text")
|
||||
set text (string replace -ar '\e\[[0-9;]*m' '' "$text")
|
||||
|
@ -1,4 +1,4 @@
|
||||
function _tide_cmd_duration
|
||||
function _tide_item_cmd_duration
|
||||
if test $CMD_DURATION -gt $tide_cmd_duration_threshold
|
||||
set -l seconds (math --scale=$tide_cmd_duration_decimals "$CMD_DURATION/1000" % 60)
|
||||
set -l minutes (math -s0 "$CMD_DURATION/60000" % 60)
|
@ -1,4 +1,4 @@
|
||||
function _tide_context
|
||||
function _tide_item_context
|
||||
if set -q SSH_TTY
|
||||
set_color $tide_context_ssh_color
|
||||
printf '%s ' $USER'@'(prompt_hostname)
|
@ -1,4 +1,4 @@
|
||||
function _tide_git_prompt
|
||||
function _tide_item_git_prompt
|
||||
if set -l gitPrompt (fish_git_prompt)
|
||||
|
||||
set -l gitPrompt (string replace '(' '' $gitPrompt)
|
@ -1,4 +1,4 @@
|
||||
function _tide_jobs
|
||||
function _tide_item_jobs
|
||||
if jobs -q
|
||||
set_color $tide_jobs_color
|
||||
printf '%s ' $tide_jobs_icon
|
3
functions/_tide_item_newline.fish
Normal file
3
functions/_tide_item_newline.fish
Normal file
@ -0,0 +1,3 @@
|
||||
function _tide_item_newline
|
||||
printf '%s' '\n'
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
function _tide_prompt_char
|
||||
function _tide_item_prompt_char
|
||||
if test $last_status -eq 0
|
||||
set_color $tide_prompt_char_success_color
|
||||
else
|
@ -1,4 +1,4 @@
|
||||
function _tide_pwd
|
||||
function _tide_item_pwd
|
||||
set -l splitPwd (string split --no-empty '/' (_truncate_pwd))
|
||||
set -l splitPwdLength (count $splitPwd)
|
||||
|
@ -1,4 +1,4 @@
|
||||
function _tide_status
|
||||
function _tide_item_status
|
||||
if string match -q --invert '0' $last_pipestatus
|
||||
set -l fishPipestatusWithSignal (__fish_pipestatus_with_signal $last_pipestatus)
|
||||
|
@ -1,4 +1,4 @@
|
||||
function _tide_time
|
||||
function _tide_item_time
|
||||
set_color $tide_time_color
|
||||
printf '%s ' (date +$tide_time_format)
|
||||
end
|
8
functions/_tide_left_prompt.fish
Normal file
8
functions/_tide_left_prompt.fish
Normal file
@ -0,0 +1,8 @@
|
||||
function _tide_left_prompt
|
||||
for item in _tide_item_{$tide_left_prompt_items}
|
||||
set -l itemOutput ($item)
|
||||
printf '%b' "$itemOutput"
|
||||
|
||||
set_color normal
|
||||
end
|
||||
end
|
@ -1,3 +0,0 @@
|
||||
function _tide_newline
|
||||
printf '%s' '\n'
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
function tide_right_prompt
|
||||
function _tide_right_prompt
|
||||
set -l splitText (string split '\n' (_fetch_right_prompt_items))
|
||||
set -l printAtEndedRightPromptHeight (count $splitText)
|
||||
|
||||
@ -23,8 +23,8 @@ end
|
||||
function _fetch_right_prompt_items
|
||||
printf '%s' ' '
|
||||
|
||||
for item in tide_{$tide_right_prompt_items}
|
||||
set -l itemOutput (_$item)
|
||||
for item in _tide_item_{$tide_right_prompt_items}
|
||||
set -l itemOutput ($item)
|
||||
printf '%s' "$itemOutput"
|
||||
|
||||
set_color normal
|
||||
@ -32,7 +32,7 @@ function _fetch_right_prompt_items
|
||||
end
|
||||
|
||||
function _print_at_end -a text
|
||||
set -l startLocation (math $COLUMNS -(string length (tide_decolor $text)))
|
||||
set -l startLocation (math $COLUMNS -(string length (_tide_decolor $text)))
|
||||
_cursor_right $startLocation
|
||||
printf '%s' $text
|
||||
|
@ -12,8 +12,8 @@ function fish_prompt --description 'Write out the prompt'
|
||||
set_color $fish_color_normal
|
||||
|
||||
printf '%b' '\r'
|
||||
tide_right_prompt
|
||||
_tide_right_prompt
|
||||
|
||||
printf '%b' '\r'
|
||||
tide_left_prompt
|
||||
_tide_left_prompt
|
||||
end
|
||||
|
@ -1,8 +0,0 @@
|
||||
function tide_left_prompt
|
||||
for item in tide_{$tide_left_prompt_items}
|
||||
set -l itemOutput (_$item)
|
||||
printf '%b' "$itemOutput"
|
||||
|
||||
set_color normal
|
||||
end
|
||||
end
|
@ -118,8 +118,8 @@ function _set -a var_name
|
||||
end
|
||||
|
||||
function _source_tide_functions
|
||||
source "$__fish_config_dir/conf.d/tide_count_left_prompt_height.fish"
|
||||
source "$__fish_config_dir/conf.d/tide_cursor_movement.fish"
|
||||
source "$__fish_config_dir/conf.d/_tide_count_left_prompt_height.fish"
|
||||
source "$__fish_config_dir/conf.d/_tide_cursor_movement.fish"
|
||||
source "$__fish_config_dir/functions/fish_prompt.fish"
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@ function _cmd_duration -a duration threshold decimals
|
||||
set -g tide_cmd_duration_threshold $threshold
|
||||
set -g tide_cmd_duration_decimals $decimals
|
||||
|
||||
tide_decolor (_tide_cmd_duration)
|
||||
_tide_decolor (_tide_cmd_duration)
|
||||
end
|
||||
|
||||
@test 'Less than threshold' (_cmd_duration 2000 3000 0) -z
|
||||
|
@ -3,9 +3,9 @@
|
||||
set -l sourceFile "$__fish_config_dir/functions/_tide_context.fish"
|
||||
|
||||
function _context
|
||||
tide_decolor (_tide_context)
|
||||
_tide_decolor (_tide_context)
|
||||
end
|
||||
|
||||
@test 'None' (_context) -z
|
||||
@test 'SSH' (set -g SSH_TTY 'true'; _context) = $USER'@'(prompt_hostname)' '
|
||||
@test 'Root' (tide_decolor (su -c "fish -c 'source $sourceFile;_tide_context'")) = 'root@'(prompt_hostname)' '
|
||||
@test 'Root' (_tide_decolor (su -c "fish -c 'source $sourceFile;_tide_context'")) = 'root@'(prompt_hostname)' '
|
@ -1,7 +1,7 @@
|
||||
@mesg '-------------jobs-------------'
|
||||
|
||||
function _jobs
|
||||
tide_decolor (_tide_jobs)
|
||||
_tide_decolor (_tide_jobs)
|
||||
end
|
||||
|
||||
@test 'No Jobs' (_jobs) -z
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
function _pwd -a dir
|
||||
cd $dir
|
||||
tide_decolor (_tide_pwd)
|
||||
_tide_decolor (_tide_pwd)
|
||||
end
|
||||
|
||||
set -l unwr "$tide_pwd_unwritable_icon "
|
||||
|
@ -3,7 +3,7 @@
|
||||
function _status
|
||||
set -g last_pipestatus $pipestatus
|
||||
set -g last_status $status
|
||||
tide_decolor (_tide_status)
|
||||
_tide_decolor (_tide_status)
|
||||
end
|
||||
|
||||
@test 'true' (true; _status) -z
|
||||
|
@ -21,7 +21,7 @@ function _fetch_right_prompt_items
|
||||
end
|
||||
|
||||
function _print_at_end -a text
|
||||
set -l startLocation (math $fake_columns -(string length (tide_decolor $text)))
|
||||
set -l startLocation (math $fake_columns -(string length (_tide_decolor $text)))
|
||||
_cursor_right $startLocation
|
||||
printf '%s' $text
|
||||
|
||||
|
@ -93,7 +93,7 @@ end
|
||||
|
||||
function _quit --on-signal INT
|
||||
source "$__fish_config_dir/functions/fish_prompt.fish"
|
||||
source "$__fish_config_dir/functions/tide_left_prompt.fish"
|
||||
source "$__fish_config_dir/functions/tide_right_prompt.fish"
|
||||
source "$__fish_config_dir/functions/_tide_left_prompt.fish"
|
||||
source "$__fish_config_dir/functions/_tide_right_prompt.fish"
|
||||
clear
|
||||
end
|
Loading…
Reference in New Issue
Block a user