diff --git a/modules/command-not-found/init.zsh b/modules/command-not-found/init.zsh index fbe959c..601986a 100644 --- a/modules/command-not-found/init.zsh +++ b/modules/command-not-found/init.zsh @@ -15,9 +15,9 @@ elif [[ -s /usr/share/doc/pkgfile/command-not-found.zsh ]]; then # Load command-not-found on macOS when Homebrew is present. Check explicitly # for MacOS, since homebrew can be installed on Linux as a supplementary PM elif [[ "$OSTYPE" =~ ^darwin ]] && (( $+commands[brew] )); then - homebrew_repo=${HOMEBREW_REPOSITORY:-$commands[brew]:A:h:h/Library} + homebrew_repo=${HOMEBREW_REPOSITORY:-$commands[brew]:A:h:h} # Look for handler in Homebrew core (as of >=4.6.12), then in Taps (< 4.6.12) - for hb_cnf_handler in "$homebrew_repo"/{Homebrew/command-not-found/handler.sh,Taps/homebrew/homebrew-command-not-found/handler.sh}; do + for hb_cnf_handler in "$homebrew_repo"/{Library/Homebrew/command-not-found/handler.sh,Taps/homebrew/homebrew-command-not-found/handler.sh}; do if [ -f "$hb_cnf_handler" ]; then source "$hb_cnf_handler" unset hb_cnf_handler homebrew_repo diff --git a/modules/completion/external b/modules/completion/external index c160d09..e461417 160000 --- a/modules/completion/external +++ b/modules/completion/external @@ -1 +1 @@ -Subproject commit c160d09fddd28ceb3af5cf80e9253af80e450d96 +Subproject commit e461417f4e20b20f84b9d48a7acd582145723929 diff --git a/modules/editor/init.zsh b/modules/editor/init.zsh index 5798bc8..39e38d8 100644 --- a/modules/editor/init.zsh +++ b/modules/editor/init.zsh @@ -83,8 +83,8 @@ zle -N edit-command-line # Runs bindkey but for all of the keymaps. Running it with no arguments will # print out the mappings for all of the keymaps. function bindkey-all { - local keymap='' - for keymap in $(bindkey -l); do + local keymap + for keymap in "${(@f)$(bindkey -l)}"; do [[ "$#" -eq 0 ]] && printf "#### %s\n" "${keymap}" 1>&2 bindkey -M "${keymap}" "$@" done diff --git a/modules/git/README.md b/modules/git/README.md index fad57a1..ed2890b 100644 --- a/modules/git/README.md +++ b/modules/git/README.md @@ -318,11 +318,20 @@ zstyle ':prezto:module:git:alias' skip 'yes' index nor the working tree. - `gwR` resets the current HEAD, index and working tree to the specified state. - `gwc` removes untracked files from the working tree (dry-run). -- `gwC` removes untracked files from the working tree. +- `gwC` removes untracked files and directories from the working tree. - `gwx` removes files from the working tree and from the index recursively. - `gwX` removes files from the working tree and from the index recursively and forcefully. +### Working tree (W) + +- `gWa` adds a new working tree. +- `gWl` lists all working trees. +- `gWx` removes a working tree. +- `gWX` removes a working tree forcefully. +- `gWm` moves a working tree to a new location. +- `gWc` prunes stale worktrees and their administrative data. + ### Shadows The following aliases may shadow system commands: diff --git a/modules/git/alias.zsh b/modules/git/alias.zsh index f14cca5..977eaac 100644 --- a/modules/git/alias.zsh +++ b/modules/git/alias.zsh @@ -192,7 +192,7 @@ if ! zstyle -t ':prezto:module:git:alias' skip; then alias glg='git log --topo-order --graph --pretty=format:"$_git_log_oneline_format"' alias glb='git log --topo-order --pretty=format:"$_git_log_brief_format"' alias glc='git shortlog --summary --numbered' - alias glS='git log --show-signature' + alias glS='git log --topo-order --show-signature --pretty=format:"${_git_log_medium_format}"' # Merge (m) alias gm='git merge' @@ -269,7 +269,15 @@ if ! zstyle -t ':prezto:module:git:alias' skip; then alias gwr='git reset --soft' alias gwR='git reset --hard' alias gwc='git clean --dry-run' - alias gwC='git clean --force' + alias gwC='git clean -d --force' alias gwx='git rm -r' alias gwX='git rm -r --force' + + # Worktree management (W) + alias gWa='git worktree add' + alias gWl='git worktree list' + alias gWx='git worktree remove' + alias gWX='git worktree remove --force' + alias gWm='git worktree move' + alias gWc='git worktree prune' fi diff --git a/modules/git/functions/git-info b/modules/git/functions/git-info index eca5046..7bbcb09 100644 --- a/modules/git/functions/git-info +++ b/modules/git/functions/git-info @@ -246,7 +246,7 @@ function git-info { fi # Get the branch. - branch="${$(command git symbolic-ref HEAD 2> /dev/null)#refs/heads/}" + branch="$(escape-eval "${$(command git symbolic-ref HEAD 2> /dev/null)#refs/heads/}")" # Format branch. zstyle -s ':prezto:module:git:info:branch' format 'branch_format' @@ -257,7 +257,7 @@ function git-info { # Format position. zstyle -s ':prezto:module:git:info:position' format 'position_format' if [[ -z "$branch" && -n "$position_format" ]]; then - position="$(command git describe --contains --all HEAD 2> /dev/null)" + position="$(escape-eval "$(command git describe --contains --all HEAD 2> /dev/null)")" if [[ -n "$position" ]]; then zformat -f position_formatted "$position_format" "p:$position" fi @@ -268,7 +268,7 @@ function git-info { if [[ -n "$branch" && -n "$remote_format" ]]; then # Gets the remote name. remote_cmd='command git rev-parse --symbolic-full-name --verify HEAD@{upstream}' - remote="${$(${(z)remote_cmd} 2> /dev/null)##refs/remotes/}" + remote="$(escape-eval "${$(${(z)remote_cmd} 2> /dev/null)##refs/remotes/}")" if [[ -n "$remote" ]]; then zformat -f remote_formatted "$remote_format" "R:$remote" fi diff --git a/modules/helper/functions/escape-eval b/modules/helper/functions/escape-eval new file mode 100644 index 0000000..2836a13 --- /dev/null +++ b/modules/helper/functions/escape-eval @@ -0,0 +1,13 @@ +# +# Escapes a string for safe use in ${(e)...} parameter expansion. +# +# Authors: +# Trey Keown +# + +# function escape-eval { + +setopt LOCAL_OPTIONS EXTENDED_GLOB +print -r -- "${1//(#m)[\\\$\`]/\\$MATCH}" + +# } diff --git a/modules/history-substring-search/external b/modules/history-substring-search/external index 87ce96b..14c8d2e 160000 --- a/modules/history-substring-search/external +++ b/modules/history-substring-search/external @@ -1 +1 @@ -Subproject commit 87ce96b1862928d84b1afe7c173316614b30e301 +Subproject commit 14c8d2e0ffaee98f2df9850b19944f32546fdea5 diff --git a/modules/node/init.zsh b/modules/node/init.zsh index 0c27764..d23cef0 100644 --- a/modules/node/init.zsh +++ b/modules/node/init.zsh @@ -19,7 +19,7 @@ if (( $#local_nodenv_paths || $+commands[nodenv] )); then # Ensure manually installed nodenv is added to path when present. [[ -s $local_nodenv_paths[1] ]] && path=($local_nodenv_paths[1]:h $path) - eval "$(nodenv init - zsh)" + eval "$(nodenv init - --no-rehash zsh)" # Load manually installed nvm into the shell session. elif (( $#local_nvm_paths )); then diff --git a/modules/prompt/external/pure b/modules/prompt/external/pure index a02209d..dbefd0d 160000 --- a/modules/prompt/external/pure +++ b/modules/prompt/external/pure @@ -1 +1 @@ -Subproject commit a02209d36c8509c0e62f44324127632999c9c0cf +Subproject commit dbefd0dcafaa3ac7d7222ca50890d9d0c97f7ca2 diff --git a/modules/prompt/functions/prompt_cloud_setup b/modules/prompt/functions/prompt_cloud_setup index 908e3c9..b0eb86e 100644 --- a/modules/prompt/functions/prompt_cloud_setup +++ b/modules/prompt/functions/prompt_cloud_setup @@ -117,7 +117,7 @@ function prompt_cloud_setup { 'rprompt' '' # Define prompts. - PROMPT='%B%F{$primary_color}${prefix}%f%b %B%F{$secondary_color}%c%f%b ${git_info:+${(e)git_info[prompt]}} ' + PROMPT='%B%F{$primary_color}${prefix}%f%b %B%F{$secondary_color}%c%f%b ${git_info:+$(escape-eval ${(e)git_info[prompt]})} ' RPROMPT='' } diff --git a/modules/prompt/functions/prompt_damoekri_setup b/modules/prompt/functions/prompt_damoekri_setup index caff12d..553f222 100644 --- a/modules/prompt/functions/prompt_damoekri_setup +++ b/modules/prompt/functions/prompt_damoekri_setup @@ -27,11 +27,6 @@ prompt_damoekri_precmd() { if (( $+functions[ruby-info] )); then ruby-info fi - - # Get Openstack tenant information. - if (( $+functions[os-info] )); then - os-info - fi } function prompt_damoekri_setup { @@ -65,12 +60,9 @@ function prompt_damoekri_setup { # Set ruby-info parameters. zstyle ':prezto:module:ruby:info:version' format ' %F{yellow}%v%f' - # Set openstack tenant info - zstyle ':prezto:module:openstack:info:tenant' format '%s' - # Define prompts. - PROMPT='${os_info:+${os_info[tenant]} }%F{cyan}${_prompt_damoekri_pwd}%f${editor_info[keymap]} ' - RPROMPT='${git_info:+${(e)git_info[rprompt]}}${ruby_info:+${ruby_info[version]}}' + PROMPT='%F{cyan}${_prompt_damoekri_pwd}%f${editor_info[keymap]} ' + RPROMPT='${git_info:+$(escape-eval "${(e)git_info[rprompt]}")}${ruby_info:+$(escape-eval "${(e)ruby_info[version]}")}' } prompt_damoekri_setup "$@" diff --git a/modules/prompt/functions/prompt_kylewest_setup b/modules/prompt/functions/prompt_kylewest_setup index d3b33a9..2cd664b 100644 --- a/modules/prompt/functions/prompt_kylewest_setup +++ b/modules/prompt/functions/prompt_kylewest_setup @@ -61,7 +61,7 @@ function prompt_kylewest_setup { zstyle ':prezto:module:ruby:info:version' format '%F{blue}[%v]%f' # Define prompts. - PROMPT='%F{cyan}%c%f ${git_info:+${(e)git_info[prompt]}}${editor_info[keymap]} ' + PROMPT='%F{cyan}%c%f ${git_info:+$(escape-eval ${(e)git_info[prompt]})}${editor_info[keymap]} ' RPROMPT='${ruby_info[version]}' } diff --git a/modules/prompt/functions/prompt_paradox_setup b/modules/prompt/functions/prompt_paradox_setup index 9286967..14012dd 100644 --- a/modules/prompt/functions/prompt_paradox_setup +++ b/modules/prompt/functions/prompt_paradox_setup @@ -50,11 +50,11 @@ function prompt_paradox_build_prompt { prompt_paradox_start_segment blue black '$_prompt_paradox_pwd' if [[ -n "$git_info" ]]; then - prompt_paradox_start_segment green black '${(e)git_info[ref]}${(e)git_info[status]}' + prompt_paradox_start_segment green black '$(escape-eval "${(e)git_info[ref]}${(e)git_info[status]}")' fi if [[ -n "$python_info" ]]; then - prompt_paradox_start_segment white black '${(e)python_info[virtualenv]}' + prompt_paradox_start_segment white black '$(escape-eval "${(e)python_info[virtualenv]}")' fi prompt_paradox_end_segment diff --git a/modules/prompt/functions/prompt_skwp_setup b/modules/prompt/functions/prompt_skwp_setup index b84011f..1657fbf 100644 --- a/modules/prompt/functions/prompt_skwp_setup +++ b/modules/prompt/functions/prompt_skwp_setup @@ -71,7 +71,7 @@ function prompt_skwp_setup { zstyle ':prezto:module:ruby:info:version' format '[%v]' # Define prompts. - PROMPT="${_prompt_skwp_colors[3]}%n%f@${_prompt_skwp_colors[2]}%m%f ${_prompt_skwp_colors[5]}%~%f "'${git_info:+${(e)git_info[prompt]}}'"$ " + PROMPT="${_prompt_skwp_colors[3]}%n%f@${_prompt_skwp_colors[2]}%m%f ${_prompt_skwp_colors[5]}%~%f "'${git_info:+$(escape-eval "${(e)git_info[prompt]}")}'"$ " RPROMPT='%F{blue}${ruby_info[version]}' } diff --git a/modules/prompt/functions/prompt_smiley_setup b/modules/prompt/functions/prompt_smiley_setup index cd1725b..eb1a14a 100644 --- a/modules/prompt/functions/prompt_smiley_setup +++ b/modules/prompt/functions/prompt_smiley_setup @@ -60,7 +60,7 @@ function prompt_smiley_setup { zstyle ':prezto:module:git:info:keys' format 'prompt' '(%b%D)' # Define prompts. - PROMPT='$python_info[virtualenv]$ruby_info[version]${git_info:+${(e)git_info[prompt]}} %B%c%b %(?:%F{green}ツ%f:%F{red}✖%f) ' + PROMPT='$python_info[virtualenv]$ruby_info[version]${git_info:+$(escape-eval ${(e)git_info[prompt]})} %B%c%b %(?:%F{green}ツ%f:%F{red}✖%f) ' RPROMPT='${editor_info[overwrite]}${VIM:+" %B%F{green}V%f%b"}' SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? ' } diff --git a/modules/spectrum/init.zsh b/modules/spectrum/init.zsh index 37b7d7b..be8c9fc 100644 --- a/modules/spectrum/init.zsh +++ b/modules/spectrum/init.zsh @@ -56,14 +56,18 @@ FX=( FG[none]="$FX[none]" BG[none]="$FX[none]" colors=(black red green yellow blue magenta cyan white) -for color in {0..255}; do - if (( $color >= 0 )) && (( $color < $#colors )); then - index=$(( $color + 1 )) - FG[$colors[$index]]="\e[38;5;${color}m" - BG[$colors[$index]]="\e[48;5;${color}m" - fi +# Named ANSI colors (0–7) have both numeric and name keys. +for color in {0..7}; do + FG[$colors[color+1]]="\e[38;5;${color}m" + BG[$colors[color+1]]="\e[48;5;${color}m" FG[$color]="\e[38;5;${color}m" BG[$color]="\e[48;5;${color}m" done -unset color{s,} index + +# Remaining 256-color indices have only numeric keys. +for color in {8..255}; do + FG[$color]="\e[38;5;${color}m" + BG[$color]="\e[48;5;${color}m" +done +unset color{s,} diff --git a/modules/ssh/init.zsh b/modules/ssh/init.zsh index 6bf237c..d6de5fe 100644 --- a/modules/ssh/init.zsh +++ b/modules/ssh/init.zsh @@ -27,19 +27,20 @@ if [[ ! -S "$SSH_AUTH_SOCK" ]]; then # Start ssh-agent if not started. if ! ps -U "$LOGNAME" -o pid,ucomm | grep -q -- "${SSH_AGENT_PID:--1} ssh-agent"; then mkdir -p "$_ssh_agent_env:h" - eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")" + eval "$(print -l "${(@)${(f)"$(ssh-agent)"}:#echo *}" | tee "$_ssh_agent_env")" fi fi # Create a persistent SSH authentication socket. if [[ -S "$SSH_AUTH_SOCK" && "$SSH_AUTH_SOCK" != "$_ssh_agent_sock" ]]; then mkdir -p "$_ssh_agent_sock:h" - ln -sf "$SSH_AUTH_SOCK" "$_ssh_agent_sock" + ln -sf "$SSH_AUTH_SOCK" "$_ssh_agent_sock.$$" + mv -f "$_ssh_agent_sock.$$" "$_ssh_agent_sock" export SSH_AUTH_SOCK="$_ssh_agent_sock" fi # Load identities. -if ssh-add -l 2>&1 | grep -q 'The agent has no identities'; then +if [[ ${(@M)${(f)"$(ssh-add -l 2>&1)"}:#The agent has no identities*} ]]; then zstyle -a ':prezto:module:ssh:load' identities '_ssh_identities' # ssh-add has strange requirements for running SSH_ASKPASS, so we duplicate # them here. Essentially, if the other requirements are met, we redirect stdin diff --git a/modules/syntax-highlighting/external b/modules/syntax-highlighting/external index db085e4..1d85c69 160000 --- a/modules/syntax-highlighting/external +++ b/modules/syntax-highlighting/external @@ -1 +1 @@ -Subproject commit db085e4661f6aafd24e5acb5b2e17e4dd5dddf3e +Subproject commit 1d85c692615a25fe2293bdd44b34c217d5d2bf04 diff --git a/modules/utility/functions/diff b/modules/utility/functions/diff index 2e812f2..fb288a8 100644 --- a/modules/utility/functions/diff +++ b/modules/utility/functions/diff @@ -8,8 +8,10 @@ # function diff { if zstyle -t ':prezto:module:utility:diff' color \ + && [[ -t 1 ]] \ && (( $+commands[colordiff] )); then command diff "$@" | colordiff + return "${pipestatus[1]}" else command diff "$@" fi diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index 5b4bf80..cacd8be 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -76,7 +76,9 @@ if zstyle -T ':prezto:module:utility' safe-ops; then fi # ls -if [[ ${(@M)${(f)"$(ls --version 2>&1)"}:#*(GNU|lsd) *} ]]; then +_ls_version="$(ls --version 2>&1)" + +if [[ ${(@M)${(f)_ls_version}:#*(GNU|lsd|uutils) *} ]]; then # GNU Core Utilities if zstyle -T ':prezto:module:utility:ls' dirs-first; then @@ -123,10 +125,12 @@ alias lt='ll -tr' # Lists sorted by date, most recent last. alias lc='lt -c' # Lists sorted by date, most recent last, shows change time. alias lu='lt -u' # Lists sorted by date, most recent last, shows access time. -if [[ ${(@M)${(f)"$(ls --version 2>&1)"}:#*GNU *} ]]; then +if [[ ${(@M)${(f)_ls_version}:#*GNU *} ]]; then alias lx='ll -XB' # Lists sorted by extension (GNU only). fi +unset _ls_version + # Grep if zstyle -t ':prezto:module:utility:grep' color; then export GREP_COLOR=${GREP_COLOR:-'37;45'} # BSD.