Add right prompt

This commit is contained in:
Ilan Cosman 2020-04-21 11:52:24 -07:00
parent c72a2b8447
commit 48ea32ffba
19 changed files with 87 additions and 28 deletions

View File

@ -0,0 +1,11 @@
function lean_load_right_prompt_modules
set -g lean_right_prompt_modules_order leanTimer
set -g leanTimer (_lean_timer)
end
function _lean_timer
if test (math $CMD_DURATION/1000) -gt $lean_timer_duration
set -l leanTimerOutput (math --scale=$lean_timer_decimals $CMD_DURATION/1000)"s"
echo -n $leanTimerOutput
end
end

View File

@ -0,0 +1,7 @@
function lean_right_prompt
set -l n (set_color normal)
set -l ltc (set_color $lean_timer_color)
set -l leanRightPrompt " "$ltc$leanTimer$n" "
echo $leanRightPrompt
end

View File

@ -27,10 +27,10 @@ end
function _promptHeight function _promptHeight
_title "Prompt Height" _title "Prompt Height"
echo "(1) One line" _option 1 "One line"
_displayPrompt prompt_height 1 _displayPrompt prompt_height 1
echo "(2) Two lines" _option 2 "Two lines"
_displayPrompt prompt_height 2 _displayPrompt prompt_height 2
_displayRestartAndQuit _displayRestartAndQuit
@ -38,7 +38,7 @@ function _promptHeight
switch (lean_user_ask "Choice" 1/2/r/q) switch (lean_user_ask "Choice" 1/2/r/q)
case 1 case 1
set -g prompt_height 1 set -g prompt_height 1
_finish _promptSpacing
case 2 case 2
set -g prompt_height 2 set -g prompt_height 2
_promptConnection _promptConnection
@ -53,13 +53,13 @@ function _promptConnection
clear clear
_title "Prompt Connection" _title "Prompt Connection"
echo "(1) Disconnected" _option 1 "Disconnected"
_displayPrompt fake_lean_prompt_connection " " _displayPrompt fake_lean_prompt_connection " "
echo "(2) Dotted" _option 2 "Dotted"
_displayPrompt fake_lean_prompt_connection "·" _displayPrompt fake_lean_prompt_connection "·"
echo "(3) Solid" _option 3 "Solid"
_displayPrompt fake_lean_prompt_connection "─" _displayPrompt fake_lean_prompt_connection "─"
_displayRestartAndQuit _displayRestartAndQuit
@ -85,16 +85,16 @@ function _promptConnectionColor
clear clear
_title "Connection Color" _title "Connection Color"
echo "(1) Lightest" _option 1 "Lightest"
_displayPrompt fake_lean_prompt_connection_color 808080 _displayPrompt fake_lean_prompt_connection_color 808080
echo "(2) Light" _option 2 "Light"
_displayPrompt fake_lean_prompt_connection_color 6C6C6C _displayPrompt fake_lean_prompt_connection_color 6C6C6C
echo "(3) Dark" _option 3 "Dark"
_displayPrompt fake_lean_prompt_connection_color 585858 _displayPrompt fake_lean_prompt_connection_color 585858
echo "(4) Darkest" _option 4 "Darkest"
_displayPrompt fake_lean_prompt_connection_color 444444 _displayPrompt fake_lean_prompt_connection_color 444444
_displayRestartAndQuit _displayRestartAndQuit
@ -123,12 +123,14 @@ function _promptSpacing
clear clear
_title "Prompt Spacing" _title "Prompt Spacing"
echo "(1) Compact" _option 1 "Compact"
_displayPrompt newline false _displayPrompt newline false
echo -ne "\r\033[1A"
_displayPrompt newline false _displayPrompt newline false
echo "(2) Sparse" _option 2 "Sparse"
_displayPrompt newline true _displayPrompt newline true
echo -ne "\r\033[1A"
_displayPrompt newline true _displayPrompt newline true
_displayRestartAndQuit _displayRestartAndQuit
@ -164,10 +166,16 @@ function _assemblePrompt --argument-names which
end end
_addMod "3_"$prompt_height"Line" _addMod "3_"$prompt_height"Line"
_addMod 4_final _addMod 4_final
if test $prompt_height -eq 1
# breakpoint
_addMod 5_rightPrompt
else
_addMod 5_rPromptNoColor
end
end end
function _addMod --argument-names file function _addMod --argument-names file
cat "$moduleDir/$file" >>$promptDir cat "$moduleDir/$file.fish" >>$promptDir
printf "\n\n" >>$promptDir printf "\n\n" >>$promptDir
end end
@ -178,13 +186,22 @@ function _title --argument-names title
for i in (seq (math $midCols-$midTitle)) for i in (seq (math $midCols-$midTitle))
echo -n " " echo -n " "
end end
set_color -o
echo $title echo $title
set_color normal
end
function _option --argument-names number text
set_color -o
echo "($number) $text"
set_color normal
end end
function _displayPrompt --argument-names var_name var_value function _displayPrompt --argument-names var_name var_value
set -g $var_name $var_value set -g $var_name $var_value
_assemblePrompt fake _assemblePrompt fake
source $promptDir source $promptDir
fake_prompt fake_prompt
echo echo
echo echo

View File

@ -55,6 +55,6 @@ function lean_install
source "$__fish_config_dir/functions/fish_prompt.fish" source "$__fish_config_dir/functions/fish_prompt.fish"
set_color $lean_color_green set_color $lean_color_green
echo "Lean theme installed!" echo "Lean theme installed! Run 'lean_wizard' to configure your prompt."
set_color $fish_color_normal set_color $fish_color_normal
end end

View File

@ -8,4 +8,14 @@
set_color $lean_timer_color set_color $lean_timer_color
echo -n $timerOutput echo -n $timerOutput
set_color $fish_color_normal set_color $fish_color_normal
echo -e "\r"(lean_pwd)(lean_git_prompt)" "
echo -ne "\r"
set -l Lblue (set_color -o $lean_color_light_blue)
set -l Dblue (set_color $lean_color_dark_blue)
set -l n (set_color $fish_color_normal)
echo -n $Lblue"~"$n$Dblue"/"$n$Lblue"src "$n
set_color $lean_color_green
echo "master "
set_color $fish_color_normal

View File

@ -0,0 +1,4 @@
function _lean_right_prompt_nocolor
set -l leanRightPromptDecolored " "$leanTimer" "
echo $leanRightPromptDecolored
end

View File

@ -0,0 +1,5 @@
function fish_right_prompt
set_color $lean_timer_color
echo " 5s "
set_color $fish_color_normal
end

View File

@ -1,13 +0,0 @@
set_color $lean_prompt_connection_color
printf "%.s$lean_prompt_connection" (seq (math $COLUMNS-1))
set_color $fish_color_normal
if test (math $CMD_DURATION/1000) -gt $lean_timer_duration
set -l timerOutput " "(math --scale=$lean_timer_decimals $CMD_DURATION/1000)"s "
set -l timerStartLocation (math $COLUMNS-(string length $timerOutput))
printf "\r\033["$timerStartLocation"C"
set_color $lean_timer_color
echo -n $timerOutput
set_color $fish_color_normal
end
echo -e "\r"(lean_pwd)(lean_git_prompt)" "

View File

@ -0,0 +1,10 @@
set_color $lean_prompt_connection_color
printf "%.s$lean_prompt_connection" (seq (math $COLUMNS-1))
set_color $fish_color_normal
lean_load_right_prompt_modules
set -l leanRightPromptStartLocation (math $COLUMNS-(string length (_lean_right_prompt_nocolor)))
printf "\r\033["$leanRightPromptStartLocation"C"
echo -n (lean_right_prompt)
echo -e "\r"(lean_pwd)(lean_git_prompt)" "

View File

@ -0,0 +1,4 @@
function _lean_right_prompt_nocolor
set -l leanRightPromptDecolored " "$leanTimer" "
echo $leanRightPromptDecolored
end

View File

@ -0,0 +1,4 @@
function fish_right_prompt
lean_load_right_prompt_modules
lean_right_prompt
end