summaryrefslogtreecommitdiff
path: root/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2016-11-06 09:28:42 -0700
committerTuowen Zhao <ztuowen@gmail.com>2016-11-06 09:28:42 -0700
commitcd03efc2e5abc2925a0fe4e17f900bae0858b451 (patch)
tree8cbfca99a7a93008ccce68b2444009d4c1b59971 /plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
parentc24de867a4d036af486fdaa77b0fcccb148e2b98 (diff)
parent0b340bc3a5c58609a07987b296f773eaea17b274 (diff)
downloadzsh-cd03efc2e5abc2925a0fe4e17f900bae0858b451.tar.gz
zsh-cd03efc2e5abc2925a0fe4e17f900bae0858b451.tar.bz2
zsh-cd03efc2e5abc2925a0fe4e17f900bae0858b451.zip
Merge branch 'master' of https://github.com/robbyrussell/oh-my-zsh
Diffstat (limited to 'plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh')
-rwxr-xr-xplugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh35
1 files changed, 20 insertions, 15 deletions
diff --git a/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh b/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
index b26549152..32b4ca064 100755
--- a/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
+++ b/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
@@ -1,38 +1,43 @@
#!/usr/bin/env zsh
-REPO_DIR="${0%/*}"
-CONFIG_DIR="$HOME/.config/znt"
+0="${(%):-%N}" # this gives immunity to functionargzero being unset
+export ZNT_REPO_DIR="${0%/*}"
+export ZNT_CONFIG_DIR="$HOME/.config/znt"
#
# Copy configs
#
-if ! test -d "$HOME/.config"; then
- mkdir "$HOME/.config"
+if [[ ! -d "$HOME/.config" ]]; then
+ command mkdir "$HOME/.config"
fi
-if ! test -d "$CONFIG_DIR"; then
- mkdir "$CONFIG_DIR"
+if [[ ! -d "$ZNT_CONFIG_DIR" ]]; then
+ command mkdir "$ZNT_CONFIG_DIR"
fi
# 9 files
-set n-aliases.conf n-env.conf n-history.conf n-list.conf n-panelize.conf n-cd.conf n-functions.conf n-kill.conf n-options.conf
+unset __ZNT_CONFIG_FILES
+typeset -ga __ZNT_CONFIG_FILES
+set +A __ZNT_CONFIG_FILES n-aliases.conf n-env.conf n-history.conf n-list.conf n-panelize.conf n-cd.conf n-functions.conf n-kill.conf n-options.conf
# Check for random 2 files if they exist
# This will shift 0 - 7 elements
-shift $(( RANDOM % 8 ))
-if ! test -f "$CONFIG_DIR/$1" || ! test -f "$CONFIG_DIR/$2"; then
+shift $(( RANDOM % 8 )) __ZNT_CONFIG_FILES
+if [[ ! -f "$ZNT_CONFIG_DIR/${__ZNT_CONFIG_FILES[1]}" || ! -f "$ZNT_CONFIG_DIR/${__ZNT_CONFIG_FILES[2]}" ]]; then
# Something changed - examine every file
- set n-aliases.conf n-env.conf n-history.conf n-list.conf n-panelize.conf n-cd.conf n-functions.conf n-kill.conf n-options.conf
- for i; do
- if ! test -f "$CONFIG_DIR/$i"; then
- cp "$REPO_DIR/.config/znt/$i" "$CONFIG_DIR"
+ set +A __ZNT_CONFIG_FILES n-aliases.conf n-env.conf n-history.conf n-list.conf n-panelize.conf n-cd.conf n-functions.conf n-kill.conf n-options.conf
+ unset __ZNT_CONFIG_FILE
+ typeset -g __ZNT_CONFIG_FILE
+ for __ZNT_CONFIG_FILE in "${__ZNT_CONFIG_FILES[@]}"; do
+ if [[ ! -f "$ZNT_CONFIG_DIR/$__ZNT_CONFIG_FILE" ]]; then
+ command cp "$ZNT_REPO_DIR/.config/znt/$__ZNT_CONFIG_FILE" "$ZNT_CONFIG_DIR"
fi
done
+ unset __ZNT_CONFIG_FILE
fi
-# Don't leave positional parameters being set
-set --
+unset __ZNT_CONFIG_FILES
#
# Load functions