Increase uninstall specificity, protect user files

This commit is contained in:
Ilan Cosman 2020-04-25 14:52:39 -07:00
parent 54c6d7a0d3
commit 75441062c7
5 changed files with 33 additions and 23 deletions

View File

@ -1,3 +1,4 @@
# Created by lean_wizard
function fish_prompt --description 'Write out the prompt' function fish_prompt --description 'Write out the prompt'
set -l lastExitCode $status set -l lastExitCode $status

View File

@ -3,33 +3,41 @@ function lean_uninstall
echo "Uninstalling lean theme..." echo "Uninstalling lean theme..."
# ------------------Remove Files------------------ # ------------------Remove Files------------------
rm "$__fish_config_dir/functions/fish_prompt.fish"
rm "$__fish_config_dir/functions/lean"*
rm -r "$__fish_config_dir/lean_theme" rm -r "$__fish_config_dir/lean_theme"
set -l fishPromptFirstLine (head -n 1 "$__fish_config_dir/functions/fish_prompt.fish")
if test $fishPromptFirstLine = "# Created by lean_wizard"
rm "$__fish_config_dir/functions/fish_prompt.fish"
end
set -l leanFunctions git_prompt load_right_prompt_modules pwd right_prompt uninstall wizard
for func in $leanFunctions
rm "$__fish_config_dir/functions/lean_$func.fish"
end
# --------------Erase Theme Variables-------------- # --------------Erase Theme Variables--------------
# --------------Prompt-------------- # --------------Prompt--------------
set -a vars lean_prompt_connection lean_prompt_connection_color set -a rmVars lean_prompt_connection lean_prompt_connection_color
# --------------Colors-------------- # --------------Colors--------------
set -a vars lean_color_{green, light_blue, dark_blue, gold} set -a rmVars lean_color_{green, light_blue, dark_blue, gold}
# ---------------Pwd--------------- # ---------------Pwd---------------
set -a vars fish_prompt_pwd_dir_length lean_shorten_pwd_margin set -a rmVars fish_prompt_pwd_dir_length lean_shorten_pwd_margin
# ------------Git prompt------------ # ------------Git prompt------------
set -a vars __fish_git_prompt_{show_informative_status, showstashstate} set -a rmVars __fish_git_prompt_{show_informative_status, showstashstate}
# -------Symbols------- # -------Symbols-------
set -a vars __fish_git_prompt_char_{stateseparator, cleanstate, upstream_ahead, upstream_behind} set -a rmVars __fish_git_prompt_char_{stateseparator, cleanstate, upstream_ahead, upstream_behind}
set -a vars __fish_git_prompt_char_{stagedstate, dirtystate, untrackedfiles, stashstate} set -a rmVars __fish_git_prompt_char_{stagedstate, dirtystate, untrackedfiles, stashstate}
# --------Colors-------- # --------Colors--------
set -a vars __fish_git_prompt_color_{branch, upstream, stagedstate, dirtystate, untrackedfiles, stashstate} set -a rmVars __fish_git_prompt_color_{branch, upstream, stagedstate, dirtystate, untrackedfiles, stashstate}
# ----------------Right Prompt Modules---------------- # ----------------Right Prompt Modules----------------
set -a vars lean_right_prompt_modules set -a rmVars lean_right_prompt_modules
# --------------Timer-------------- # --------------Timer--------------
set -a vars lean_timer_{color, decimals, duration} set -a rmVars lean_timer_{color, decimals, duration}
# ---------------SSH--------------- # ---------------SSH---------------
set -a vars lean_ssh_color set -a rmVars lean_ssh_color
for var in $vars for var in $rmVars
set -e $var set -e $var
end end
@ -41,7 +49,7 @@ function lean_uninstall
end end
end end
function _user_confirm_defaultNo --argument-names question function _user_confirm_defaultNo -a question
while true while true
read -P "$question [y/N] " input read -P "$question [y/N] " input

View File

@ -149,10 +149,10 @@ function _promptSpacing
end end
end end
function _assemblePrompt --argument-names which function _assemblePrompt -a whichPrompt
set -g moduleDir "$__fish_config_dir/lean_theme/prompt_modules/$which""_prompt" set -g moduleDir "$__fish_config_dir/lean_theme/prompt_modules/$whichPrompt""_prompt"
if test $which = "fish" if test $whichPrompt = "fish"
set -g promptDir "$__fish_config_dir/functions/fish_prompt.fish" set -g promptDir "$__fish_config_dir/functions/fish_prompt.fish"
else else
set -g promptDir "$__fish_config_dir/lean_theme/temp_prompt.fish" set -g promptDir "$__fish_config_dir/lean_theme/temp_prompt.fish"
@ -173,12 +173,12 @@ function _assemblePrompt --argument-names which
end end
end end
function _addMod --argument-names file function _addMod -a file
cat "$moduleDir/$file.fish" >>$promptDir cat "$moduleDir/$file.fish" >>$promptDir
printf "\n\n" >>$promptDir printf "\n\n" >>$promptDir
end end
function _title --argument-names title function _title -a title
set -l midCols (math $columns/2) set -l midCols (math $columns/2)
set -l midTitle (math (string length $title)/2) set -l midTitle (math (string length $title)/2)
@ -190,13 +190,13 @@ function _title --argument-names title
set_color normal set_color normal
end end
function _option --argument-names symbol text function _option -a symbol text
set_color -o set_color -o
echo "($symbol) $text" echo "($symbol) $text"
set_color normal set_color normal
end end
function _displayPrompt --argument-names var_name var_value function _displayPrompt -a var_name var_value
set -g $var_name $var_value set -g $var_name $var_value
_assemblePrompt fake _assemblePrompt fake
source $promptDir source $promptDir
@ -236,7 +236,7 @@ function _finish
_quit _quit
end end
function _menu --argument-names question options function _menu -a question options
set -l optionList (string split "/" $options) set -l optionList (string split "/" $options)
set -l bold (set_color -o) set -l bold (set_color -o)
set -l norm (set_color normal) set -l norm (set_color normal)

View File

@ -71,7 +71,7 @@ function lean_install
end end
end end
function _user_confirm_defaultYes --argument-names question function _user_confirm_defaultYes -a question
while true while true
read -P "$question [Y/n] " input read -P "$question [Y/n] " input

View File

@ -1,2 +1,3 @@
# Created by lean_wizard
function fish_prompt --description 'Write out the prompt' function fish_prompt --description 'Write out the prompt'
set -l lastExitCode $status set -l lastExitCode $status