From 065e8ebdd02ba2554d4509424f1cde0e84361357 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 13 Dec 2021 15:13:43 +0100 Subject: style(jonathan): fix code style in jonathan theme --- themes/simonoff.zsh-theme | 136 ++++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 70 deletions(-) (limited to 'themes/simonoff.zsh-theme') diff --git a/themes/simonoff.zsh-theme b/themes/simonoff.zsh-theme index ef91c5ee3..fea2eff42 100644 --- a/themes/simonoff.zsh-theme +++ b/themes/simonoff.zsh-theme @@ -10,46 +10,46 @@ # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white function precmd { - local TERMWIDTH - (( TERMWIDTH = ${COLUMNS} - 1 )) + local TERMWIDTH + (( TERMWIDTH = ${COLUMNS} - 1 )) - ### - # Truncate the path if it's too long. + ### + # Truncate the path if it's too long. - PR_FILLBAR="" - PR_PWDLEN="" + PR_FILLBAR="" + PR_PWDLEN="" - local promptsize=${#${(%):---(%n@%M:%l)---()}} - local pwdsize=${#${(%):-%~}} - local gitbranch="$(git_prompt_info)" - local rvmprompt="$(ruby_prompt_info)" - local gitbranchsize=${#${gitbranch:-''}} - local rvmpromptsize=${#${rvmprompt:-''}} + local promptsize=${#${(%):---(%n@%M:%l)---()}} + local pwdsize=${#${(%):-%~}} + local gitbranch="$(git_prompt_info)" + local rvmprompt="$(ruby_prompt_info)" + local gitbranchsize=${#${gitbranch:-''}} + local rvmpromptsize=${#${rvmprompt:-''}} - if [[ "$promptsize + $pwdsize + $rvmpromptsize + $gitbranchsize" -gt $TERMWIDTH ]]; then - ((PR_PWDLEN=$TERMWIDTH - $promptsize)) - else - PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize + $rvmpromptsize + $gitbranchsize)))..${PR_SPACE}.)}" - fi + if [[ "$promptsize + $pwdsize + $rvmpromptsize + $gitbranchsize" -gt $TERMWIDTH ]]; then + ((PR_PWDLEN=$TERMWIDTH - $promptsize)) + else + PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize + $rvmpromptsize + $gitbranchsize)))..${PR_SPACE}.)}" + fi } setopt extended_glob preexec () { - if [[ "$TERM" == "screen" ]]; then - local CMD=${1[(wr)^(*=*|sudo|-*)]} - echo -n "\ek$CMD\e\\" - fi + if [[ "$TERM" == "screen" ]]; then + local CMD=${1[(wr)^(*=*|sudo|-*)]} + echo -n "\ek$CMD\e\\" + fi - if [[ "$TERM" == "xterm" ]]; then - print -Pn "\e]0;$1\a" - fi + if [[ "$TERM" == "xterm" ]]; then + print -Pn "\e]0;$1\a" + fi - if [[ "$TERM" == "rxvt" ]]; then - print -Pn "\e]0;$1\a" - fi + if [[ "$TERM" == "rxvt" ]]; then + print -Pn "\e]0;$1\a" + fi } @@ -57,71 +57,67 @@ setprompt () { ### # Need this so the prompt will work. - setopt prompt_subst + setopt prompt_subst ### # See if we can use colors. - autoload zsh/terminfo - for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do - eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}' - eval PR_LIGHT_$color='%{$fg[${(L)color}]%}' - (( count = $count + 1 )) - done - PR_NO_COLOUR="%{$terminfo[sgr0]%}" + autoload zsh/terminfo + for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do + eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}' + eval PR_LIGHT_$color='%{$fg[${(L)color}]%}' + (( count = $count + 1 )) + done + PR_NO_COLOUR="%{$terminfo[sgr0]%}" ### # See if we can use extended characters to look nicer. - - typeset -A altchar -# set -A altchar "${(s..)terminfo[acsc]}" - PR_SET_CHARSET="%{$terminfo[enacs]%}" - PR_HBAR=${altchar[q]:--} - PR_ULCORNER=${altchar[l]:--} - PR_LLCORNER=${altchar[m]:--} - PR_LRCORNER=${altchar[j]:--} - PR_URCORNER=${altchar[k]:--} - - ### - # Modify Git prompt - ZSH_THEME_GIT_PROMPT_PREFIX=" [" - ZSH_THEME_GIT_PROMPT_SUFFIX="]" - ### - # Modify RVM prompt - ZSH_THEME_RUBY_PROMPT_PREFIX=" [" - ZSH_THEME_RUBY_PROMPT_SUFFIX="]" + PR_HBAR=${altchar[q]:--} + PR_ULCORNER=${altchar[l]:--} + PR_LLCORNER=${altchar[m]:--} + PR_LRCORNER=${altchar[j]:--} + PR_URCORNER=${altchar[k]:--} + + ### + # Modify Git prompt + ZSH_THEME_GIT_PROMPT_PREFIX=" [" + ZSH_THEME_GIT_PROMPT_SUFFIX="]" + ### + # Modify RVM prompt + ZSH_THEME_RUBY_PROMPT_PREFIX=" [" + ZSH_THEME_RUBY_PROMPT_SUFFIX="]" ### # Decide if we need to set titlebar text. - case $TERM in - xterm*|*rxvt*) - PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%M:%~ $(git_prompt_info) $(rvm_prompt_info) | ${COLUMNS}x${LINES} | %y\a%}' - ;; - screen) - PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}' - ;; - *) - PR_TITLEBAR='' - ;; - esac + case $TERM in + xterm*|*rxvt*) + PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%M:%~ $(git_prompt_info) $(rvm_prompt_info) | ${COLUMNS}x${LINES} | %y\a%}' + ;; + screen) + PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}' + ;; + *) + PR_TITLEBAR='' + ;; + esac ### # Decide whether to set a screen title - if [[ "$TERM" == "screen" ]]; then - PR_STITLE=$'%{\ekzsh\e\\%}' - else - PR_STITLE='' - fi + if [[ "$TERM" == "screen" ]]; then + PR_STITLE=$'%{\ekzsh\e\\%}' + else + PR_STITLE='' + fi ### # Finally, the prompt. # - PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\ + PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\ $PR_RED$PR_HBAR<\ $PR_BLUE%(!.$PR_RED%SROOT%s.%n)$PR_GREEN@$PR_BLUE%M:$PR_GREEN%$PR_PWDLEN<...<%~$PR_CYAN$(git_prompt_info)$(rvm_prompt_info)\ $PR_RED>$PR_HBAR$PR_SPACE${(e)PR_FILLBAR}\ -- cgit v1.2.3-70-g09d2 From aa99472c8ac5bdd111ea306e800bb152fb8580ac Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 13 Dec 2021 17:02:21 +0100 Subject: style(simonoff): fix code style and optimize use of variables --- themes/simonoff.zsh-theme | 131 +++++++++++++++++----------------------------- 1 file changed, 48 insertions(+), 83 deletions(-) (limited to 'themes/simonoff.zsh-theme') diff --git a/themes/simonoff.zsh-theme b/themes/simonoff.zsh-theme index fea2eff42..c906192a0 100644 --- a/themes/simonoff.zsh-theme +++ b/themes/simonoff.zsh-theme @@ -1,43 +1,22 @@ -# Prompt -# -# Below are the color init strings for the basic file types. A color init -# string consists of one or more of the following numeric codes: -# Attribute codes: -# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed -# Text color codes: -# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white -# Background color codes: -# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white -function precmd { - - local TERMWIDTH - (( TERMWIDTH = ${COLUMNS} - 1 )) - - - ### - # Truncate the path if it's too long. - +function theme_precmd { PR_FILLBAR="" PR_PWDLEN="" - local promptsize=${#${(%):---(%n@%M:%l)---()}} + local promptsize=${#${(%):--(%n@%M:)--(%l)-}} local pwdsize=${#${(%):-%~}} - local gitbranch="$(git_prompt_info)" - local rvmprompt="$(ruby_prompt_info)" - local gitbranchsize=${#${gitbranch:-''}} - local rvmpromptsize=${#${rvmprompt:-''}} + local gitbranchsize="${#${(%)$(git_prompt_info)}:-}" + local rvmpromptsize="${#${(%)$(ruby_prompt_info):-}}" - if [[ "$promptsize + $pwdsize + $rvmpromptsize + $gitbranchsize" -gt $TERMWIDTH ]]; then - ((PR_PWDLEN=$TERMWIDTH - $promptsize)) + # Truncate the path if it's too long. + if (( promptsize + pwdsize + rvmpromptsize + gitbranchsize > COLUMNS )); then + (( PR_PWDLEN = COLUMNS - promptsize )) else - PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize + $rvmpromptsize + $gitbranchsize)))..${PR_SPACE}.)}" + PR_FILLBAR="\${(l.$(( COLUMNS - (promptsize + pwdsize + rvmpromptsize + gitbranchsize) ))..${PR_SPACE}.)}" fi } - -setopt extended_glob - -preexec () { +function theme_preexec { + setopt local_options extended_glob if [[ "$TERM" == "screen" ]]; then local CMD=${1[(wr)^(*=*|sudo|-*)]} echo -n "\ek$CMD\e\\" @@ -53,47 +32,41 @@ preexec () { } -setprompt () { -### -# Need this so the prompt will work. +autoload -U add-zsh-hook +add-zsh-hook precmd theme_precmd +add-zsh-hook preexec theme_preexec - setopt prompt_subst +# Set the prompt + +# Need this so the prompt will work. +setopt prompt_subst -### # See if we can use colors. +autoload zsh/terminfo +for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do + print -v "PR_$color" "%{$terminfo[bold]$fg[${(L)color}]%}" + print -v "PR_LIGHT_$color" "%{$fg[${(L)color}]%}" +done +PR_NO_COLOUR="%{$terminfo[sgr0]%}" + +# Use extended characters to look nicer +PR_HBAR="-" +PR_ULCORNER="-" +PR_LLCORNER="-" +PR_LRCORNER="-" +PR_URCORNER="-" + +# Modify Git prompt +ZSH_THEME_GIT_PROMPT_PREFIX=" [" +ZSH_THEME_GIT_PROMPT_SUFFIX="]" + +# Modify RVM prompt +ZSH_THEME_RUBY_PROMPT_PREFIX=" [" +ZSH_THEME_RUBY_PROMPT_SUFFIX="]" - autoload zsh/terminfo - for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do - eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}' - eval PR_LIGHT_$color='%{$fg[${(L)color}]%}' - (( count = $count + 1 )) - done - PR_NO_COLOUR="%{$terminfo[sgr0]%}" - - -### -# See if we can use extended characters to look nicer. - PR_HBAR=${altchar[q]:--} - PR_ULCORNER=${altchar[l]:--} - PR_LLCORNER=${altchar[m]:--} - PR_LRCORNER=${altchar[j]:--} - PR_URCORNER=${altchar[k]:--} - - ### - # Modify Git prompt - ZSH_THEME_GIT_PROMPT_PREFIX=" [" - ZSH_THEME_GIT_PROMPT_SUFFIX="]" - ### - # Modify RVM prompt - ZSH_THEME_RUBY_PROMPT_PREFIX=" [" - ZSH_THEME_RUBY_PROMPT_SUFFIX="]" - - -### # Decide if we need to set titlebar text. - - case $TERM in +case $TERM in xterm*|*rxvt*) PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%M:%~ $(git_prompt_info) $(rvm_prompt_info) | ${COLUMNS}x${LINES} | %y\a%}' ;; @@ -101,26 +74,22 @@ setprompt () { PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}' ;; *) - PR_TITLEBAR='' + PR_TITLEBAR="" ;; - esac - +esac -### # Decide whether to set a screen title - if [[ "$TERM" == "screen" ]]; then - PR_STITLE=$'%{\ekzsh\e\\%}' - else - PR_STITLE='' - fi +if [[ "$TERM" == "screen" ]]; then + PR_STITLE=$'%{\ekzsh\e\\%}' +else + PR_STITLE="" +fi -### # Finally, the prompt. -# - PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\ +PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\ $PR_RED$PR_HBAR<\ $PR_BLUE%(!.$PR_RED%SROOT%s.%n)$PR_GREEN@$PR_BLUE%M:$PR_GREEN%$PR_PWDLEN<...<%~$PR_CYAN$(git_prompt_info)$(rvm_prompt_info)\ -$PR_RED>$PR_HBAR$PR_SPACE${(e)PR_FILLBAR}\ +$PR_RED>$PR_HBAR${(e)PR_FILLBAR}\ $PR_RED$PR_HBAR<\ $PR_GREEN%l$PR_RED>$PR_HBAR\ @@ -128,7 +97,3 @@ $PR_RED$PR_HBAR<\ %(?..$PR_LIGHT_RED%?$PR_BLUE:)\ $PR_LIGHT_BLUE%(!.$PR_RED.$PR_WHITE)%#$PR_RED>$PR_HBAR\ $PR_NO_COLOUR ' - -} - -setprompt -- cgit v1.2.3-70-g09d2 From e3bb6e685dc0325f472a4cfadb9847add12ec699 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 13 Dec 2021 17:12:31 +0100 Subject: refactor(themes): use `ruby_prompt_info` everywhere --- themes/aussiegeek.zsh-theme | 2 +- themes/josh.zsh-theme | 4 ++-- themes/murilasso.zsh-theme | 2 +- themes/simonoff.zsh-theme | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'themes/simonoff.zsh-theme') diff --git a/themes/aussiegeek.zsh-theme b/themes/aussiegeek.zsh-theme index c2c7f65b9..2ded5c157 100644 --- a/themes/aussiegeek.zsh-theme +++ b/themes/aussiegeek.zsh-theme @@ -1,5 +1,5 @@ -PROMPT='$fg_bold[blue][ $fg[red]%t $fg_bold[blue]] $fg_bold[blue] [ $fg[red]%n@%m:%~$(git_prompt_info)$fg[yellow]$(rvm_prompt_info)$fg_bold[blue] ]$reset_color +PROMPT='$fg_bold[blue][ $fg[red]%t $fg_bold[blue]] $fg_bold[blue] [ $fg[red]%n@%m:%~$(git_prompt_info)$fg[yellow]$(ruby_prompt_info)$fg_bold[blue] ]$reset_color $ ' # git theming ZSH_THEME_GIT_PROMPT_PREFIX="$fg_bold[green](" diff --git a/themes/josh.zsh-theme b/themes/josh.zsh-theme index c8f0f4dd7..ea051c58e 100644 --- a/themes/josh.zsh-theme +++ b/themes/josh.zsh-theme @@ -10,7 +10,7 @@ function josh_prompt { prompt=" " branch=$(git_current_branch) - ruby_version=$(rvm_prompt_info || rbenv_prompt_info) + ruby_version=$(ruby_prompt_info) path_size=${#PWD} branch_size=${#branch} ruby_size=${#ruby_version} @@ -31,7 +31,7 @@ function josh_prompt { prompt=" $prompt" done - prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(rvm_prompt_info || rbenv_prompt_info)%{$reset_color%} $(git_current_branch)" + prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(ruby_prompt_info)%{$reset_color%} $(git_current_branch)" echo $prompt } diff --git a/themes/murilasso.zsh-theme b/themes/murilasso.zsh-theme index bc2b9b224..d46874c54 100644 --- a/themes/murilasso.zsh-theme +++ b/themes/murilasso.zsh-theme @@ -1,7 +1,7 @@ local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}' local current_dir='%{$terminfo[bold]$fg[blue]%}%~%{$reset_color%}' -local rvm_ruby='%{$fg[red]%}$(rvm_prompt_info || rbenv_prompt_info)%{$reset_color%}' +local rvm_ruby='%{$fg[red]%}$(ruby_prompt_info)%{$reset_color%}' local git_branch='%{$fg[blue]%}$(git_prompt_info)%{$reset_color%}' PROMPT="${user_host}:${current_dir} ${rvm_ruby} diff --git a/themes/simonoff.zsh-theme b/themes/simonoff.zsh-theme index c906192a0..201d5d7e4 100644 --- a/themes/simonoff.zsh-theme +++ b/themes/simonoff.zsh-theme @@ -68,7 +68,7 @@ ZSH_THEME_RUBY_PROMPT_SUFFIX="]" # Decide if we need to set titlebar text. case $TERM in xterm*|*rxvt*) - PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%M:%~ $(git_prompt_info) $(rvm_prompt_info) | ${COLUMNS}x${LINES} | %y\a%}' + PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%M:%~ $(git_prompt_info) $(ruby_prompt_info) | ${COLUMNS}x${LINES} | %y\a%}' ;; screen) PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}' @@ -88,7 +88,7 @@ fi # Finally, the prompt. PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\ $PR_RED$PR_HBAR<\ -$PR_BLUE%(!.$PR_RED%SROOT%s.%n)$PR_GREEN@$PR_BLUE%M:$PR_GREEN%$PR_PWDLEN<...<%~$PR_CYAN$(git_prompt_info)$(rvm_prompt_info)\ +$PR_BLUE%(!.$PR_RED%SROOT%s.%n)$PR_GREEN@$PR_BLUE%M:$PR_GREEN%$PR_PWDLEN<...<%~$PR_CYAN$(git_prompt_info)$(ruby_prompt_info)\ $PR_RED>$PR_HBAR${(e)PR_FILLBAR}\ $PR_RED$PR_HBAR<\ $PR_GREEN%l$PR_RED>$PR_HBAR\ -- cgit v1.2.3-70-g09d2 From fb86ec7749644bba4792f95bd06076049d9c74a6 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 14 Dec 2021 13:09:02 +0100 Subject: style: use `typeset` for dynamic variable names --- plugins/dirhistory/dirhistory.plugin.zsh | 4 ++-- themes/adben.zsh-theme | 4 ++-- themes/jonathan.zsh-theme | 4 ++-- themes/simonoff.zsh-theme | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'themes/simonoff.zsh-theme') diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index 9f39264cf..2f5a79735 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -19,14 +19,14 @@ export DIRHISTORY_SIZE=30 # Returns the element if the array was not empty, # otherwise returns empty string. function pop_past() { - print -v $1 "${dirhistory_past[$#dirhistory_past]}" + typeset $1="${dirhistory_past[$#dirhistory_past]}" if [[ $#dirhistory_past -gt 0 ]]; then dirhistory_past[$#dirhistory_past]=() fi } function pop_future() { - print -v $1 "${dirhistory_future[$#dirhistory_future]}" + typeset $1="${dirhistory_future[$#dirhistory_future]}" if [[ $#dirhistory_future -gt 0 ]]; then dirhistory_future[$#dirhistory_future]=() fi diff --git a/themes/adben.zsh-theme b/themes/adben.zsh-theme index ddb34236b..a11f7b0a9 100644 --- a/themes/adben.zsh-theme +++ b/themes/adben.zsh-theme @@ -32,8 +32,8 @@ ########## COLOR ########### for COLOR in CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY; do - print -v "PR_$COLOR" "%b%{$fg[${(L)COLOR}]%}" - print -v "PR_BRIGHT_$COLOR" "%B%{$fg[${(L)COLOR}]%}" + typeset PR_$COLOR="%b%{$fg[${(L)COLOR}]%}" + typeset PR_BRIGHT_$COLOR="%B%{$fg[${(L)COLOR}]%}" done PR_RESET="%{$reset_color%}" diff --git a/themes/jonathan.zsh-theme b/themes/jonathan.zsh-theme index ca58b94a3..fc3cb2caa 100644 --- a/themes/jonathan.zsh-theme +++ b/themes/jonathan.zsh-theme @@ -37,8 +37,8 @@ setopt prompt_subst # See if we can use colors. autoload zsh/terminfo for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do - print -v "PR_$color" "%{$terminfo[bold]$fg[${(L)color}]%}" - print -v "PR_LIGHT_$color" "%{$fg[${(L)color}]%}" + typeset PR_$color="%{$terminfo[bold]$fg[${(L)color}]%}" + typeset PR_LIGHT_$color="%{$fg[${(L)color}]%}" done PR_NO_COLOUR="%{$terminfo[sgr0]%}" diff --git a/themes/simonoff.zsh-theme b/themes/simonoff.zsh-theme index 201d5d7e4..c7e35e160 100644 --- a/themes/simonoff.zsh-theme +++ b/themes/simonoff.zsh-theme @@ -45,8 +45,8 @@ setopt prompt_subst # See if we can use colors. autoload zsh/terminfo for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do - print -v "PR_$color" "%{$terminfo[bold]$fg[${(L)color}]%}" - print -v "PR_LIGHT_$color" "%{$fg[${(L)color}]%}" + typeset PR_$color="%{$terminfo[bold]$fg[${(L)color}]%}" + typeset PR_LIGHT_$color="%{$fg[${(L)color}]%}" done PR_NO_COLOUR="%{$terminfo[sgr0]%}" -- cgit v1.2.3-70-g09d2 From 7d03ea18eda8d89316fdb035fb3840f48a065338 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 16 Dec 2021 10:15:55 +0100 Subject: fix: declare variables as global when using `typeset` Fixes fb86ec77 --- plugins/dirhistory/dirhistory.plugin.zsh | 4 ++-- themes/adben.zsh-theme | 4 ++-- themes/jonathan.zsh-theme | 4 ++-- themes/simonoff.zsh-theme | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'themes/simonoff.zsh-theme') diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index 2f5a79735..8268147f6 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -19,14 +19,14 @@ export DIRHISTORY_SIZE=30 # Returns the element if the array was not empty, # otherwise returns empty string. function pop_past() { - typeset $1="${dirhistory_past[$#dirhistory_past]}" + typeset -g $1="${dirhistory_past[$#dirhistory_past]}" if [[ $#dirhistory_past -gt 0 ]]; then dirhistory_past[$#dirhistory_past]=() fi } function pop_future() { - typeset $1="${dirhistory_future[$#dirhistory_future]}" + typeset -g $1="${dirhistory_future[$#dirhistory_future]}" if [[ $#dirhistory_future -gt 0 ]]; then dirhistory_future[$#dirhistory_future]=() fi diff --git a/themes/adben.zsh-theme b/themes/adben.zsh-theme index a11f7b0a9..c2fdbed23 100644 --- a/themes/adben.zsh-theme +++ b/themes/adben.zsh-theme @@ -32,8 +32,8 @@ ########## COLOR ########### for COLOR in CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY; do - typeset PR_$COLOR="%b%{$fg[${(L)COLOR}]%}" - typeset PR_BRIGHT_$COLOR="%B%{$fg[${(L)COLOR}]%}" + typeset -g PR_$COLOR="%b%{$fg[${(L)COLOR}]%}" + typeset -g PR_BRIGHT_$COLOR="%B%{$fg[${(L)COLOR}]%}" done PR_RESET="%{$reset_color%}" diff --git a/themes/jonathan.zsh-theme b/themes/jonathan.zsh-theme index fc3cb2caa..48927f1db 100644 --- a/themes/jonathan.zsh-theme +++ b/themes/jonathan.zsh-theme @@ -37,8 +37,8 @@ setopt prompt_subst # See if we can use colors. autoload zsh/terminfo for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do - typeset PR_$color="%{$terminfo[bold]$fg[${(L)color}]%}" - typeset PR_LIGHT_$color="%{$fg[${(L)color}]%}" + typeset -g PR_$color="%{$terminfo[bold]$fg[${(L)color}]%}" + typeset -g PR_LIGHT_$color="%{$fg[${(L)color}]%}" done PR_NO_COLOUR="%{$terminfo[sgr0]%}" diff --git a/themes/simonoff.zsh-theme b/themes/simonoff.zsh-theme index c7e35e160..287781d9e 100644 --- a/themes/simonoff.zsh-theme +++ b/themes/simonoff.zsh-theme @@ -45,8 +45,8 @@ setopt prompt_subst # See if we can use colors. autoload zsh/terminfo for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do - typeset PR_$color="%{$terminfo[bold]$fg[${(L)color}]%}" - typeset PR_LIGHT_$color="%{$fg[${(L)color}]%}" + typeset -g PR_$color="%{$terminfo[bold]$fg[${(L)color}]%}" + typeset -g PR_LIGHT_$color="%{$fg[${(L)color}]%}" done PR_NO_COLOUR="%{$terminfo[sgr0]%}" -- cgit v1.2.3-70-g09d2