mirror of
https://github.com/IlanCosman/tide.git
synced 2024-09-11 17:15:34 +03:00
Generalize prompt items, add left_prompt
This commit is contained in:
parent
859600359c
commit
9b3ec5eabe
16
functions/_lean_cmd_duration.fish
Normal file
16
functions/_lean_cmd_duration.fish
Normal file
@ -0,0 +1,16 @@
|
||||
function _lean_cmd_duration
|
||||
if test $CMD_DURATION -gt $lean_cmd_duration_threshold
|
||||
set -l seconds (math --scale=$lean_cmd_duration_decimals "$CMD_DURATION/1000" % 60)
|
||||
set -l minutes (math -s0 "$seconds/60" % 60)
|
||||
set -l hours (math -s0 "$minutes/60" % 60)
|
||||
|
||||
for time in hours minutes seconds
|
||||
if test $$time -eq 0
|
||||
set -e $time
|
||||
end
|
||||
end
|
||||
|
||||
set_color $lean_cmd_duration_color
|
||||
echo -n {$hours}'h' {$minutes}'m' {$seconds}'s'
|
||||
end
|
||||
end
|
9
functions/_lean_context.fish
Normal file
9
functions/_lean_context.fish
Normal file
@ -0,0 +1,9 @@
|
||||
function _lean_context
|
||||
if set -q SSH_TTY
|
||||
set_color $lean_context_ssh_color
|
||||
echo -n $USER'@'(prompt_hostname)
|
||||
else if test $USER = 'root'
|
||||
set_color $lean_context_root_color
|
||||
echo -n $USER'@'(prompt_hostname)
|
||||
end
|
||||
end
|
@ -1,8 +1,8 @@
|
||||
function lean_git_prompt
|
||||
function _lean_git_prompt
|
||||
set -l gitPrompt (fish_git_prompt)
|
||||
|
||||
set -l gitPrompt (string replace '(' '' $gitPrompt)
|
||||
set -l gitPrompt (string replace ')' '' $gitPrompt)
|
||||
|
||||
echo $gitPrompt
|
||||
string trim $gitPrompt
|
||||
end
|
6
functions/_lean_jobs.fish
Normal file
6
functions/_lean_jobs.fish
Normal file
@ -0,0 +1,6 @@
|
||||
function _lean_jobs
|
||||
if jobs -q
|
||||
set_color $lean_jobs_color
|
||||
echo -n $lean_jobs_icon
|
||||
end
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
function lean_pwd
|
||||
function _lean_pwd
|
||||
set -l splitPwd (string split --no-empty '/' (_shorten_pwd))
|
||||
set -l splitPwdLength (count $splitPwd)
|
||||
|
16
functions/_lean_status.fish
Normal file
16
functions/_lean_status.fish
Normal file
@ -0,0 +1,16 @@
|
||||
function _lean_status
|
||||
if string match -q --invert '0' $last_pipestatus
|
||||
set -l fishPipestatusWithSignal (__fish_pipestatus_with_signal $last_pipestatus)
|
||||
|
||||
if test (count $last_pipestatus) -gt 1 || string match -qe 'SIG' $fishPipestatusWithSignal
|
||||
if test $last_status -eq 0
|
||||
set_color $lean_status_success_color
|
||||
echo -n {$lean_status_success_icon}' '
|
||||
else
|
||||
set_color $lean_status_failure_color
|
||||
echo -n {$lean_status_failure_icon}' '
|
||||
end
|
||||
string join '|' (string replace 'SIG' '' $fishPipestatusWithSignal)
|
||||
end
|
||||
end
|
||||
end
|
4
functions/_lean_time.fish
Normal file
4
functions/_lean_time.fish
Normal file
@ -0,0 +1,4 @@
|
||||
function _lean_time
|
||||
set_color $lean_time_color
|
||||
date +$lean_time_format
|
||||
end
|
@ -9,7 +9,8 @@ function fish_prompt --description 'Write out the prompt'
|
||||
printf "%.s$lean_prompt_connection_icon" (seq $COLUMNS)
|
||||
set_color $fish_color_normal
|
||||
|
||||
echo -ne '\r'(lean_pwd)(lean_git_prompt)' '
|
||||
printf '\r'
|
||||
lean_left_prompt
|
||||
|
||||
set -l rightPrompt (lean_right_prompt)
|
||||
set -l rightPromptStartLocation (math $COLUMNS-(string length (lean_decolor $rightPrompt)))
|
||||
@ -25,3 +26,4 @@ function fish_prompt --description 'Write out the prompt'
|
||||
echo -n '❯ '
|
||||
set_color $fish_color_normal
|
||||
end
|
||||
|
||||
|
11
functions/lean_left_prompt.fish
Normal file
11
functions/lean_left_prompt.fish
Normal file
@ -0,0 +1,11 @@
|
||||
function lean_left_prompt
|
||||
for item in lean_{$lean_left_prompt_items}
|
||||
set -l itemOutput (_$item)
|
||||
|
||||
if test -n "$itemOutput"
|
||||
echo -n $itemOutput' '
|
||||
end
|
||||
|
||||
set_color normal
|
||||
end
|
||||
end
|
@ -2,7 +2,8 @@
|
||||
printf "%.s$lean_prompt_connection_icon" (seq $COLUMNS)
|
||||
set_color $fish_color_normal
|
||||
|
||||
echo -ne '\r'(lean_pwd)(lean_git_prompt)' '
|
||||
printf '\r'
|
||||
lean_left_prompt
|
||||
|
||||
set -l rightPrompt (lean_right_prompt)
|
||||
set -l rightPromptStartLocation (math $COLUMNS-(string length (lean_decolor $rightPrompt)))
|
||||
|
Loading…
Reference in New Issue
Block a user