Fix wizard

This commit is contained in:
Ilan Cosman 2020-04-20 20:35:56 -07:00
parent 3d225378b9
commit c72a2b8447
16 changed files with 79 additions and 89 deletions

View File

@ -1,28 +0,0 @@
function fish_prompt --description 'Write out the prompt'
set -l last_status $status
if test (math $CMD_DURATION/1000) -gt $lean_timer_duration
for i in (seq (math $COLUMNS-(string length (echo -n " "(math --scale=$lean_timer_decimals $CMD_DURATION/1000)"s"))-1))
set_color $lean_prompt_connection_color
echo -n $lean_prompt_connection
set_color $fish_color_normal
end
set_color $lean_timer_color
echo -n " "(math --scale=$lean_timer_decimals $CMD_DURATION/1000)"s"
set_color $fish_color_normal
else
for i in (seq (math $COLUMNS-1))
set_color $lean_prompt_connection_color
echo -n $lean_prompt_connection
set_color $fish_color_normal
end
end
echo -e "\r"(lean_pwd)(lean_git_prompt)" "
# Prompt character
if test $last_status -eq 0
set_color $lean_green
else
set_color $fish_color_error
end
echo -n " "
set_color $fish_color_normal
end

View File

@ -7,6 +7,8 @@ function lean_uninstall
rm "$__fish_config_dir/functions/lean*" rm "$__fish_config_dir/functions/lean*"
# ---------------Erase Theme Variables--------------- # ---------------Erase Theme Variables---------------
# --------------Prompt--------------
set -l vars $vars lean_prompt_connection lean_prompt_connection_color
# --------------Colors-------------- # --------------Colors--------------
set -l vars $vars lean_color_green lean_color_light_blue lean_color_dark_blue lean_color_gold set -l vars $vars lean_color_green lean_color_light_blue lean_color_dark_blue lean_color_gold
# --------------Timer-------------- # --------------Timer--------------

View File

@ -4,11 +4,8 @@ function lean_wizard
return 1 return 1
end end
set -g leanTimerDurationSave $lean_timer_duration
set -U lean_timer_duration 0
set -g tempPrompt "$__fish_config_dir/lean_theme/temp_prompt.fish"
set -g moduleDir "$__fish_config_dir/lean_theme/prompt_modules"
set -g fishPrompt "$__fish_config_dir/functions/fish_prompt.fish" set -g fishPrompt "$__fish_config_dir/functions/fish_prompt.fish"
set -g tempPrompt "$__fish_config_dir/lean_theme/temp_prompt.fish"
set -g columns $COLUMNS set -g columns $COLUMNS
set -g lines $LINES set -g lines $LINES
@ -23,8 +20,8 @@ end
function _setDefaults function _setDefaults
set -g newline true set -g newline true
set -g lean_prompt_connection " " set -g fake_lean_prompt_connection " "
set -g lean_prompt_connection_color 6C6C6C set -g fake_lean_prompt_connection_color 6C6C6C
end end
function _promptHeight function _promptHeight
@ -57,28 +54,25 @@ function _promptConnection
_title "Prompt Connection" _title "Prompt Connection"
echo "(1) Disconnected" echo "(1) Disconnected"
_displayPrompt lean_prompt_connection " " _displayPrompt fake_lean_prompt_connection " "
echo "(2) Dotted" echo "(2) Dotted"
_displayPrompt lean_prompt_connection "·" _displayPrompt fake_lean_prompt_connection "·"
echo "(3) Solid" echo "(3) Solid"
_displayPrompt lean_prompt_connection "─" _displayPrompt fake_lean_prompt_connection "─"
_displayRestartAndQuit _displayRestartAndQuit
switch (lean_user_ask "Choice" 1/2/3/r/q) switch (lean_user_ask "Choice" 1/2/3/r/q)
case 1 case 1
set -U lean_prompt_connection " " set -g fake_lean_prompt_connection " "
set -g lean_prompt_connection " "
_promptSpacing _promptSpacing
case 2 case 2
set -U lean_prompt_connection "·" set -g fake_lean_prompt_connection "·"
set -g lean_prompt_connection "·"
_promptConnectionColor _promptConnectionColor
case 3 case 3
set -U lean_prompt_connection "─" set -g fake_lean_prompt_connection "─"
set -g lean_prompt_connection "─"
_promptConnectionColor _promptConnectionColor
case r case r
_begin _begin
@ -92,35 +86,31 @@ function _promptConnectionColor
_title "Connection Color" _title "Connection Color"
echo "(1) Lightest" echo "(1) Lightest"
_displayPrompt lean_prompt_connection_color 808080 _displayPrompt fake_lean_prompt_connection_color 808080
echo "(2) Light" echo "(2) Light"
_displayPrompt lean_prompt_connection_color 6C6C6C _displayPrompt fake_lean_prompt_connection_color 6C6C6C
echo "(3) Dark" echo "(3) Dark"
_displayPrompt lean_prompt_connection_color 585858 _displayPrompt fake_lean_prompt_connection_color 585858
echo "(4) Darkest" echo "(4) Darkest"
_displayPrompt lean_prompt_connection_color 444444 _displayPrompt fake_lean_prompt_connection_color 444444
_displayRestartAndQuit _displayRestartAndQuit
switch (lean_user_ask "Choice" 1/2/3/4/r/q) switch (lean_user_ask "Choice" 1/2/3/4/r/q)
case 1 case 1
set -U lean_prompt_connection_color 808080 set -g fake_lean_prompt_connection_color 808080
set -g lean_prompt_connection_color 808080
_promptSpacing _promptSpacing
case 2 case 2
set -U lean_prompt_connection_color 6C6C6C set -g fake_lean_prompt_connection_color 6C6C6C
set -g lean_prompt_connection_color 6C6C6C
_promptSpacing _promptSpacing
case 3 case 3
set -U lean_prompt_connection_color 585858 set -g fake_lean_prompt_connection_color 585858
set -g lean_prompt_connection_color 585858
_promptSpacing _promptSpacing
case 4 case 4
set -U lean_prompt_connection_color 444444 set -g fake_lean_prompt_connection_color 444444
set -g lean_prompt_connection_color 444444
_promptSpacing _promptSpacing
case r case r
_begin _begin
@ -157,8 +147,16 @@ function _promptSpacing
end end
end end
function _assemble_prompt function _assemblePrompt --argument-names which
echo -n >$tempPrompt set -g moduleDir "$__fish_config_dir/lean_theme/prompt_modules/$which""_prompt"
if test $which = "fish"
set -g promptDir "$__fish_config_dir/functions/fish_prompt.fish"
else
set -g promptDir "$__fish_config_dir/lean_theme/temp_prompt.fish"
end
echo -n >$promptDir
_addMod 1_initial _addMod 1_initial
if test $newline = "true" if test $newline = "true"
@ -169,7 +167,8 @@ function _assemble_prompt
end end
function _addMod --argument-names file function _addMod --argument-names file
cat "$moduleDir/$file" >>$tempPrompt cat "$moduleDir/$file" >>$promptDir
printf "\n\n" >>$promptDir
end end
function _title --argument-names title function _title --argument-names title
@ -184,9 +183,9 @@ 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
_assemble_prompt _assemblePrompt fake
source $tempPrompt source $promptDir
fish_prompt fake_prompt
echo echo
echo echo
end end
@ -197,16 +196,13 @@ function _displayRestartAndQuit
end end
function _quit function _quit
set -U lean_timer_duration $leanTimerDurationSave
source $fishPrompt source $fishPrompt
fish_prompt
clear clear
end end
function _finish function _finish
set -U lean_timer_duration $leanTimerDurationSave _assemblePrompt fish
_assemble_prompt set -U lean_prompt_connection $fake_lean_prompt_connection
cat $tempPrompt >$fishPrompt set -U lean_prompt_connection_color $fake_lean_prompt_connection_color
source $fishPrompt _quit
clear
end end

View File

@ -1 +0,0 @@
echo

View File

@ -1 +0,0 @@
echo -n (lean_pwd)(lean_git_prompt)" "

View File

@ -1,17 +0,0 @@
if test (math $CMD_DURATION/1000) -gt $lean_timer_duration
for i in (seq (math $COLUMNS-(string length (echo -n " "(math --scale=$lean_timer_decimals $CMD_DURATION/1000)"s"))-1))
set_color $lean_prompt_connection_color
echo -n $lean_prompt_connection
set_color $fish_color_normal
end
set_color $lean_timer_color
echo -n " "(math --scale=$lean_timer_decimals $CMD_DURATION/1000)"s"
set_color $fish_color_normal
else
for i in (seq (math $COLUMNS-1))
set_color $lean_prompt_connection_color
echo -n $lean_prompt_connection
set_color $fish_color_normal
end
end
echo -e "\r"(lean_pwd)(lean_git_prompt)" "

View File

@ -0,0 +1,2 @@
function fake_prompt --description 'Write out the prompt'
set -l lastExitCode $status

View File

@ -0,0 +1 @@
echo

View File

@ -0,0 +1 @@
echo -n (lean_pwd)(lean_git_prompt)" "

View File

@ -0,0 +1,11 @@
set_color $fake_lean_prompt_connection_color
printf "%.s$fake_lean_prompt_connection" (seq (math $COLUMNS-1))
set_color $fish_color_normal
set -l timerOutput " 5s "
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
echo -e "\r"(lean_pwd)(lean_git_prompt)" "

View File

@ -1,5 +1,5 @@
# Prompt character # Prompt character
if test $last_status -eq 0 if test $lastExitCode -eq 0
set_color $lean_color_green set_color $lean_color_green
else else
set_color $fish_color_error set_color $fish_color_error

View File

@ -1,2 +1,2 @@
function fish_prompt --description 'Write out the prompt' function fish_prompt --description 'Write out the prompt'
set -l last_status $status set -l lastExitCode $status

View File

@ -0,0 +1 @@
echo

View File

@ -0,0 +1 @@
echo -n (lean_pwd)(lean_git_prompt)" "

View File

@ -0,0 +1,13 @@
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,9 @@
# Prompt character
if test $lastExitCode -eq 0
set_color $lean_color_green
else
set_color $fish_color_error
end
echo -n " "
set_color $fish_color_normal
end