Skip to content

Commit

Permalink
Merge commit '9d3e2f0204f2de5a0f04da1e0cdcf63e8afe5add'
Browse files Browse the repository at this point in the history
* commit '9d3e2f0204f2de5a0f04da1e0cdcf63e8afe5add':
  python: Expand compctl matches for pip variants
  command-not-found: Minor reformatting
  homebrew: Load 'HOMEBREW_' prefixed variables only
  homebrew: Simplify array assignment
  archive: Enhance 'archive' helper to support multi file archive
  git: add documentation for new aliases
  Aliases to digital sign/verify commits and tags (sorin-ionescu#651)
  syntax-highlighting: Further clarify relative module ordering
  rsync: Update link to Bombich rsync page again
  node: Make nvm lookup mechanism more efficient in homebrewed environment
  python: Fix pip compctl file match pattern
  command-not-found: Support custom Homebrew tap on MacOS
  node: Cache completion for additional helpers
  python: Use more apropriate filename for pip completion
  python: Make cached completion file mangling more reliable
  command-not-found: Restore idiomatic homebrewed handler loading on MacOS
  Update submodules versions
  Resolves sorin-ionescu#1641 - Roll the pure prompt back from 1.8.0 to 1.7.0
  Update submodules
  • Loading branch information
Andreas Pataki committed Dec 17, 2018
2 parents d55ff96 + 9d3e2f0 commit df0e99f
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 45 deletions.
32 changes: 13 additions & 19 deletions modules/archive/functions/archive
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

# function archive {

local archive_name dir_to_archive _gzip_bin _bzip2_bin
local archive_name path_to_archive _gzip_bin _bzip2_bin

if (( $# != 2 )); then
if (( $# < 2 )); then
cat >&2 <<EOF
usage: $0 [archive_name.zip] [/path/to/include/into/archive]
usage: $0 [archive_name.zip] [/path/to/include/into/archive ...]
Where 'archive.zip' uses any of the following extensions:
Expand All @@ -28,14 +28,8 @@ fi

# strip the path, just in case one is provided for some reason
archive_name="${1:t}"
# use absolute paths, and follow symlinks
dir_to_archive="${2}"

# if the directory doesn't exist, quit. Nothing to archive
if [[ ! -e "${dir_to_archive}" ]]; then
print "$0: file or directory not valid: ${dir_to_archive}" >&2
return 1
fi
# let paths be handled by actual archive helper
path_to_archive="${@:2}"

# here, we check for dropin/multi-threaded replacements
# this should eventually be moved to modules/archive/init.zsh
Expand All @@ -53,14 +47,14 @@ else
fi

case "${archive_name}" in
(*.tar.gz|*.tgz) tar -cvf "${archive_name}" --use-compress-program="${_gzip_bin}" "${dir_to_archive}" ;;
(*.tar.bz2|*.tbz|*.tbz2) tar -cvf "${archive_name}" --use-compress-program="${_bzip2_bin}" "${dir_to_archive}" ;;
(*.tar.xz|*.txz) tar -cvJf "${archive_name}" "${dir_to_archive}" ;;
(*.tar.lzma|*.tlz) tar -cvf "${archive_name}" --lzma "${dir_to_archive}" ;;
(*.tar) tar -cvf "${archive_name}" "${dir_to_archive}" ;;
(*.zip|*.jar) zip -r "${archive_name}" "${dir_to_archive}" ;;
(*.rar) rar a "${archive_name}" "${dir_to_archive}" ;;
(*.7z) 7za a "${archive_name}" "${dir_to_archive}" ;;
(*.tar.gz|*.tgz) tar -cvf "${archive_name}" --use-compress-program="${_gzip_bin}" "${=path_to_archive}" ;;
(*.tar.bz2|*.tbz|*.tbz2) tar -cvf "${archive_name}" --use-compress-program="${_bzip2_bin}" "${=path_to_archive}" ;;
(*.tar.xz|*.txz) tar -cvJf "${archive_name}" "${=path_to_archive}" ;;
(*.tar.lzma|*.tlz) tar -cvf "${archive_name}" --lzma "${=path_to_archive}" ;;
(*.tar) tar -cvf "${archive_name}" "${=path_to_archive}" ;;
(*.zip|*.jar) zip -r "${archive_name}" "${=path_to_archive}" ;;
(*.rar) rar a "${archive_name}" "${=path_to_archive}" ;;
(*.7z) 7za a "${archive_name}" "${=path_to_archive}" ;;
(*.gz) print "\n.gz is only useful for single files, and does not capture permissions. Use .tar.gz" ;;
(*.bz2) print "\n.bzip2 is only useful for single files, and does not capture permissions. Use .tar.bz2" ;;
(*.xz) print "\n.xz is only useful for single files, and does not capture permissions. Use .tar.xz" ;;
Expand Down
27 changes: 24 additions & 3 deletions modules/command-not-found/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,30 @@ if [[ -s '/etc/zsh_command_not_found' ]]; then
# Load command-not-found on Arch Linux-based distributions.
elif [[ -s '/usr/share/doc/pkgfile/command-not-found.zsh' ]]; then
source '/usr/share/doc/pkgfile/command-not-found.zsh'
# Load command-not-found on macOS when homebrew tap is configured.
elif [[ -s '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh' ]]; then
source '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh'
# Load command-not-found on macOS when Homebrew tap is configured.
# To avoid performance penalty, we do not use Homebrew's ruby based command
# lookup mechanism (viz., `brew command command-not-found-init`) and instead
# `find` it ourselves from `TAP_DIRECTORY` defined internally in Homebrew.
elif (( $+commands[brew] )); then
cnf_command=(
"$(brew --repository 2> /dev/null)"/Library/Taps/*/*/cmd/brew-command-not-found-init(|.rb)(.N)
)
if (( $#cnf_command )); then
cache_file="${TMPDIR:-/tmp}/prezto-brew-command-not-found-cache.$UID.zsh"

if [[ "${${(@o)cnf_command}[1]}" -nt "$cache_file" \
|| "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" \
|| ! -s "$cache_file" ]]; then
# brew command-not-found-init is slow; cache its output.
brew command-not-found-init >! "$cache_file" 2> /dev/null
fi

source "$cache_file"

unset cache_file
fi

unset cnf_command
# Return if requirements are not found.
else
return 1
Expand Down
4 changes: 4 additions & 0 deletions modules/git/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ zstyle ':prezto:module:git:alias' skip 'yes'
commits.
- `gcR` removes the *HEAD* commit.
- `gcs` displays various types of objects.
- `gcsS` displays commits with GPG signature.
- `gcl` lists lost commits.
- `gcy` displays commits yet to be applied to upstream in the short format.
- `gcY` displays commits yet to be applied to upstream.
Expand Down Expand Up @@ -220,6 +221,7 @@ zstyle ':prezto:module:git:alias' skip 'yes'
- `glg` displays the graph log.
- `glb` displays the brief commit log.
- `glc` displays the commit count for each contributor in descending order.
- `glS` displays the log and checks the validity of signed commits.

### Merge

Expand Down Expand Up @@ -295,6 +297,8 @@ zstyle ':prezto:module:git:alias' skip 'yes'

- `gt` lists tags or creates tag.
- `gtl` lists tags matching pattern.
- `gts` creates a signed tag.
- `gtv` validate a signed tag.

### Working directory

Expand Down
4 changes: 4 additions & 0 deletions modules/git/alias.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ if ! zstyle -t ':prezto:module:git:alias' skip 'yes'; then
alias gcr='git revert'
alias gcR='git reset "HEAD^"'
alias gcs='git show'
alias gcsS='git show --pretty=short --show-signature'
alias gcl='git-commit-lost'
alias gcy='git cherry -v --abbrev'
alias gcY='git cherry -v'
Expand Down Expand Up @@ -190,6 +191,7 @@ if ! zstyle -t ':prezto:module:git:alias' skip 'yes'; then
alias glg='git log --topo-order --all --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'

# Merge (m)
alias gm='git merge'
Expand Down Expand Up @@ -255,6 +257,8 @@ if ! zstyle -t ':prezto:module:git:alias' skip 'yes'; then
# Tag (t)
alias gt='git tag'
alias gtl='git tag -l'
alias gts='git tag -s'
alias gtv='git verify-tag'

# Working Copy (w)
alias gws='git status --ignore-submodules=${_git_status_ignore_submodules} --short'
Expand Down
14 changes: 7 additions & 7 deletions modules/homebrew/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ fi
# Variables
#

# Load standard Homebrew shellenv into the shell session.
# `brew shellenv` is relatively new, guard for legacy Homebrew.
# Load standard Homebrew shellenv into the shell session.
# Load 'HOMEBREW_' prefixed variables only. Avoid loading 'PATH' related
# variables as they are already handled in standard zsh configuration.
if (( $+commands[brew] )); then
eval "$(brew shellenv 2> /dev/null)"
eval "${(@M)${(f)"$(brew shellenv 2> /dev/null)"}:#export HOMEBREW*}"
fi

#
Expand Down Expand Up @@ -45,12 +46,11 @@ alias casks='hb_deprecated brew cask search'
alias caskx='brew cask uninstall'

function hb_deprecated {
local cmd="${argv[3]}"
local cmd_args=( ${(@)argv:4} )
local cmd="${@[3]}"
local cmd_args="${@:4}"

printf "'brew cask %s' has been deprecated, " "${cmd}"
printf "using 'brew %s' instead\n" "${cmd}"

cmd_args=( ${(@)argv:4} )
command brew "${cmd}" ${(@)cmd_args}
command brew "${cmd}" "${=cmd_args}"
}
38 changes: 25 additions & 13 deletions modules/node/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
source "$HOME/.nvm/nvm.sh"

# Load package manager installed NVM into the shell session.
elif (( $+commands[brew] )) && [[ -d "$(brew --prefix nvm 2> /dev/null)" ]]; then
elif (( $+commands[brew] )) && \
[[ -d "${nvm_prefix::="$(brew --prefix 2> /dev/null)"/opt/nvm}" ]]; then
source "$(brew --prefix nvm)/nvm.sh"
unset nvm_prefix

# Load manually installed nodenv into the shell session.
elif [[ -s "$HOME/.nodenv/bin/nodenv" ]]; then
Expand All @@ -28,18 +30,28 @@ elif (( ! $+commands[node] )); then
return 1
fi

# Load NPM completion.
if (( $+commands[npm] )); then
cache_file="${TMPDIR:-/tmp}/prezto-node-cache.$UID.zsh"
# Load NPM and known helper completions.
typeset -A compl_commands=(
npm 'npm completion'
grunt 'grunt --completion=zsh'
gupl 'gulp --completion=zsh'
)

if [[ "$commands[npm]" -nt "$cache_file" \
|| "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" \
|| ! -s "$cache_file" ]]; then
# npm is slow; cache its output.
npm completion >! "$cache_file" 2> /dev/null
fi
for compl_command in "${(k)compl_commands[@]}"; do
if (( $+commands[$compl_command] )); then
cache_file="${TMPDIR:-/tmp}/prezto-$compl_command-cache.$UID.zsh"

source "$cache_file"
# Completion commands are slow; cache their output if old or missing.
if [[ "$commands[$compl_command]" -nt "$cache_file" \
|| "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" \
|| ! -s "$cache_file" ]]; then
command ${=compl_commands[$compl_command]} >! "$cache_file" 2> /dev/null
fi

unset cache_file
fi
source "$cache_file"

unset cache_file
fi
done

unset compl_command{s,}
5 changes: 3 additions & 2 deletions modules/python/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ fi

# Load PIP completion.
if (( $#commands[(i)pip(|[23])] )); then
cache_file="${TMPDIR:-/tmp}/prezto-python-cache.$UID.zsh"
cache_file="${TMPDIR:-/tmp}/prezto-pip-cache.$UID.zsh"

# Detect and use one available from among 'pip', 'pip2', 'pip3' variants
pip_command="$commands[(i)pip(|[23])]"
Expand All @@ -160,10 +160,11 @@ if (( $#commands[(i)pip(|[23])] )); then
|| ! -s "$cache_file" ]]; then
# pip is slow; cache its output. And also support 'pip2', 'pip3' variants
$pip_command completion --zsh \
| sed -e "s|compctl -K [-_[:alnum:]]* pip|& pip2 pip3|" >! "$cache_file" 2> /dev/null
| sed -e "s/\(compctl -K [-_[:alnum:]]*\) pip.*/\1 pip(|[23](|.[0-9]))/" >! "$cache_file" 2> /dev/null
fi

source "$cache_file"

unset cache_file pip_command
fi

Expand Down
2 changes: 1 addition & 1 deletion modules/rsync/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if grep -q 'xattrs' <(rsync --help 2>&1); then
fi

# macOS and HFS+ Enhancements
# http://help.bombich.com/kb/overview/credits#opensource
# https://bombich.com/kb/ccc5/credits
if [[ "$OSTYPE" == darwin* ]] && grep -q 'file-flags' <(rsync --help 2>&1); then
_rsync_cmd="${_rsync_cmd} --crtimes --fileflags --protect-decmpfs --force-change"
fi
Expand Down
3 changes: 3 additions & 0 deletions modules/syntax-highlighting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Additionally, if this module is used in conjunction with the
*history-substring-search* module, this module must be loaded **before** the
*history-substring-search* module.

To elaborate: The relative order of loading the modules would be
'syntax-highlighting', 'history-substring-search' and 'prompt'.

Contributors
------------

Expand Down

0 comments on commit df0e99f

Please sign in to comment.