From 50f629ccda96f173dc13bb8dba3214caf5362157 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Mon, 1 Apr 2024 22:50:22 +0900 Subject: [PATCH] themes/modern+: Localize variables --- themes/mairan/mairan.theme.sh | 16 ++++++++-------- themes/modern-t/modern-t.theme.sh | 2 +- themes/modern/modern.theme.sh | 2 +- themes/slick/slick.theme.sh | 9 +++++---- themes/zork/zork.theme.sh | 16 ++++++++-------- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/themes/mairan/mairan.theme.sh b/themes/mairan/mairan.theme.sh index 5c3b907..d871945 100644 --- a/themes/mairan/mairan.theme.sh +++ b/themes/mairan/mairan.theme.sh @@ -70,7 +70,7 @@ function is_vim_shell { } function modern_scm_prompt { - CHAR=$(scm_char) + local CHAR=$(scm_char) if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then return else @@ -81,7 +81,7 @@ function modern_scm_prompt { # show chroot if exist function chroot { if [[ $debian_chroot ]]; then - my_ps_chroot=$_omb_prompt_bold_teal$debian_chroot$_omb_prompt_normal + local my_ps_chroot=$_omb_prompt_bold_teal$debian_chroot$_omb_prompt_normal echo "($my_ps_chroot)" fi } @@ -89,22 +89,22 @@ function chroot { # show virtualenvwrapper function my_ve { if [[ $VIRTUAL_ENV ]]; then - my_ps_ve=$_omb_prompt_bold_purple$ve$_omb_prompt_normal + local my_ps_ve=$_omb_prompt_bold_purple$ve$_omb_prompt_normal echo "($my_ps_ve)" fi echo "" } function _omb_theme_PROMPT_COMMAND { - my_ps_host="$BOLD$ORANGE\h${_omb_prompt_normal}" + local my_ps_host="$BOLD$ORANGE\h${_omb_prompt_normal}" # yes, these are the the same for now ... - my_ps_host_root="$ORANGE\h${_omb_prompt_normal}" + local my_ps_host_root="$ORANGE\h${_omb_prompt_normal}" - my_ps_user="$BOLD$GREEN\u${_omb_prompt_normal}" - my_ps_root="${_omb_prompt_bold_brown}\u${_omb_prompt_normal}" + local my_ps_user="$BOLD$GREEN\u${_omb_prompt_normal}" + local my_ps_root="${_omb_prompt_bold_brown}\u${_omb_prompt_normal}" if [[ $VIRTUAL_ENV ]]; then - ve=$(basename "$VIRTUAL_ENV") + local ve=$(basename "$VIRTUAL_ENV") fi # nice prompt diff --git a/themes/modern-t/modern-t.theme.sh b/themes/modern-t/modern-t.theme.sh index fb61948..45207a2 100644 --- a/themes/modern-t/modern-t.theme.sh +++ b/themes/modern-t/modern-t.theme.sh @@ -26,7 +26,7 @@ function is_vim_shell { } function modern_scm_prompt { - CHAR=$(scm_char) + local CHAR=$(scm_char) if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then return else diff --git a/themes/modern/modern.theme.sh b/themes/modern/modern.theme.sh index 7db387b..e2916f3 100644 --- a/themes/modern/modern.theme.sh +++ b/themes/modern/modern.theme.sh @@ -26,7 +26,7 @@ function is_vim_shell { } function modern_scm_prompt { - CHAR=$(scm_char) + local CHAR=$(scm_char) if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then return else diff --git a/themes/slick/slick.theme.sh b/themes/slick/slick.theme.sh index 100ff98..88e457b 100644 --- a/themes/slick/slick.theme.sh +++ b/themes/slick/slick.theme.sh @@ -43,7 +43,7 @@ function is_vim_shell { } function modern_scm_prompt { - CHAR=$(scm_char) + local CHAR=$(scm_char) if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then return else @@ -52,6 +52,7 @@ function modern_scm_prompt { } function _omb_theme_PROMPT_COMMAND { + local my_ps_host case $HOSTNAME in "clappy"* ) my_ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}"; ;; @@ -61,9 +62,9 @@ function _omb_theme_PROMPT_COMMAND { ;; esac - my_ps_user="\[\033[01;32m\]\u\[\033[00m\]"; - my_ps_root="\[\033[01;31m\]\u\[\033[00m\]"; - my_ps_path="\[\033[01;36m\]\w\[\033[00m\]"; + local my_ps_user="\[\033[01;32m\]\u\[\033[00m\]"; + local my_ps_root="\[\033[01;31m\]\u\[\033[00m\]"; + local my_ps_path="\[\033[01;36m\]\w\[\033[00m\]"; # nice prompt case $(id -u) in diff --git a/themes/zork/zork.theme.sh b/themes/zork/zork.theme.sh index 8cb62e3..4f7bda8 100644 --- a/themes/zork/zork.theme.sh +++ b/themes/zork/zork.theme.sh @@ -37,7 +37,7 @@ function is_vim_shell { } function modern_scm_prompt { - CHAR=$(scm_char) + local CHAR=$(scm_char) if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then return else @@ -48,7 +48,7 @@ function modern_scm_prompt { # show chroot if exist function chroot { if [[ $debian_chroot ]]; then - my_ps_chroot=$_omb_prompt_bold_teal$debian_chroot$_omb_prompt_normal + local my_ps_chroot=$_omb_prompt_bold_teal$debian_chroot$_omb_prompt_normal echo "($my_ps_chroot)" fi } @@ -56,22 +56,22 @@ function chroot { # show virtualenvwrapper function my_ve { if [[ $VIRTUAL_ENV ]]; then - my_ps_ve=$_omb_prompt_bold_purple$ve$_omb_prompt_normal + local my_ps_ve=$_omb_prompt_bold_purple$ve$_omb_prompt_normal echo "($my_ps_ve)" fi echo "" } function _omb_theme_PROMPT_COMMAND { - my_ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}" + local my_ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}" # yes, these are the the same for now ... - my_ps_host_root="${_omb_prompt_green}\h${_omb_prompt_normal}" + local my_ps_host_root="${_omb_prompt_green}\h${_omb_prompt_normal}" - my_ps_user="${_omb_prompt_bold_green}\u${_omb_prompt_normal}" - my_ps_root="${_omb_prompt_bold_brown}\u${_omb_prompt_normal}" + local my_ps_user="${_omb_prompt_bold_green}\u${_omb_prompt_normal}" + local my_ps_root="${_omb_prompt_bold_brown}\u${_omb_prompt_normal}" if [[ $VIRTUAL_ENV ]]; then - ve=$(basename "$VIRTUAL_ENV") + local ve=$(basename "$VIRTUAL_ENV") fi # nice prompt