Switch pure strings to

This commit is contained in:
Ilan Cosman 2020-04-29 14:52:58 -07:00
parent e68ee51173
commit ebd830b6d7
17 changed files with 116 additions and 116 deletions

View File

@ -9,11 +9,11 @@ function fish_prompt --description 'Write out the prompt'
printf "%.s$lean_prompt_connection_icon" (seq $COLUMNS)
set_color $fish_color_normal
echo -ne "\r"(lean_pwd)(lean_git_prompt)" "
echo -ne '\r'(lean_pwd)(lean_git_prompt)' '
lean_load_right_prompt_items
set -l leanRightPromptStartLocation (math $COLUMNS-(string length (_lean_right_prompt_nocolor)))
printf "\r\033["$leanRightPromptStartLocation"C"
printf '\r\033['$leanRightPromptStartLocation'C'
echo -e (lean_right_prompt)
# Prompt character
@ -22,17 +22,17 @@ function fish_prompt --description 'Write out the prompt'
else
set_color $fish_color_error
end
echo -n " "
echo -n ' '
set_color $fish_color_normal
end
function _lean_right_prompt_nocolor
echo -n " "
echo -n ' '
for item in lean_{$lean_right_prompt_items}
if test -n "$$item"
echo -n "$$item"
echo -n " "
echo -n ' '
end
end
end

View File

@ -1,8 +1,8 @@
function lean_git_prompt
set -l gitPrompt (fish_git_prompt)
set -l gitPrompt (string replace "(" "" $gitPrompt)
set -l gitPrompt (string replace ")" "" $gitPrompt)
set -l gitPrompt (string replace '(' '' $gitPrompt)
set -l gitPrompt (string replace ')' '' $gitPrompt)
echo $gitPrompt
end

View File

@ -1,29 +1,29 @@
function lean_load_right_prompt_items
for item in lean_{$lean_right_prompt_items}
set -g $item (eval "_$item")
set -g $item (eval '_'$item)
end
end
function _lean_status
if string match -q --invert "0" $last_pipestatus
if string match -q --invert '0' $last_pipestatus
set -l fishPipestatusWithSignal (__fish_pipestatus_with_signal $last_pipestatus)
if test (count $last_pipestatus) -gt 1 || string match -qe "SIG" $fishPipestatusWithSignal
if test (count $last_pipestatus) -gt 1 || string match -qe 'SIG' $fishPipestatusWithSignal
if test $last_status -eq 0
set -g lean_status_color $lean_status_success_color
echo -n "$lean_status_success_icon "
echo -n {$lean_status_success_icon}' '
else
set -g lean_status_color $lean_status_failure_color
echo -n "$lean_status_failure_icon "
echo -n {$lean_status_failure_icon}' '
end
string join "|" (string replace "SIG" "" $fishPipestatusWithSignal)
string join '|' (string replace 'SIG' '' $fishPipestatusWithSignal)
end
end
end
function _lean_timer
if test (math $CMD_DURATION/1000) -gt $lean_timer_duration
echo -n (math --scale=$lean_timer_decimals $CMD_DURATION/1000)"s"
echo -n (math --scale=$lean_timer_decimals $CMD_DURATION/1000)'s'
end
end
@ -31,7 +31,7 @@ function _lean_context
if set -q SSH_TTY
set -g lean_context_color $lean_context_ssh_color
echo -n $USER'@'(prompt_hostname)
else if test $USER = "root"
else if test $USER = 'root'
set -g lean_context_color $lean_context_root_color
echo -n $USER'@'(prompt_hostname)
end

View File

@ -1,16 +1,16 @@
function lean_pwd
set -l pwdSplit (string split --no-empty "/" (_shorten_pwd))
set -l pwdSplit (string split --no-empty '/' (_shorten_pwd))
set -l pwdSplitLength (count $pwdSplit)
if not test -w $PWD
set_color $lean_color_dark_blue
echo -n "$lean_pwd_unwritable_icon "
echo -n $lean_pwd_unwritable_icon' '
set_color $fish_color_normal
end
if test "$pwdSplit[1]" != "~"
if test "$pwdSplit[1]" != '~'
set_color $lean_color_dark_blue
echo -n "/"
echo -n '/'
set_color $fish_color_normal
end
@ -20,14 +20,14 @@ function lean_pwd
if test $pwdSplitLength -gt 1
set_color $lean_color_dark_blue
echo -n "/"
echo -n '/'
set_color $fish_color_normal
end
if test $pwdSplitLength -gt 2
set_color $lean_color_dark_blue
echo -n (string join "/" $pwdSplit[2..-2])
echo -n "/"
echo -n (string join '/' $pwdSplit[2..-2])
echo -n '/'
set_color $fish_color_normal
end

View File

@ -1,16 +1,16 @@
function lean_right_prompt
echo -n " "
echo -n ' '
for item in lean_{$lean_right_prompt_items}
if test -n "$$item"
set -l colorName "$item""_color"
set -l colorNameBoldFlag "$colorName""_bold"
set -l colorName $item'_color'
set -l colorNameBoldFlag $colorName'_bold'
if test $colorNameBoldFlag = "true"
if test $colorNameBoldFlag = 'true'
set_color -o
end
set_color "$$colorName"
echo -n "$$item"" "
echo -n "$$item"' '
set_color normal
end
end

View File

@ -1,14 +1,14 @@
function lean_uninstall
if _user_confirm_defaultNo "Unininstall lean theme?"
if _user_confirm_defaultNo 'Unininstall lean theme?'
set -l fishPrompt "$__fish_config_dir/functions/fish_prompt.fish"
echo "Uninstalling lean theme..."
echo 'Uninstalling lean theme...'
# ------------------Remove Files------------------
rm -r "$__fish_config_dir/lean_theme"
set -l fishPromptFirstLine (head -n 1 $fishPrompt)
if test "$fishPromptFirstLine" = "# Created by lean_wizard"
if test "$fishPromptFirstLine" = '# Created by lean_wizard'
rm $fishPrompt
source "$__fish_data_dir/functions/fish_prompt.fish"
end
@ -48,9 +48,9 @@ function lean_uninstall
set -e $var
end
echo "Lean theme uninstalled."
echo 'Lean theme uninstalled.'
else
echo "Aborted uninstall."
echo 'Aborted uninstall.'
end
end

View File

@ -1,6 +1,6 @@
function lean_wizard
if test $COLUMNS -lt 55 || test $LINES -lt 21
echo "Terminal size too small; must be at least 55 x 21"
echo 'Terminal size too small; must be at least 55 x 21'
return 1
end
@ -27,22 +27,22 @@ function _setDefaults
else
set -g newline false
end
set -g fake_lean_prompt_connection " "
set -g fake_lean_prompt_connection ' '
set -g fake_lean_prompt_connection_color 6C6C6C
end
function _promptHeight
_title "Prompt Height"
_title 'Prompt Height'
_option 1 "One line"
_option 1 'One line'
_displayPrompt prompt_height 1
_option 2 "Two lines"
_option 2 'Two lines'
_displayPrompt prompt_height 2
_displayRestartAndQuit
switch (_menu "Choice" 1/2/r/q)
switch (_menu 'Choice' 1/2/r/q)
case 1
set -g prompt_height 1
_promptSpacing
@ -57,28 +57,28 @@ function _promptHeight
end
function _promptConnection
_title "Prompt Connection"
_title 'Prompt Connection'
_option 1 "Disconnected"
_displayPrompt fake_lean_prompt_connection " "
_option 1 'Disconnected'
_displayPrompt fake_lean_prompt_connection ' '
_option 2 "Dotted"
_displayPrompt fake_lean_prompt_connection "·"
_option 2 'Dotted'
_displayPrompt fake_lean_prompt_connection '·'
_option 3 "Solid"
_displayPrompt fake_lean_prompt_connection "─"
_option 3 'Solid'
_displayPrompt fake_lean_prompt_connection '─'
_displayRestartAndQuit
switch (_menu "Choice" 1/2/3/r/q)
switch (_menu 'Choice' 1/2/3/r/q)
case 1
set -g fake_lean_prompt_connection " "
set -g fake_lean_prompt_connection ' '
_promptSpacing
case 2
set -g fake_lean_prompt_connection "·"
set -g fake_lean_prompt_connection '·'
_promptConnectionColor
case 3
set -g fake_lean_prompt_connection "─"
set -g fake_lean_prompt_connection '─'
_promptConnectionColor
case r
_begin
@ -88,23 +88,23 @@ function _promptConnection
end
function _promptConnectionColor
_title "Connection Color"
_title 'Connection Color'
_option 1 "Lightest"
_option 1 'Lightest'
_displayPrompt fake_lean_prompt_connection_color 808080
_option 2 "Light"
_option 2 'Light'
_displayPrompt fake_lean_prompt_connection_color 6C6C6C
_option 3 "Dark"
_option 3 'Dark'
_displayPrompt fake_lean_prompt_connection_color 585858
_option 4 "Darkest"
_option 4 'Darkest'
_displayPrompt fake_lean_prompt_connection_color 444444
_displayRestartAndQuit
switch (_menu "Choice" 1/2/3/4/r/q)
switch (_menu 'Choice' 1/2/3/4/r/q)
case 1
set -g fake_lean_prompt_connection_color 808080
_promptSpacing
@ -125,21 +125,21 @@ function _promptConnectionColor
end
function _promptSpacing
_title "Prompt Spacing"
_title 'Prompt Spacing'
_option 1 "Compact"
_option 1 'Compact'
_displayPrompt newline true
echo -ne "\r\033[1A"
echo -ne '\r\033[1A'
_displayPrompt newline false
_option 2 "Sparse"
_option 2 'Sparse'
_displayPrompt newline true
echo -ne "\r\033[1A"
echo -ne '\r\033[1A'
_displayPrompt newline true
_displayRestartAndQuit
switch (_menu "Choice" 1/2/r/q)
switch (_menu 'Choice' 1/2/r/q)
case 1
set -g newline false
_finish
@ -156,7 +156,7 @@ end
function _assemblePrompt -a whichPrompt
set -g moduleDir "$__fish_config_dir/lean_theme/prompt_modules/$whichPrompt""_prompt"
if test "$whichPrompt" = "fish"
if test "$whichPrompt" = 'fish'
set -g promptDir $fishPrompt
else
set -g promptDir $fakePrompt
@ -165,10 +165,10 @@ function _assemblePrompt -a whichPrompt
echo -n >$promptDir
_addMod 1_initial
if test "$newline" = "true"
if test "$newline" = 'true'
_addMod 2_newline
end
_addMod "3_"$prompt_height"Line"
_addMod '3_'$prompt_height'Line'
_addMod 4_final
if test $prompt_height -eq 1
_addMod 5_rightPrompt
@ -179,7 +179,7 @@ end
function _addMod -a file
cat "$moduleDir/$file.fish" >>$promptDir
printf "\n\n" >>$promptDir
printf '\n\n' >>$promptDir
end
function _title -a title
@ -188,7 +188,7 @@ function _title -a title
set -l midTitle (math (string length $title)/2)
for i in (seq (math $midCols-$midTitle))
echo -n " "
echo -n ' '
end
set_color -o
echo $title
@ -208,12 +208,12 @@ function _displayPrompt -a var_name var_value
source $promptDir
fake_prompt
printf "\n\n"
printf '\n\n'
end
function _displayRestartAndQuit
echo -e "(r) Restart from the beginning\n"
echo -e "(q) Quit and do nothing\n"
echo -e '(r) Restart from the beginning\n'
echo -e '(q) Quit and do nothing\n'
end
function _quit
@ -223,15 +223,15 @@ function _quit
end
function _finish
_title "Overwrite fish_prompt?"
_title 'Overwrite fish_prompt?'
_option y "Yes"
printf "\n\n"
_option y 'Yes'
printf '\n\n'
_option n "No"
printf "\n\n"
_option n 'No'
printf '\n\n'
switch (_menu "Choice" y/n)
switch (_menu 'Choice' y/n)
case y
_assemblePrompt fish
set -U lean_prompt_connection_icon $fake_lean_prompt_connection
@ -243,7 +243,7 @@ function _finish
end
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 norm (set_color normal)

View File

@ -1,8 +1,8 @@
function lean_install
echo "Installing lean theme..."
echo 'Installing lean theme...'
# -----------------Download Functions-----------------
set -l tempDir "/tmp/lean_theme"
set -l tempDir '/tmp/lean_theme'
# Clone repository into $tempDir
if test -e $tempDir
@ -28,19 +28,19 @@ function lean_install
set -U lean_color_gold D7AF00
# ---------------Pwd---------------
set -U lean_pwd_shorten_margin 5
set -U lean_pwd_unwritable_icon "" # Lock
set -U lean_pwd_unwritable_icon '' # Lock
# ------------Git prompt------------
set -U __fish_git_prompt_show_informative_status true
set -U __fish_git_prompt_showstashstate true
# -------Symbols-------
set -U __fish_git_prompt_char_stateseparator ""
set -U __fish_git_prompt_char_cleanstate ""
set -U __fish_git_prompt_char_upstream_ahead " ⇡"
set -U __fish_git_prompt_char_upstream_behind " ⇣"
set -U __fish_git_prompt_char_stagedstate " +"
set -U __fish_git_prompt_char_dirtystate " !"
set -U __fish_git_prompt_char_untrackedfiles " ?"
set -U __fish_git_prompt_char_stashstate " *"
set -U __fish_git_prompt_char_stateseparator ''
set -U __fish_git_prompt_char_cleanstate ''
set -U __fish_git_prompt_char_upstream_ahead ' ⇡'
set -U __fish_git_prompt_char_upstream_behind ' ⇣'
set -U __fish_git_prompt_char_stagedstate ' +'
set -U __fish_git_prompt_char_dirtystate ' !'
set -U __fish_git_prompt_char_untrackedfiles ' ?'
set -U __fish_git_prompt_char_stashstate ' *'
# --------Colors--------
set -U __fish_git_prompt_color_branch $lean_color_green
set -U __fish_git_prompt_color_upstream $lean_color_green
@ -50,11 +50,11 @@ function lean_install
set -U __fish_git_prompt_color_stashstate $lean_color_green
# ----------------Right Prompt Items----------------
set -U lean_right_prompt_items "status" "timer" "context" "jobs"
set -U lean_right_prompt_items 'status' 'timer' 'context' 'jobs'
# --------------Status--------------
set -U lean_status_success_icon "✔"
set -U lean_status_success_icon '✔'
set -U lean_status_success_color 5FAF00
set -U lean_status_failure_icon "✘"
set -U lean_status_failure_icon '✘'
set -U lean_status_failure_color D70000
# --------------Timer--------------
set -U lean_timer_color 87875F
@ -64,20 +64,20 @@ function lean_install
set -U lean_context_ssh_color D7AF87
set -U lean_context_root_color D7AF00
# ---------------Jobs---------------
set -U lean_jobs_icon "" # Gear
set -U lean_jobs_icon '' # Gear
set -U lean_jobs_color 5FAF00
# -----------------------Finish-----------------------
source "$__fish_config_dir/functions/fish_prompt.fish"
set_color $lean_color_green
echo "Lean theme installed!"
echo 'Lean theme installed!'
set_color $fish_color_normal
if _user_confirm_defaultYes "Configure lean prompt?"
if _user_confirm_defaultYes 'Configure lean prompt?'
lean_wizard
else
echo -e "\n""Run lean_wizard to configure your prompt."
echo -e '\n''Run lean_wizard to configure your prompt.'
end
end
@ -90,7 +90,7 @@ function _user_confirm_defaultYes -a question
return 0
case n N no No
return 1
case ""
case ''
return 0
end
end

View File

@ -1,19 +1,19 @@
printf "%.s " (seq $columns)
printf '%.s ' (seq $columns)
set -l timerOutput " 5s "
set -l timerOutput ' 5s '
set -l timerStartLocation (math $columns-(string length $timerOutput))
printf "\r\033["$timerStartLocation"C"
printf '\r\033['$timerStartLocation'C'
set_color $lean_timer_color
echo -n $timerOutput
set_color $fish_color_normal
echo -ne "\r"
echo -ne '\r'
set -l Lblue (set_color -o $lean_color_light_blue)
set -l Dblue (set_color $lean_color_dark_blue)
set -l n (set_color $fish_color_normal)
echo -n $Lblue"~"$n$Dblue"/"$n$Lblue"src "$n
echo -n $Lblue'~'$n$Dblue'/'$n$Lblue'src '$n
set_color $lean_color_green
echo -n "master "
echo -n 'master '
set_color $fish_color_normal

View File

@ -2,20 +2,20 @@
printf "%.s$fake_lean_prompt_connection" (seq $columns)
set_color $fish_color_normal
set -l timerOutput " 5s "
set -l timerOutput ' 5s '
set -l timerStartLocation (math $columns-(string length $timerOutput))
printf "\r\033["$timerStartLocation"C"
printf '\r\033['$timerStartLocation'C'
set_color $lean_timer_color
echo -n $timerOutput
set_color $fish_color_normal
echo -ne "\r"
echo -ne '\r'
set -l Lblue (set_color -o $lean_color_light_blue)
set -l Dblue (set_color $lean_color_dark_blue)
set -l n (set_color $fish_color_normal)
echo -n $Lblue"~"$n$Dblue"/"$n$Lblue"src "$n
echo -n $Lblue'~'$n$Dblue'/'$n$Lblue'src '$n
set_color $lean_color_green
echo "master "
echo 'master '
set_color $fish_color_normal

View File

@ -4,6 +4,6 @@
else
set_color $fish_color_error
end
echo -n " "
echo -n ' '
set_color $fish_color_normal
end

View File

@ -1,7 +1,7 @@
function _lean_right_prompt_nocolor
echo -n " "
echo -n ' '
if test -n "$leanTimer"
echo -n $leanTimer
echo -n " "
echo -n ' '
end
end

View File

@ -1,5 +1,5 @@
function fish_right_prompt
set_color $lean_timer_color
echo " 5s "
echo ' 5s '
set_color $fish_color_normal
end

View File

@ -1 +1 @@
echo -n (lean_pwd)(lean_git_prompt)" "
echo -n (lean_pwd)(lean_git_prompt)' '

View File

@ -2,9 +2,9 @@
printf "%.s$lean_prompt_connection_icon" (seq $COLUMNS)
set_color $fish_color_normal
echo -ne "\r"(lean_pwd)(lean_git_prompt)" "
echo -ne '\r'(lean_pwd)(lean_git_prompt)' '
lean_load_right_prompt_items
set -l leanRightPromptStartLocation (math $COLUMNS-(string length (_lean_right_prompt_nocolor)))
printf "\r\033["$leanRightPromptStartLocation"C"
printf '\r\033['$leanRightPromptStartLocation'C'
echo -e (lean_right_prompt)

View File

@ -4,6 +4,6 @@
else
set_color $fish_color_error
end
echo -n " "
echo -n ' '
set_color $fish_color_normal
end

View File

@ -1,10 +1,10 @@
function _lean_right_prompt_nocolor
echo -n " "
echo -n ' '
for item in lean_{$lean_right_prompt_items}
if test -n "$$item"
echo -n "$$item"
echo -n " "
echo -n ' '
end
end
end