From 0dd773f302892bbeaa7840b32aafe224546bc1ec Mon Sep 17 00:00:00 2001 From: Ilan Cosman Date: Tue, 28 Apr 2020 21:19:32 -0700 Subject: [PATCH] Add background jobs right prompt item. Rename variables --- functions/fish_prompt.fish | 2 +- functions/lean_load_right_prompt_items.fish | 17 ++++++++--------- functions/lean_pwd.fish | 4 ++-- functions/lean_uninstall.fish | 10 ++++++---- functions/lean_wizard.fish | 2 +- install.fish | 9 ++++++--- .../prompt_modules/fish_prompt/3_2Line.fish | 2 +- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 1473b71..4b1402a 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -5,7 +5,7 @@ function fish_prompt --description 'Write out the prompt' echo set_color $lean_prompt_connection_color - printf "%.s$lean_prompt_connection" (seq $COLUMNS) + printf "%.s$lean_prompt_connection_icon" (seq $COLUMNS) set_color $fish_color_normal echo -ne "\r"(lean_pwd)(lean_git_prompt)" " diff --git a/functions/lean_load_right_prompt_items.fish b/functions/lean_load_right_prompt_items.fish index 05ed144..14e39f9 100644 --- a/functions/lean_load_right_prompt_items.fish +++ b/functions/lean_load_right_prompt_items.fish @@ -6,23 +6,22 @@ end function _lean_timer if test (math $CMD_DURATION/1000) -gt $lean_timer_duration - set -l lean_timer_output (math --scale=$lean_timer_decimals $CMD_DURATION/1000)"s" - echo -n $lean_timer_output + echo -n (math --scale=$lean_timer_decimals $CMD_DURATION/1000)"s" end end function _lean_context if set -q SSH_TTY set -g lean_context_color $lean_context_ssh_color - set -g lean_context_color_bold false - - set -l lean_context_output $USER'@'(prompt_hostname) - echo -n $lean_context_output + echo -n $USER'@'(prompt_hostname) else if test $USER = "root" set -g lean_context_color $lean_context_root_color - set -g lean_context_color_bold true + echo -n $USER'@'(prompt_hostname) + end +end - set -l lean_context_output $USER'@'(prompt_hostname) - echo -n $lean_context_output +function _lean_jobs + if jobs -q + echo -n $lean_jobs_icon # Gear icon end end \ No newline at end of file diff --git a/functions/lean_pwd.fish b/functions/lean_pwd.fish index 99574c3..3900d23 100644 --- a/functions/lean_pwd.fish +++ b/functions/lean_pwd.fish @@ -4,7 +4,7 @@ function lean_pwd if not test -w $PWD set_color $lean_color_dark_blue - echo -n " " # Lock icon + echo -n "$lean_pwd_unwritable_icon " set_color $fish_color_normal end @@ -49,7 +49,7 @@ function _shorten_pwd set -g fish_prompt_pwd_dir_length 0 set -l pwd (prompt_pwd) set -l lengthPromptPwd (string length $pwd) - set -l shortenPwdLength (math $COLUMNS-$lean_shorten_pwd_margin) + set -l shortenPwdLength (math $COLUMNS-$lean_pwd_shorten_margin) set -l promptPwdDirLength 8 while test $lengthPromptPwd -gt $shortenPwdLength -a $promptPwdDirLength -gt 0 diff --git a/functions/lean_uninstall.fish b/functions/lean_uninstall.fish index c522c44..44ed2c6 100644 --- a/functions/lean_uninstall.fish +++ b/functions/lean_uninstall.fish @@ -1,9 +1,9 @@ function lean_uninstall if _user_confirm_defaultNo "Unininstall lean theme?" set -l fishPrompt "$__fish_config_dir/functions/fish_prompt.fish" - + echo "Uninstalling lean theme..." - + # ------------------Remove Files------------------ rm -r "$__fish_config_dir/lean_theme" @@ -20,11 +20,11 @@ function lean_uninstall # --------------Erase Theme Variables-------------- # --------------Prompt-------------- - set -a rmVars lean_prompt_connection lean_prompt_connection_color + set -a rmVars lean_prompt_connection_{icon, color} # --------------Colors-------------- set -a rmVars lean_color_{green, light_blue, dark_blue, gold} # ---------------Pwd--------------- - set -a rmVars fish_prompt_pwd_dir_length lean_shorten_pwd_margin + set -a rmVars lean_pwd_{shorten_margin, unwritable_icon} # ------------Git prompt------------ set -a rmVars __fish_git_prompt_{show_informative_status, showstashstate} # -------Symbols------- @@ -39,6 +39,8 @@ function lean_uninstall set -a rmVars lean_timer_{color, decimals, duration} # ---------------SSH--------------- set -a rmVars lean_context_{ssh_color, root_color} + # ---------------Jobs--------------- + set -U lean_jobs_{icon, color} for var in $rmVars set -e $var diff --git a/functions/lean_wizard.fish b/functions/lean_wizard.fish index 6913c78..57c8e95 100644 --- a/functions/lean_wizard.fish +++ b/functions/lean_wizard.fish @@ -234,7 +234,7 @@ function _finish switch (_menu "Choice" y/n) case y _assemblePrompt fish - set -U lean_prompt_connection $fake_lean_prompt_connection + set -U lean_prompt_connection_icon $fake_lean_prompt_connection set -U lean_prompt_connection_color $fake_lean_prompt_connection_color case n end diff --git a/install.fish b/install.fish index 6b4cd9b..e569cc1 100644 --- a/install.fish +++ b/install.fish @@ -26,8 +26,8 @@ function lean_install set -U lean_color_dark_blue 0087AF set -U lean_color_gold D7AF00 # ---------------Pwd--------------- - set -U fish_prompt_pwd_dir_length 0 - set -U lean_shorten_pwd_margin 5 + set -U lean_pwd_shorten_margin 5 + 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 @@ -49,7 +49,7 @@ function lean_install set -U __fish_git_prompt_color_stashstate $lean_color_green # ----------------Right Prompt Items---------------- - set -U lean_right_prompt_items timer context + set -U lean_right_prompt_items timer context jobs # --------------Timer-------------- set -U lean_timer_color 87875F set -U lean_timer_decimals 0 @@ -57,6 +57,9 @@ function lean_install # -------------Context------------- 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_color 5FAF00 # -----------------------Finish----------------------- source "$__fish_config_dir/functions/fish_prompt.fish" diff --git a/lean_theme/prompt_modules/fish_prompt/3_2Line.fish b/lean_theme/prompt_modules/fish_prompt/3_2Line.fish index 77a7bf7..d91aec3 100644 --- a/lean_theme/prompt_modules/fish_prompt/3_2Line.fish +++ b/lean_theme/prompt_modules/fish_prompt/3_2Line.fish @@ -1,5 +1,5 @@ set_color $lean_prompt_connection_color - printf "%.s$lean_prompt_connection" (seq $COLUMNS) + printf "%.s$lean_prompt_connection_icon" (seq $COLUMNS) set_color $fish_color_normal echo -ne "\r"(lean_pwd)(lean_git_prompt)" "