mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-15 01:48:34 -07:00
style: declare globals properly
By default, `typeset` defines variables locally unless in the main scope. This is specially bad when using `omz plugin load`, which happens inside a function, so the declared variables don't continue being defined when the function finishes and the main scope reappears.
This commit is contained in:
parent
31d63ea884
commit
d3bb52d7d8
@ -22,7 +22,7 @@ less_termcap[ue]="${reset_color}"
|
|||||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||||
|
|
||||||
# Absolute path to this file's directory.
|
# Absolute path to this file's directory.
|
||||||
typeset __colored_man_pages_dir="${0:A:h}"
|
typeset -g __colored_man_pages_dir="${0:A:h}"
|
||||||
|
|
||||||
function colored() {
|
function colored() {
|
||||||
local -a environment
|
local -a environment
|
||||||
|
@ -32,7 +32,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions"
|
|||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
# bind it to `deno`. Otherwise, compinit will have already done that.
|
# bind it to `deno`. Otherwise, compinit will have already done that.
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_deno" ]]; then
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_deno" ]]; then
|
||||||
declare -A _comps
|
typeset -g -A _comps
|
||||||
autoload -Uz _deno
|
autoload -Uz _deno
|
||||||
_comps[deno]=_deno
|
_comps[deno]=_deno
|
||||||
fi
|
fi
|
||||||
|
@ -18,7 +18,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions"
|
|||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
# bind it to `fnm`. Otherwise, compinit will have already done that.
|
# bind it to `fnm`. Otherwise, compinit will have already done that.
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnm" ]]; then
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnm" ]]; then
|
||||||
declare -A _comps
|
typeset -g -A _comps
|
||||||
autoload -Uz _fnm
|
autoload -Uz _fnm
|
||||||
_comps[fnm]=_fnm
|
_comps[fnm]=_fnm
|
||||||
fi
|
fi
|
||||||
|
@ -19,7 +19,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions"
|
|||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
# bind it to `gh`. Otherwise, compinit will have already done that.
|
# bind it to `gh`. Otherwise, compinit will have already done that.
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_gh" ]]; then
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_gh" ]]; then
|
||||||
declare -A _comps
|
typeset -g -A _comps
|
||||||
autoload -Uz _gh
|
autoload -Uz _gh
|
||||||
_comps[gh]=_gh
|
_comps[gh]=_gh
|
||||||
fi
|
fi
|
||||||
|
@ -14,7 +14,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions"
|
|||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
# bind it to `helm`. Otherwise, compinit will have already done that.
|
# bind it to `helm`. Otherwise, compinit will have already done that.
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_helm" ]]; then
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_helm" ]]; then
|
||||||
declare -A _comps
|
typeset -g -A _comps
|
||||||
autoload -Uz _helm
|
autoload -Uz _helm
|
||||||
_comps[helm]=_helm
|
_comps[helm]=_helm
|
||||||
fi
|
fi
|
||||||
|
@ -11,7 +11,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions"
|
|||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
# bind it to `rbw`. Otherwise, compinit will have already done that.
|
# bind it to `rbw`. Otherwise, compinit will have already done that.
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_rbw" ]]; then
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_rbw" ]]; then
|
||||||
declare -A _comps
|
typeset -g -A _comps
|
||||||
autoload -Uz _rbw
|
autoload -Uz _rbw
|
||||||
_comps[rbw]=_rbw
|
_comps[rbw]=_rbw
|
||||||
fi
|
fi
|
||||||
|
@ -11,7 +11,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions"
|
|||||||
# bind it to `cargo`. Otherwise, compinit will have already done that
|
# bind it to `cargo`. Otherwise, compinit will have already done that
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_cargo" ]]; then
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_cargo" ]]; then
|
||||||
autoload -Uz _cargo
|
autoload -Uz _cargo
|
||||||
declare -A _comps
|
typeset -g -A _comps
|
||||||
_comps[cargo]=_cargo
|
_comps[cargo]=_cargo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ fi
|
|||||||
# bind it to `rustup`. Otherwise, compinit will have already done that
|
# bind it to `rustup`. Otherwise, compinit will have already done that
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_rustup" ]]; then
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_rustup" ]]; then
|
||||||
autoload -Uz _rustup
|
autoload -Uz _rustup
|
||||||
declare -A _comps
|
typeset -g -A _comps
|
||||||
_comps[rustup]=_rustup
|
_comps[rustup]=_rustup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Completion
|
# Completion
|
||||||
fpath+=("${rvm_path}/scripts/zsh/Completion")
|
fpath+=("${rvm_path}/scripts/zsh/Completion")
|
||||||
|
|
||||||
declare -A _comps
|
typeset -g -A _comps
|
||||||
autoload -Uz _rvm
|
autoload -Uz _rvm
|
||||||
_comps[rvm]=_rvm
|
_comps[rvm]=_rvm
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions"
|
|||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
# bind it to `deno`. Otherwise, compinit will have already done that.
|
# bind it to `deno`. Otherwise, compinit will have already done that.
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_volta" ]]; then
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_volta" ]]; then
|
||||||
declare -A _comps
|
typeset -g -A _comps
|
||||||
autoload -Uz _volta
|
autoload -Uz _volta
|
||||||
_comps[volta]=_volta
|
_comps[volta]=_volta
|
||||||
fi
|
fi
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# The exit code visual cues will only display once.
|
# The exit code visual cues will only display once.
|
||||||
# (i.e. they will be reset, even if you hit enter a few times on empty command prompts)
|
# (i.e. they will be reset, even if you hit enter a few times on empty command prompts)
|
||||||
|
|
||||||
typeset -A host_repr
|
typeset -g -A host_repr
|
||||||
|
|
||||||
# translate hostnames into shortened, colorcoded strings
|
# translate hostnames into shortened, colorcoded strings
|
||||||
host_repr=('dieter-ws-a7n8x-arch' "%{$fg_bold[green]%}ws" 'dieter-p4sci-arch' "%{$fg_bold[blue]%}p4")
|
host_repr=('dieter-ws-a7n8x-arch' "%{$fg_bold[green]%}ws" 'dieter-p4sci-arch' "%{$fg_bold[blue]%}p4")
|
||||||
|
@ -66,7 +66,7 @@ if [[ "${langinfo[CODESET]}" = UTF-8 ]]; then
|
|||||||
PR_LRCORNER="┘"
|
PR_LRCORNER="┘"
|
||||||
PR_URCORNER="┐"
|
PR_URCORNER="┐"
|
||||||
else
|
else
|
||||||
typeset -A altchar
|
typeset -g -A altchar
|
||||||
set -A altchar ${(s..)terminfo[acsc]}
|
set -A altchar ${(s..)terminfo[acsc]}
|
||||||
# Some stuff to help us draw nice lines
|
# Some stuff to help us draw nice lines
|
||||||
PR_SET_CHARSET="%{$terminfo[enacs]%}"
|
PR_SET_CHARSET="%{$terminfo[enacs]%}"
|
||||||
|
Loading…
Reference in New Issue
Block a user