From c72a2b8447172778eafcdd42f40f92a313cc904e Mon Sep 17 00:00:00 2001 From: Ilan Cosman Date: Mon, 20 Apr 2020 20:35:56 -0700 Subject: [PATCH] Fix wizard --- functions/fish_prompt.fish | 28 ------- functions/lean_uninstall.fish | 2 + functions/lean_wizard.fish | 76 +++++++++---------- lean_theme/prompt_modules/2_newline | 1 - lean_theme/prompt_modules/3_1Line | 1 - lean_theme/prompt_modules/3_2Line | 17 ----- .../prompt_modules/fake_prompt/1_initial | 2 + .../prompt_modules/fake_prompt/2_newline | 1 + lean_theme/prompt_modules/fake_prompt/3_1Line | 1 + lean_theme/prompt_modules/fake_prompt/3_2Line | 11 +++ .../prompt_modules/{ => fake_prompt}/4_final | 2 +- .../{ => fish_prompt}/1_initial | 2 +- .../prompt_modules/fish_prompt/2_newline | 1 + lean_theme/prompt_modules/fish_prompt/3_1Line | 1 + lean_theme/prompt_modules/fish_prompt/3_2Line | 13 ++++ lean_theme/prompt_modules/fish_prompt/4_final | 9 +++ 16 files changed, 79 insertions(+), 89 deletions(-) delete mode 100644 functions/fish_prompt.fish delete mode 100644 lean_theme/prompt_modules/2_newline delete mode 100644 lean_theme/prompt_modules/3_1Line delete mode 100644 lean_theme/prompt_modules/3_2Line create mode 100644 lean_theme/prompt_modules/fake_prompt/1_initial create mode 100644 lean_theme/prompt_modules/fake_prompt/2_newline create mode 100644 lean_theme/prompt_modules/fake_prompt/3_1Line create mode 100644 lean_theme/prompt_modules/fake_prompt/3_2Line rename lean_theme/prompt_modules/{ => fake_prompt}/4_final (83%) rename lean_theme/prompt_modules/{ => fish_prompt}/1_initial (65%) create mode 100644 lean_theme/prompt_modules/fish_prompt/2_newline create mode 100644 lean_theme/prompt_modules/fish_prompt/3_1Line create mode 100644 lean_theme/prompt_modules/fish_prompt/3_2Line create mode 100644 lean_theme/prompt_modules/fish_prompt/4_final diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish deleted file mode 100644 index 6269de9..0000000 --- a/functions/fish_prompt.fish +++ /dev/null @@ -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 \ No newline at end of file diff --git a/functions/lean_uninstall.fish b/functions/lean_uninstall.fish index 692eb3f..5830902 100644 --- a/functions/lean_uninstall.fish +++ b/functions/lean_uninstall.fish @@ -7,6 +7,8 @@ function lean_uninstall rm "$__fish_config_dir/functions/lean*" # ---------------Erase Theme Variables--------------- + # --------------Prompt-------------- + set -l vars $vars lean_prompt_connection lean_prompt_connection_color # --------------Colors-------------- set -l vars $vars lean_color_green lean_color_light_blue lean_color_dark_blue lean_color_gold # --------------Timer-------------- diff --git a/functions/lean_wizard.fish b/functions/lean_wizard.fish index 7e8eaaa..b5cb618 100644 --- a/functions/lean_wizard.fish +++ b/functions/lean_wizard.fish @@ -4,11 +4,8 @@ function lean_wizard return 1 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 tempPrompt "$__fish_config_dir/lean_theme/temp_prompt.fish" set -g columns $COLUMNS set -g lines $LINES @@ -23,8 +20,8 @@ end function _setDefaults set -g newline true - set -g lean_prompt_connection " " - set -g lean_prompt_connection_color 6C6C6C + set -g fake_lean_prompt_connection " " + set -g fake_lean_prompt_connection_color 6C6C6C end function _promptHeight @@ -57,28 +54,25 @@ function _promptConnection _title "Prompt Connection" echo "(1) Disconnected" - _displayPrompt lean_prompt_connection " " + _displayPrompt fake_lean_prompt_connection " " echo "(2) Dotted" - _displayPrompt lean_prompt_connection "·" + _displayPrompt fake_lean_prompt_connection "·" echo "(3) Solid" - _displayPrompt lean_prompt_connection "─" + _displayPrompt fake_lean_prompt_connection "─" _displayRestartAndQuit switch (lean_user_ask "Choice" 1/2/3/r/q) case 1 - set -U lean_prompt_connection " " - set -g lean_prompt_connection " " + set -g fake_lean_prompt_connection " " _promptSpacing case 2 - set -U lean_prompt_connection "·" - set -g lean_prompt_connection "·" + set -g fake_lean_prompt_connection "·" _promptConnectionColor case 3 - set -U lean_prompt_connection "─" - set -g lean_prompt_connection "─" + set -g fake_lean_prompt_connection "─" _promptConnectionColor case r _begin @@ -92,35 +86,31 @@ function _promptConnectionColor _title "Connection Color" echo "(1) Lightest" - _displayPrompt lean_prompt_connection_color 808080 + _displayPrompt fake_lean_prompt_connection_color 808080 echo "(2) Light" - _displayPrompt lean_prompt_connection_color 6C6C6C + _displayPrompt fake_lean_prompt_connection_color 6C6C6C echo "(3) Dark" - _displayPrompt lean_prompt_connection_color 585858 + _displayPrompt fake_lean_prompt_connection_color 585858 echo "(4) Darkest" - _displayPrompt lean_prompt_connection_color 444444 + _displayPrompt fake_lean_prompt_connection_color 444444 _displayRestartAndQuit switch (lean_user_ask "Choice" 1/2/3/4/r/q) case 1 - set -U lean_prompt_connection_color 808080 - set -g lean_prompt_connection_color 808080 + set -g fake_lean_prompt_connection_color 808080 _promptSpacing case 2 - set -U lean_prompt_connection_color 6C6C6C - set -g lean_prompt_connection_color 6C6C6C + set -g fake_lean_prompt_connection_color 6C6C6C _promptSpacing case 3 - set -U lean_prompt_connection_color 585858 - set -g lean_prompt_connection_color 585858 + set -g fake_lean_prompt_connection_color 585858 _promptSpacing case 4 - set -U lean_prompt_connection_color 444444 - set -g lean_prompt_connection_color 444444 + set -g fake_lean_prompt_connection_color 444444 _promptSpacing case r _begin @@ -157,8 +147,16 @@ function _promptSpacing end end -function _assemble_prompt - echo -n >$tempPrompt +function _assemblePrompt --argument-names which + 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 if test $newline = "true" @@ -169,7 +167,8 @@ function _assemble_prompt end function _addMod --argument-names file - cat "$moduleDir/$file" >>$tempPrompt + cat "$moduleDir/$file" >>$promptDir + printf "\n\n" >>$promptDir end function _title --argument-names title @@ -184,9 +183,9 @@ end function _displayPrompt --argument-names var_name var_value set -g $var_name $var_value - _assemble_prompt - source $tempPrompt - fish_prompt + _assemblePrompt fake + source $promptDir + fake_prompt echo echo end @@ -197,16 +196,13 @@ function _displayRestartAndQuit end function _quit - set -U lean_timer_duration $leanTimerDurationSave source $fishPrompt - fish_prompt clear end function _finish - set -U lean_timer_duration $leanTimerDurationSave - _assemble_prompt - cat $tempPrompt >$fishPrompt - source $fishPrompt - clear + _assemblePrompt fish + set -U lean_prompt_connection $fake_lean_prompt_connection + set -U lean_prompt_connection_color $fake_lean_prompt_connection_color + _quit end \ No newline at end of file diff --git a/lean_theme/prompt_modules/2_newline b/lean_theme/prompt_modules/2_newline deleted file mode 100644 index c6192e0..0000000 --- a/lean_theme/prompt_modules/2_newline +++ /dev/null @@ -1 +0,0 @@ - echo diff --git a/lean_theme/prompt_modules/3_1Line b/lean_theme/prompt_modules/3_1Line deleted file mode 100644 index c12525d..0000000 --- a/lean_theme/prompt_modules/3_1Line +++ /dev/null @@ -1 +0,0 @@ - echo -n (lean_pwd)(lean_git_prompt)" " diff --git a/lean_theme/prompt_modules/3_2Line b/lean_theme/prompt_modules/3_2Line deleted file mode 100644 index 0106bf5..0000000 --- a/lean_theme/prompt_modules/3_2Line +++ /dev/null @@ -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)" " diff --git a/lean_theme/prompt_modules/fake_prompt/1_initial b/lean_theme/prompt_modules/fake_prompt/1_initial new file mode 100644 index 0000000..91863c6 --- /dev/null +++ b/lean_theme/prompt_modules/fake_prompt/1_initial @@ -0,0 +1,2 @@ +function fake_prompt --description 'Write out the prompt' + set -l lastExitCode $status \ No newline at end of file diff --git a/lean_theme/prompt_modules/fake_prompt/2_newline b/lean_theme/prompt_modules/fake_prompt/2_newline new file mode 100644 index 0000000..c12010d --- /dev/null +++ b/lean_theme/prompt_modules/fake_prompt/2_newline @@ -0,0 +1 @@ + echo \ No newline at end of file diff --git a/lean_theme/prompt_modules/fake_prompt/3_1Line b/lean_theme/prompt_modules/fake_prompt/3_1Line new file mode 100644 index 0000000..50dde60 --- /dev/null +++ b/lean_theme/prompt_modules/fake_prompt/3_1Line @@ -0,0 +1 @@ + echo -n (lean_pwd)(lean_git_prompt)" " \ No newline at end of file diff --git a/lean_theme/prompt_modules/fake_prompt/3_2Line b/lean_theme/prompt_modules/fake_prompt/3_2Line new file mode 100644 index 0000000..aed8145 --- /dev/null +++ b/lean_theme/prompt_modules/fake_prompt/3_2Line @@ -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)" " \ No newline at end of file diff --git a/lean_theme/prompt_modules/4_final b/lean_theme/prompt_modules/fake_prompt/4_final similarity index 83% rename from lean_theme/prompt_modules/4_final rename to lean_theme/prompt_modules/fake_prompt/4_final index 1c8748d..a3bea46 100644 --- a/lean_theme/prompt_modules/4_final +++ b/lean_theme/prompt_modules/fake_prompt/4_final @@ -1,5 +1,5 @@ # Prompt character - if test $last_status -eq 0 + if test $lastExitCode -eq 0 set_color $lean_color_green else set_color $fish_color_error diff --git a/lean_theme/prompt_modules/1_initial b/lean_theme/prompt_modules/fish_prompt/1_initial similarity index 65% rename from lean_theme/prompt_modules/1_initial rename to lean_theme/prompt_modules/fish_prompt/1_initial index 3d6ef42..8056ebd 100644 --- a/lean_theme/prompt_modules/1_initial +++ b/lean_theme/prompt_modules/fish_prompt/1_initial @@ -1,2 +1,2 @@ function fish_prompt --description 'Write out the prompt' - set -l last_status $status + set -l lastExitCode $status \ No newline at end of file diff --git a/lean_theme/prompt_modules/fish_prompt/2_newline b/lean_theme/prompt_modules/fish_prompt/2_newline new file mode 100644 index 0000000..c12010d --- /dev/null +++ b/lean_theme/prompt_modules/fish_prompt/2_newline @@ -0,0 +1 @@ + echo \ No newline at end of file diff --git a/lean_theme/prompt_modules/fish_prompt/3_1Line b/lean_theme/prompt_modules/fish_prompt/3_1Line new file mode 100644 index 0000000..50dde60 --- /dev/null +++ b/lean_theme/prompt_modules/fish_prompt/3_1Line @@ -0,0 +1 @@ + echo -n (lean_pwd)(lean_git_prompt)" " \ No newline at end of file diff --git a/lean_theme/prompt_modules/fish_prompt/3_2Line b/lean_theme/prompt_modules/fish_prompt/3_2Line new file mode 100644 index 0000000..6d7e209 --- /dev/null +++ b/lean_theme/prompt_modules/fish_prompt/3_2Line @@ -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)" " \ No newline at end of file diff --git a/lean_theme/prompt_modules/fish_prompt/4_final b/lean_theme/prompt_modules/fish_prompt/4_final new file mode 100644 index 0000000..a3bea46 --- /dev/null +++ b/lean_theme/prompt_modules/fish_prompt/4_final @@ -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 \ No newline at end of file