mirror of
https://github.com/IlanCosman/tide.git
synced 2024-11-12 19:47:03 +03:00
Multi-line right prompt
This commit is contained in:
parent
8ad87ed74a
commit
ab1d200513
@ -15,6 +15,6 @@ function _lean_cmd_duration
|
||||
end
|
||||
|
||||
set_color $lean_cmd_duration_color
|
||||
echo -n {$hours}'h' {$minutes}'m' {$seconds}'s'
|
||||
echo -n {$hours}'h' {$minutes}'m' {$seconds}'s'' '
|
||||
end
|
||||
end
|
@ -1,9 +1,9 @@
|
||||
function _lean_context
|
||||
if set -q SSH_TTY
|
||||
set_color $lean_context_ssh_color
|
||||
echo -n $USER'@'(prompt_hostname)
|
||||
echo -n $USER'@'(prompt_hostname)' '
|
||||
else if test $USER = 'root'
|
||||
set_color $lean_context_root_color
|
||||
echo -n $USER'@'(prompt_hostname)
|
||||
echo -n $USER'@'(prompt_hostname)' '
|
||||
end
|
||||
end
|
@ -4,5 +4,5 @@ function _lean_git_prompt
|
||||
set -l gitPrompt (string replace '(' '' $gitPrompt)
|
||||
set -l gitPrompt (string replace ')' '' $gitPrompt)
|
||||
|
||||
string trim $gitPrompt
|
||||
echo -n (string trim $gitPrompt)' '
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
function _lean_jobs
|
||||
if jobs -q
|
||||
set_color $lean_jobs_color
|
||||
echo -n $lean_jobs_icon
|
||||
echo -n "$lean_jobs_icon"' '
|
||||
end
|
||||
end
|
3
functions/_lean_newline.fish
Normal file
3
functions/_lean_newline.fish
Normal file
@ -0,0 +1,3 @@
|
||||
function _lean_newline
|
||||
echo -n '\n'
|
||||
end
|
8
functions/_lean_prompt_char.fish
Normal file
8
functions/_lean_prompt_char.fish
Normal file
@ -0,0 +1,8 @@
|
||||
function _lean_prompt_char
|
||||
if test $last_status -eq 0
|
||||
set_color $lean_color_green
|
||||
else
|
||||
set_color $fish_color_error
|
||||
end
|
||||
echo -n '❯ '
|
||||
end
|
@ -35,6 +35,7 @@ function _lean_pwd
|
||||
echo -n $splitPwd[-1]
|
||||
set_color $fish_color_normal
|
||||
end
|
||||
echo -n ' '
|
||||
end
|
||||
|
||||
function _shorten_pwd
|
||||
|
@ -10,7 +10,7 @@ function _lean_status
|
||||
set_color $lean_status_failure_color
|
||||
echo -n {$lean_status_failure_icon}' '
|
||||
end
|
||||
string join '|' (string replace 'SIG' '' $fishPipestatusWithSignal)
|
||||
echo -n (string join '|' (string replace 'SIG' '' $fishPipestatusWithSignal))' '
|
||||
end
|
||||
end
|
||||
end
|
@ -1,4 +1,5 @@
|
||||
function _lean_time
|
||||
set_color $lean_time_color
|
||||
date +$lean_time_format
|
||||
echo -n ' '
|
||||
end
|
5
functions/_up.fish
Normal file
5
functions/_up.fish
Normal file
@ -0,0 +1,5 @@
|
||||
function _up -a number
|
||||
if test $number -ne 0
|
||||
echo -ne '\033['$number'A'
|
||||
end
|
||||
end
|
@ -3,27 +3,18 @@ function fish_prompt --description 'Write out the prompt'
|
||||
set -g last_pipestatus $pipestatus
|
||||
set -g last_status $status
|
||||
|
||||
echo
|
||||
if test "$lean_newline" = 'true'
|
||||
echo
|
||||
end
|
||||
|
||||
set_color $lean_prompt_connection_color
|
||||
printf "%.s$lean_prompt_connection_icon" (seq $COLUMNS)
|
||||
set_color $fish_color_normal
|
||||
|
||||
printf '\r'
|
||||
lean_right_prompt
|
||||
_up $leftPromptHeight
|
||||
|
||||
printf '\r'
|
||||
lean_left_prompt
|
||||
|
||||
set -l rightPrompt (lean_right_prompt)
|
||||
set -l rightPromptStartLocation (math $COLUMNS-(string length (lean_decolor $rightPrompt)))
|
||||
printf '\r\033['$rightPromptStartLocation'C'
|
||||
echo $rightPrompt
|
||||
|
||||
# Prompt character
|
||||
if test $last_status -eq 0
|
||||
set_color $lean_color_green
|
||||
else
|
||||
set_color $fish_color_error
|
||||
end
|
||||
echo -n '❯ '
|
||||
set_color $fish_color_normal
|
||||
end
|
||||
|
||||
|
@ -1,9 +1,14 @@
|
||||
function lean_left_prompt
|
||||
set -U leftPromptHeight 1
|
||||
|
||||
for item in lean_{$lean_left_prompt_items}
|
||||
set -l itemOutput (_$item)
|
||||
|
||||
if test -n "$itemOutput"
|
||||
echo -n $itemOutput' '
|
||||
echo -ne $itemOutput
|
||||
end
|
||||
if test $item = 'lean_newline'
|
||||
set -U leftPromptHeight (math $leftPromptHeight+1)
|
||||
end
|
||||
|
||||
set_color normal
|
||||
|
@ -1,13 +1,37 @@
|
||||
function lean_right_prompt
|
||||
set -l splitText (string split '\n' (_fetch_right_prompt_items))
|
||||
for thing in $splitText[1..-2]
|
||||
_print_at_end $thing
|
||||
end
|
||||
if test (count $splitText) -eq $leftPromptHeight
|
||||
set -g fishRightPromptRun $splitText[-1]
|
||||
else
|
||||
_print_at_end $splitText[-1]
|
||||
set -g fishRightPromptRun ''
|
||||
end
|
||||
echo
|
||||
end
|
||||
|
||||
function fish_right_prompt
|
||||
echo $fishRightPromptRun
|
||||
end
|
||||
|
||||
function _fetch_right_prompt_items
|
||||
echo -n ' '
|
||||
|
||||
for item in lean_{$lean_right_prompt_items}
|
||||
set -l itemOutput (_$item)
|
||||
|
||||
if test -n "$itemOutput"
|
||||
echo -n $itemOutput' '
|
||||
echo -n $itemOutput
|
||||
end
|
||||
|
||||
set_color normal
|
||||
end
|
||||
end
|
||||
|
||||
function _print_at_end -a text
|
||||
set -l startLocation (math $COLUMNS-(string length (lean_decolor $text)))
|
||||
echo -ne '\033['$startLocation'C'
|
||||
echo $text
|
||||
end
|
@ -1 +1 @@
|
||||
echo -n (lean_pwd)(lean_git_prompt)' '
|
||||
lean_left_prompt
|
Loading…
Reference in New Issue
Block a user