aboutsummaryrefslogtreecommitdiff
path: root/functions/utilities.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-03-18 19:24:56 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-03-18 19:24:56 +0300
commit85e9f4955ba859efc363ad98b78011af088a8333 (patch)
tree5f8e6b10a0525c1384a4e87478704fc0b19f2993 /functions/utilities.zsh
parent6e7ba250467d2cfc1916086c9ef0ce443dc58fb6 (diff)
expand string parameters with (g::) where appropriate
Diffstat (limited to 'functions/utilities.zsh')
-rwxr-xr-xfunctions/utilities.zsh12
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