diff options
author | romkatv <roman.perepelitsa@gmail.com> | 2019-03-18 19:24:56 +0300 |
---|---|---|
committer | romkatv <roman.perepelitsa@gmail.com> | 2019-03-18 19:24:56 +0300 |
commit | 85e9f4955ba859efc363ad98b78011af088a8333 (patch) | |
tree | 5f8e6b10a0525c1384a4e87478704fc0b19f2993 /functions/utilities.zsh | |
parent | 6e7ba250467d2cfc1916086c9ef0ce443dc58fb6 (diff) |
expand string parameters with (g::) where appropriate
Diffstat (limited to 'functions/utilities.zsh')
-rwxr-xr-x | functions/utilities.zsh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 3a77eaca..0d04413e 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -30,6 +30,18 @@ function set_default() { fi } +function _p9k_g_expand() { + local -a ts=("${=$(typeset -p $1)}") + shift ts + for x in "${ts[@]}"; do + [[ $x == -* ]] || break + # Don't change readonly variables. Ideally, we shouldn't modify any variables at all, + # but for now this will do. + [[ $x == -*r* ]] && return + done + typeset -g $1=${(g::)${(P)1}} +} + # Converts large memory values into a human-readable unit (e.g., bytes --> GB) # Takes two arguments: # * $size - The number which should be prettified |