1
0
Fork 0
mirror of synced 2024-11-22 15:25:34 -05:00

Unify the for syntax

For short single commands, prefer a one-liner `for` with the zsh syntax:
```
for x (foo bar) print ${x}
```
Otherwise just place `; do` on the same line as the POSIX `for ... in`:
```
for x in foo bar; do
  print ${x}
done
```

Closes #268
This commit is contained in:
Eric Nielsen 2018-04-25 08:59:19 -05:00 committed by GitHub
parent 1aa7d7a401
commit d371d80af2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 18 deletions

View file

@ -48,7 +48,7 @@ Installing Zim is easy. If you have a different shell framework installed (like
2. Paste this into your terminal to prepend the initialization templates to your configs: 2. Paste this into your terminal to prepend the initialization templates to your configs:
``` ```
setopt EXTENDED_GLOB setopt EXTENDED_GLOB
for template_file ( ${ZDOTDIR:-${HOME}}/.zim/templates/* ); do for template_file in ${ZDOTDIR:-${HOME}}/.zim/templates/*; do
user_file="${ZDOTDIR:-${HOME}}/.${template_file:t}" user_file="${ZDOTDIR:-${HOME}}/.${template_file:t}"
touch ${user_file} touch ${user_file}
( print -rn "$(<${template_file})$(<${user_file})" >! ${user_file} ) 2>/dev/null ( print -rn "$(<${template_file})$(<${user_file})" >! ${user_file} ) 2>/dev/null

View file

@ -37,13 +37,13 @@ fi
() { () {
local zmodule zmodule_dir zmodule_file local zmodule zmodule_dir zmodule_file
for zmodule (${zmodules}); do for zmodule in ${zmodules}; do
zmodule_dir=${ZIM_HOME}/modules/${zmodule} zmodule_dir=${ZIM_HOME}/modules/${zmodule}
if [[ ! -d ${zmodule_dir} ]]; then if [[ ! -d ${zmodule_dir} ]]; then
print "No such module \"${zmodule}\"." >&2 print "No such module \"${zmodule}\"." >&2
else else
for zmodule_file (${zmodule_dir}/init.zsh \ for zmodule_file in ${zmodule_dir}/init.zsh \
${zmodule_dir}/{,zsh-}${zmodule}.{zsh,plugin.zsh,zsh-theme,sh}); do ${zmodule_dir}/{,zsh-}${zmodule}.{zsh,plugin.zsh,zsh-theme,sh}; do
if [[ -f ${zmodule_file} ]]; then if [[ -f ${zmodule_file} ]]; then
source ${zmodule_file} source ${zmodule_file}
break break

View file

@ -22,7 +22,7 @@
done done
# zcompile enabled module scripts # zcompile enabled module scripts
for file (${ZIM_HOME}/modules/${^zmodules}/(^*test*/)#*.zsh{,-theme}(.NLk+1)); do for file in ${ZIM_HOME}/modules/${^zmodules}/(^*test*/)#*.zsh{,-theme}(.NLk+1); do
zrecompile -pq ${file} zrecompile -pq ${file}
done done

View file

@ -10,7 +10,5 @@ if command git branch --delete ${@} && \
read -q "?Also delete remote branch(es) ${remotes} [y/N]? "; then read -q "?Also delete remote branch(es) ${remotes} [y/N]? "; then
print print
local remote local remote
for remote (${remotes}); do for remote (${remotes}) command git push ${remote%%/*} :${remote#*/}
command git push ${remote%%/*} :${remote#*/}
done
fi fi

View file

@ -3,6 +3,4 @@ local git_root
git_root=$(git-root) || return 1 git_root=$(git-root) || return 1
# we are in a git repository. add parameters to .gitignore # we are in a git repository. add parameters to .gitignore
for file in "${@}"; do for file (${@}) print ${file} >>! "${git_root}/.gitignore"
print "${file}" >>! "${git_root}/.gitignore"
done

View file

@ -46,12 +46,8 @@ key_info=(
# Bind the keys # Bind the keys
local key local key
for key in "${(s: :)key_info[ControlLeft]}"; do for key (${(s: :)key_info[ControlLeft]}) bindkey ${key} backward-word
bindkey ${key} backward-word for key (${(s: :)key_info[ControlRight]}) bindkey ${key} forward-word
done
for key in "${(s: :)key_info[ControlRight]}"; do
bindkey ${key} forward-word
done
[[ -n ${key_info[Home]} ]] && bindkey ${key_info[Home]} beginning-of-line [[ -n ${key_info[Home]} ]] && bindkey ${key_info[Home]} beginning-of-line
[[ -n ${key_info[End]} ]] && bindkey ${key_info[End]} end-of-line [[ -n ${key_info[End]} ]] && bindkey ${key_info[End]} end-of-line

View file

@ -126,7 +126,7 @@ alias pacblame="${zpacman_frontend} -Qo"
# #
# source helper functions/aliases # source helper functions/aliases
for helper ( ${zpacman_helper[@]} ); do for helper in ${zpacman_helper[@]}; do
if [[ -s ${0:h}/helper_${helper}.zsh ]]; then if [[ -s ${0:h}/helper_${helper}.zsh ]]; then
source ${0:h}/helper_${helper}.zsh source ${0:h}/helper_${helper}.zsh
else else