mirror of
https://github.com/IlanCosman/tide.git
synced 2024-11-15 09:07:40 +03:00
Rm lean_user_ask in favor of situation specific menus
This commit is contained in:
parent
dea611ca06
commit
be227de5a7
@ -1,5 +1,5 @@
|
|||||||
function lean_uninstall
|
function lean_uninstall
|
||||||
if lean_user_ask "Unininstall lean theme?" y/N
|
if _user_confirm_defaultNo "Unininstall lean theme?"
|
||||||
echo "Uninstalling lean theme..."
|
echo "Uninstalling lean theme..."
|
||||||
|
|
||||||
# ------------------Remove Files------------------
|
# ------------------Remove Files------------------
|
||||||
@ -39,3 +39,18 @@ function lean_uninstall
|
|||||||
echo "Aborted uninstall."
|
echo "Aborted uninstall."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function _user_confirm_defaultNo --argument-names question
|
||||||
|
while true
|
||||||
|
read -P "$question [y/N] " input
|
||||||
|
|
||||||
|
switch $input
|
||||||
|
case y Y yes Yes
|
||||||
|
return 0
|
||||||
|
case n N no No
|
||||||
|
return 1
|
||||||
|
case ''
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,36 +0,0 @@
|
|||||||
function lean_user_ask --argument-names question options
|
|
||||||
set -l optionList (string split "/" $options)
|
|
||||||
|
|
||||||
for option in $optionList
|
|
||||||
set -g upperOption (string upper $option)
|
|
||||||
|
|
||||||
if contains $upperOption $optionList
|
|
||||||
set -g default (_indexMinusOne $upperOption $optionList)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
while true
|
|
||||||
read -P "$question [$options] " input
|
|
||||||
|
|
||||||
set -l splitInput (string split -m1 '' $input)
|
|
||||||
set -l lowerInput (string join '' (string lower $splitInput[1]) $splitInput[2])
|
|
||||||
set -l upperInput (string join '' (string upper $splitInput[1]) $splitInput[2])
|
|
||||||
|
|
||||||
if contains $lowerInput $optionList
|
|
||||||
echo $lowerInput
|
|
||||||
return (_indexMinusOne $lowerInput $optionList)
|
|
||||||
end
|
|
||||||
if contains $upperInput $optionList
|
|
||||||
echo $upperInput
|
|
||||||
return (_indexMinusOne $upperInput $optionList)
|
|
||||||
end
|
|
||||||
if test -z $input && set -q default
|
|
||||||
echo $upperOption
|
|
||||||
return $default
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function _indexMinusOne --argument-names item
|
|
||||||
echo (math (contains -i $item $argv[2..-1])-1)
|
|
||||||
end
|
|
@ -35,7 +35,7 @@ function _promptHeight
|
|||||||
|
|
||||||
_displayRestartAndQuit
|
_displayRestartAndQuit
|
||||||
|
|
||||||
switch (lean_user_ask "Choice" 1/2/r/q)
|
switch (_menu "Choice" 1/2/r/q)
|
||||||
case 1
|
case 1
|
||||||
set -g prompt_height 1
|
set -g prompt_height 1
|
||||||
_promptSpacing
|
_promptSpacing
|
||||||
@ -64,7 +64,7 @@ function _promptConnection
|
|||||||
|
|
||||||
_displayRestartAndQuit
|
_displayRestartAndQuit
|
||||||
|
|
||||||
switch (lean_user_ask "Choice" 1/2/3/r/q)
|
switch (_menu "Choice" 1/2/3/r/q)
|
||||||
case 1
|
case 1
|
||||||
set -g fake_lean_prompt_connection " "
|
set -g fake_lean_prompt_connection " "
|
||||||
_promptSpacing
|
_promptSpacing
|
||||||
@ -99,7 +99,7 @@ function _promptConnectionColor
|
|||||||
|
|
||||||
_displayRestartAndQuit
|
_displayRestartAndQuit
|
||||||
|
|
||||||
switch (lean_user_ask "Choice" 1/2/3/4/r/q)
|
switch (_menu "Choice" 1/2/3/4/r/q)
|
||||||
case 1
|
case 1
|
||||||
set -g fake_lean_prompt_connection_color 808080
|
set -g fake_lean_prompt_connection_color 808080
|
||||||
_promptSpacing
|
_promptSpacing
|
||||||
@ -135,7 +135,7 @@ function _promptSpacing
|
|||||||
|
|
||||||
_displayRestartAndQuit
|
_displayRestartAndQuit
|
||||||
|
|
||||||
switch (lean_user_ask "Choice" 1/2/r/q)
|
switch (_menu "Choice" 1/2/r/q)
|
||||||
case 1
|
case 1
|
||||||
set -g newline false
|
set -g newline false
|
||||||
_finish
|
_finish
|
||||||
@ -222,3 +222,16 @@ function _finish
|
|||||||
set -U lean_prompt_connection_color $fake_lean_prompt_connection_color
|
set -U lean_prompt_connection_color $fake_lean_prompt_connection_color
|
||||||
_quit
|
_quit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function _menu --argument-names question options
|
||||||
|
set -l optionList (string split "/" $options)
|
||||||
|
|
||||||
|
while true
|
||||||
|
read -P "$question [$options] " input
|
||||||
|
|
||||||
|
if contains $input $optionList
|
||||||
|
echo $input
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
23
install.fish
23
install.fish
@ -55,6 +55,27 @@ 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! Run lean_wizard to configure your prompt."
|
echo "Lean theme installed!"
|
||||||
set_color $fish_color_normal
|
set_color $fish_color_normal
|
||||||
|
|
||||||
|
if _user_confirm_defaultYes "Configure prompt?"
|
||||||
|
lean_wizard
|
||||||
|
else
|
||||||
|
echo -e "\n""Run lean_wizard to configure your prompt."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _user_confirm_defaultYes --argument-names question
|
||||||
|
while true
|
||||||
|
read -P "$question [Y/n] " input
|
||||||
|
|
||||||
|
switch $input
|
||||||
|
case y Y yes Yes
|
||||||
|
return 0
|
||||||
|
case n N no No
|
||||||
|
return 1
|
||||||
|
case ''
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user