mirror of
https://github.com/IlanCosman/tide.git
synced 2024-12-23 12:03:48 +03:00
Add user_confirm function
This commit is contained in:
parent
4de13ecbb4
commit
3e0c70b9a4
@ -1,46 +1,40 @@
|
||||
function lean_uninstall
|
||||
while true
|
||||
read -l -P 'Uninstall lean theme? [y/N] ' confirm
|
||||
if user_confirm "Unininstall lean theme?" y/N
|
||||
echo "Uninstalling lean theme..."
|
||||
|
||||
switch $confirm
|
||||
case Y y
|
||||
echo "Uninstalling lean theme..."
|
||||
# ------------------Remove Functions------------------
|
||||
set fns fish_prompt lean_pwd lean_git_prompt lean_uninstall
|
||||
set fishFnsDir "$__fish_config_dir/functions"
|
||||
|
||||
# ------------------Remove Functions------------------
|
||||
set fns fish_prompt lean_pwd lean_git_prompt lean_uninstall
|
||||
set fishFnsDir "$__fish_config_dir/functions"
|
||||
|
||||
for fn in $fns
|
||||
rm "$fishFnsDir/$fn.fish"
|
||||
end
|
||||
|
||||
# ---------------Erase Theme Variables---------------
|
||||
# --------------Colors--------------
|
||||
set vars $vars lean_green lean_light_blue lean_dark_blue lean_gold
|
||||
# ---------------Pwd---------------
|
||||
set vars $vars fish_prompt_pwd_dir_length lean_shorten_pwd_margin
|
||||
# ------------Git prompt------------
|
||||
set vars $vars __fish_git_prompt_show_informative_status __fish_git_prompt_showstashstate
|
||||
# -------Symbols-------
|
||||
set vars $vars __fish_git_prompt_char_stateseparator __fish_git_prompt_char_cleanstate
|
||||
set vars $vars __fish_git_prompt_char_upstream_ahead __fish_git_prompt_char_upstream_behind
|
||||
set vars $vars __fish_git_prompt_char_stagedstate __fish_git_prompt_char_dirtystate
|
||||
set vars $vars __fish_git_prompt_char_untrackedfiles __fish_git_prompt_char_stashstate
|
||||
# --------Colors--------
|
||||
set vars $vars __fish_git_prompt_color_branch __fish_git_prompt_color_upstream
|
||||
set vars $vars __fish_git_prompt_color_stagedstate __fish_git_prompt_color_dirtystate
|
||||
set vars $vars __fish_git_prompt_color_untrackedfiles __fish_git_prompt_color_stashstate
|
||||
|
||||
for var in $vars
|
||||
set -e $var
|
||||
end
|
||||
|
||||
echo "Lean theme uninstalled. Exiting fish."
|
||||
sleep 1
|
||||
exit
|
||||
case N n ''
|
||||
echo "Aborted uninstall."
|
||||
break
|
||||
for fn in $fns
|
||||
rm "$fishFnsDir/$fn.fish"
|
||||
end
|
||||
|
||||
# ---------------Erase Theme Variables---------------
|
||||
# --------------Colors--------------
|
||||
set vars $vars lean_green lean_light_blue lean_dark_blue lean_gold
|
||||
# ---------------Pwd---------------
|
||||
set vars $vars fish_prompt_pwd_dir_length lean_shorten_pwd_margin
|
||||
# ------------Git prompt------------
|
||||
set vars $vars __fish_git_prompt_show_informative_status __fish_git_prompt_showstashstate
|
||||
# -------Symbols-------
|
||||
set vars $vars __fish_git_prompt_char_stateseparator __fish_git_prompt_char_cleanstate
|
||||
set vars $vars __fish_git_prompt_char_upstream_ahead __fish_git_prompt_char_upstream_behind
|
||||
set vars $vars __fish_git_prompt_char_stagedstate __fish_git_prompt_char_dirtystate
|
||||
set vars $vars __fish_git_prompt_char_untrackedfiles __fish_git_prompt_char_stashstate
|
||||
# --------Colors--------
|
||||
set vars $vars __fish_git_prompt_color_branch __fish_git_prompt_color_upstream
|
||||
set vars $vars __fish_git_prompt_color_stagedstate __fish_git_prompt_color_dirtystate
|
||||
set vars $vars __fish_git_prompt_color_untrackedfiles __fish_git_prompt_color_stashstate
|
||||
|
||||
for var in $vars
|
||||
set -e $var
|
||||
end
|
||||
|
||||
echo "Lean theme uninstalled. Exiting fish."
|
||||
sleep 1
|
||||
exit
|
||||
else
|
||||
echo "Aborted uninstall."
|
||||
end
|
||||
end
|
23
functions/user_confirm.fish
Normal file
23
functions/user_confirm.fish
Normal file
@ -0,0 +1,23 @@
|
||||
function user_confirm
|
||||
set -l question $argv[1]
|
||||
set -l rule $argv[2]
|
||||
set -l splitRule (string split "/" $rule)
|
||||
|
||||
while true
|
||||
read -P "$question [$rule] " confirm
|
||||
|
||||
switch $confirm
|
||||
case Y y Yes yes
|
||||
return 0
|
||||
case N n No no
|
||||
return 1
|
||||
case ''
|
||||
if test (string sub -l 1 $splitRule[1]) = "Y"
|
||||
return 0
|
||||
end
|
||||
if test (string sub -l 1 $splitRule[2]) = "N"
|
||||
return 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,7 +1,7 @@
|
||||
echo "Installing lean theme..."
|
||||
|
||||
# -----------------Download Functions-----------------
|
||||
set fns fish_prompt lean_pwd lean_git_prompt lean_uninstall
|
||||
set fns fish_prompt lean_git_prompt lean_pwd lean_uninstall user_confirm
|
||||
set fishFnsDir "$__fish_config_dir/functions"
|
||||
set ghubFnsDir "https://raw.githubusercontent.com/IlanCosman/lean/master/functions"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user