diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7800b818c4..f4dc0d6160 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,7 +32,7 @@ there are a number of additional things to keep in mind. - Prefer `zstyle` over environment variables for configuration. - Prefer (( ... )) over [[ ... ]] for arithmetic expression. - Use the function keyword to define functions. - - The 80 character hard limit can be waved for readability. + - The 80 character hard limit can be waived for readability. #### Using an Alternative zprezto Directory diff --git a/README.md b/README.md index 18bcfcce4e..552784bae7 100644 --- a/README.md +++ b/README.md @@ -33,10 +33,11 @@ version is 4.3.11. done ``` - Note: If you already have any of the given config files, ln will error. In - simple cases you can add `source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"` to - the bottom of your `.zshrc` to load prezto but keep your config intact. For - more complicated setups, it is recommended that you back up your original + Note: If you already have any of the given configuration files, `ln` will + cause error. In simple cases you can load prezto by adding the line + `source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"` to the bottom of your + `.zshrc` and keep the rest of your Zsh configuration intact. For more + complicated setups, it is recommended that you back up your original configs and replace them with the provided prezto runcoms. 4. Set Zsh as your default shell: @@ -89,6 +90,10 @@ accompanying README files to learn of what is available. window or tab. ![sorin theme][2] + Note that the 'git' module may be required for special symbols to appear, + such as those on the right of the above image. Add `'git'` to the `pmodule` + list (under `zstyle ':prezto:load' pmodule \` in your *~/.zpreztorc*) to + enable this module. ### External Modules @@ -99,7 +104,7 @@ accompanying README files to learn of what is available. Note that module names need to be unique or they will cause an error when loading. - ```console + ```sh zstyle ':prezto:load' pmodule-dirs $HOME/.zprezto-contrib ``` @@ -126,6 +131,6 @@ This project is licensed under the MIT License. [3]: http://git-scm.com [4]: https://github.com [5]: http://gitimmersion.com -[6]: http://gitref.org +[6]: https://git.github.io/git-reference/ [7]: http://www.bash2zsh.com/zsh_refcard/refcard.pdf [8]: http://grml.org/zsh/zsh-lovers.html diff --git a/modules/README.md b/modules/README.md index 1c2cdc54d8..1ff4e61225 100644 --- a/modules/README.md +++ b/modules/README.md @@ -20,7 +20,7 @@ Integrates zsh-autosuggestions into Prezto. Command-Not-Found ----------------- -Loads the command-not-found tool on Debian-based distributions. +Loads the command-not-found tool on macOS or Debian-based distributions. Completion ---------- @@ -122,7 +122,7 @@ Initializes OCaml package management. OSX --- -Defines Mac OS X aliases and functions. +Defines macOS aliases and functions. Pacman ------ @@ -132,7 +132,7 @@ Provides aliases and functions for the Pacman package manager and frontends. Perl ---- -Enables local Perl module installation on Mac OS X and defines alises. +Enables local Perl module installation on macOS and defines alises. Prompt ------ diff --git a/modules/archive/README.md b/modules/archive/README.md index 600ff15d0e..c9806ea591 100644 --- a/modules/archive/README.md +++ b/modules/archive/README.md @@ -31,9 +31,9 @@ installed: - *.7z* requires `7za`. - *.deb* requires `ar`, `tar`. -Additionally, if `pigz` and/or `pbzip2` are installed, `archive` will use them over -their traditional counterparts, `gzip` and `bzip2` respectively, to take full advantage -of all available CPU cores for compression. +Additionally, if `pigz` and/or `pbzip2` are installed, `archive` will use them +over their traditional counterparts, `gzip` and `bzip2` respectively, to take +full advantage of all available CPU cores for compression. Alternatives ------------ diff --git a/modules/archive/functions/archive b/modules/archive/functions/archive index 0e3bb616bf..fab409e2c0 100644 --- a/modules/archive/functions/archive +++ b/modules/archive/functions/archive @@ -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 <&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 @@ -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" ;; diff --git a/modules/autosuggestions/README.md b/modules/autosuggestions/README.md index ad0f7eced9..48f9852887 100644 --- a/modules/autosuggestions/README.md +++ b/modules/autosuggestions/README.md @@ -1,8 +1,3 @@ -Autosuggestions ---------------- - -Integrates zsh-autosuggestions into Prezto. - Autosuggestions =============== @@ -46,6 +41,14 @@ To set the query found color, add the following line to *zpreztorc*: zstyle ':prezto:module:autosuggestions:color' found '' ``` +Troubleshooting +--------------- + +### Autosuggestions from previous sessions don't show up + +For autosuggestions from previous shell sessions to work, please make sure you +also have the `history` module enabled. + Authors ------- diff --git a/modules/command-not-found/README.md b/modules/command-not-found/README.md index 7775c92621..ee5a94d6d5 100644 --- a/modules/command-not-found/README.md +++ b/modules/command-not-found/README.md @@ -3,11 +3,12 @@ Command-Not-Found When you try to use a command that is not available locally, searches the package manager for a package offering that command and suggests -the proper install command. +the proper install command. -Debian-based and Arch Linux-based distributions use the [`command-not-found`][1] tool. +Debian and Arch Linux based distributions use the [`command-not-found`][1] tool. -macOS uses Homebrew's [`command-not-found` clone][2]. Note that you also need to [follow the instructions to tap the `command-not-found` homebrew repository][3]. +macOS uses Homebrew's [`command-not-found` clone][2]. Note that you also need to +[follow the instructions][3] to tap the `command-not-found` homebrew repository. Authors diff --git a/modules/command-not-found/init.zsh b/modules/command-not-found/init.zsh index 0e778031f1..f3d7ea6287 100644 --- a/modules/command-not-found/init.zsh +++ b/modules/command-not-found/init.zsh @@ -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 Mac OS X when homebrew tap is configured. -elif (( $+commands[brew] )) && brew command command-not-found-init > /dev/null 2>&1; then - eval "$(brew command-not-found-init)" +# 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 diff --git a/modules/completion/README.md b/modules/completion/README.md index 7efb3d96a8..dc2b9b837a 100644 --- a/modules/completion/README.md +++ b/modules/completion/README.md @@ -6,6 +6,19 @@ the [zsh-completions][1] project. This module must be loaded **after** the *utility* module. +Options +------- + + - `COMPLETE_IN_WORD` complete from both ends of a word. + - `ALWAYS_TO_END` move cursor to the end of a completed word. + - `PATH_DIRS` perform path search even on command names with slashes. + - `AUTO_MENU` show completion menu on a successive tab press. + - `AUTO_LIST` automatically list choices on ambiguous completion. + - `AUTO_PARAM_SLASH` if completed parameter is a directory, add a trailing slash. + - `EXTENDED_GLOB` needed for file modification glob modifiers with compinit. + - `MENU_COMPLETE` do not autoselect the first completion entry. + - `FLOW_CONTROL` disable start/stop characters in shell editor. + Settings -------- diff --git a/modules/completion/init.zsh b/modules/completion/init.zsh index e2cc2d4472..07acf13bf3 100644 --- a/modules/completion/init.zsh +++ b/modules/completion/init.zsh @@ -99,7 +99,7 @@ zstyle ':completion:*:history-words' remove-all-dups yes zstyle ':completion:*:history-words' list false zstyle ':completion:*:history-words' menu yes -# Environmental Variables +# Environment Variables zstyle ':completion::*:(-command-|export):*' fake-parameters ${${${_comps[(I)-value-*]#*,}%%,*}:#-*-} # Populate hostname completion. But allow ignoring custom entries from static @@ -107,7 +107,7 @@ zstyle ':completion::*:(-command-|export):*' fake-parameters ${${${_comps[(I)-va zstyle -a ':prezto:module:completion:*:hosts' etc-host-ignores '_etc_host_ignores' zstyle -e ':completion:*:hosts' hosts 'reply=( - ${=${=${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2> /dev/null)"}%%[#| ]*}//\]:[0-9]*/ }//,/ }//\[/ } + ${=${=${=${${(f)"$(cat {/etc/ssh/ssh_,~/.ssh/}known_hosts(|2)(N) 2> /dev/null)"}%%[#| ]*}//\]:[0-9]*/ }//,/ }//\[/ } ${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2> /dev/null))"}%%(\#${_etc_host_ignores:+|${(j:|:)~_etc_host_ignores}})*} ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2> /dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}} )' diff --git a/modules/directory/init.zsh b/modules/directory/init.zsh index 47191dfe4f..8abc1e2407 100644 --- a/modules/directory/init.zsh +++ b/modules/directory/init.zsh @@ -16,7 +16,6 @@ setopt PUSHD_IGNORE_DUPS # Do not store duplicates in the stack. setopt PUSHD_SILENT # Do not print the directory stack after pushd or popd. setopt PUSHD_TO_HOME # Push to home directory when no argument is given. setopt CDABLE_VARS # Change directory to a path stored in a variable. -setopt AUTO_NAME_DIRS # Auto add variable-stored paths to ~ list. setopt MULTIOS # Write to multiple descriptors. setopt EXTENDED_GLOB # Use extended globbing syntax. unsetopt CLOBBER # Do not overwrite existing files with > and >>. diff --git a/modules/editor/README.md b/modules/editor/README.md index c27e8642c0..d5280c45f5 100644 --- a/modules/editor/README.md +++ b/modules/editor/README.md @@ -1,7 +1,17 @@ Editor ====== -Sets key bindings. +Sets editor specific key bindings options and variables. + +Options +------- + + - `BEEP` beep on error in line editor. + +Variables +--------- + + - `WORDCHARS` treat a given set of characters as part of a word. Settings -------- diff --git a/modules/editor/init.zsh b/modules/editor/init.zsh index ed57a102fa..085947ef61 100644 --- a/modules/editor/init.zsh +++ b/modules/editor/init.zsh @@ -14,8 +14,7 @@ fi # Options # -# Beep on error in line editor. -setopt BEEP +setopt BEEP # Beep on error in line editor. # # Variables @@ -242,6 +241,27 @@ function glob-alias { } zle -N glob-alias +# Toggle the comment character at the start of the line. This is meant to work +# around a buggy implementation of pound-insert in zsh. +# +# This is currently only used for the emacs keys because vi-pound-insert has +# been reported to work properly. +function pound-toggle { + if [[ "$BUFFER" = '#'* ]]; then + # Because of an oddity in how zsh handles the cursor when the buffer size + # changes, we need to make this check before we modify the buffer and let + # zsh handle moving the cursor back if it's past the end of the line. + if [[ $CURSOR != $#BUFFER ]]; then + (( CURSOR -= 1 )) + fi + BUFFER="${BUFFER:1}" + else + BUFFER="#$BUFFER" + (( CURSOR += 1 )) + fi +} +zle -N pound-toggle + # Reset to default key bindings. bindkey -d @@ -277,6 +297,12 @@ if (( $+widgets[history-incremental-pattern-search-backward] )); then history-incremental-pattern-search-forward fi +# Toggle comment at the start of the line. Note that we use pound-toggle which +# is similar to pount insert, but meant to work around some issues that were +# being seen in iTerm. +bindkey -M emacs "$key_info[Escape];" pound-toggle + + # # Vi Key Bindings # @@ -296,6 +322,9 @@ else bindkey -M vicmd "/" history-incremental-search-forward fi +# Toggle comment at the start of the line. +bindkey -M vicmd "#" vi-pound-insert + # # Emacs and Vi Key Bindings # diff --git a/modules/environment/README.md b/modules/environment/README.md index b0d579bb45..15ee95922c 100644 --- a/modules/environment/README.md +++ b/modules/environment/README.md @@ -5,9 +5,6 @@ Sets general shell options and defines environment variables. This module must be loaded first. -Environment Variables ---------------------- - Contributors ------------ @@ -15,6 +12,39 @@ This module **MUST NOT** rely on any command not built in Zsh. Non-interactive environment variables should be defined in [`zshenv`][1]. +Options +------- + +### General + + - `COMBINING_CHARS` combine zero-length punctuation characters (accents) with + the base character. + - `INTERACTIVE_COMMENTS` enable comments in interactive shell. + - `RC_QUOTES` allow 'Henry''s Garage' instead of 'Henry'\''s Garage'. + - `MAIL_WARNING` don't print a warning message if a mail file has been accessed. + +### Jobs + + - `LONG_LIST_JOBS` list jobs in the long format by default. + - `AUTO_RESUME` attempt to resume existing job before creating a new process. + - `NOTIFY` report status of background jobs immediately. + - `BG_NICE` don't run all background jobs at a lower priority. + - `HUP` don't kill jobs on shell exit. + - `CHECK_JOBS` don't report on jobs when shell exit. + +Variables +--------- + +### Termcap + + - `LESS_TERMCAP_mb` begins blinking. + - `LESS_TERMCAP_md` begins bold. + - `LESS_TERMCAP_me` ends mode. + - `LESS_TERMCAP_se` ends standout-mode. + - `LESS_TERMCAP_so` begins standout-mode. + - `LESS_TERMCAP_ue` ends underline. + - `LESS_TERMCAP_us` begins underline. + Authors ------- diff --git a/modules/environment/init.zsh b/modules/environment/init.zsh index 79e98a4a24..7ae8c4f6a6 100644 --- a/modules/environment/init.zsh +++ b/modules/environment/init.zsh @@ -14,7 +14,7 @@ # paste had a regression. Additionally, 5.2 added bracketed-paste-url-magic # which is generally better than url-quote-magic so we load that when possible. autoload -Uz is-at-least -if [[ ${ZSH_VERSION} != 5.1.1 ]]; then +if [[ ${ZSH_VERSION} != 5.1.1 && ${TERM} != "dumb" ]]; then if is-at-least 5.2; then autoload -Uz bracketed-paste-url-magic zle -N bracketed-paste bracketed-paste-url-magic @@ -32,10 +32,11 @@ fi # General # -setopt COMBINING_CHARS # Combine zero-length punctuation characters (accents) - # with the base character. -setopt RC_QUOTES # Allow 'Henry''s Garage' instead of 'Henry'\''s Garage'. -unsetopt MAIL_WARNING # Don't print a warning message if a mail file has been accessed. +setopt COMBINING_CHARS # Combine zero-length punctuation characters (accents) + # with the base character. +setopt INTERACTIVE_COMMENTS # Enable comments in interactive shell. +setopt RC_QUOTES # Allow 'Henry''s Garage' instead of 'Henry'\''s Garage'. +unsetopt MAIL_WARNING # Don't print a warning message if a mail file has been accessed. # # Jobs diff --git a/modules/fasd/init.zsh b/modules/fasd/init.zsh index 113a8716f0..37babd8e3e 100644 --- a/modules/fasd/init.zsh +++ b/modules/fasd/init.zsh @@ -20,7 +20,9 @@ fi # cache_file="${TMPDIR:-/tmp}/prezto-fasd-cache.$UID.zsh" -if [[ "${commands[fasd]}" -nt "$cache_file" || ! -s "$cache_file" ]]; then +if [[ "${commands[fasd]}" -nt "$cache_file" \ + || "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" \ + || ! -s "$cache_file" ]]; then # Set the base init arguments. init_args=(zsh-hook) diff --git a/modules/git/README.md b/modules/git/README.md index bd67f712cc..e4425fab22 100644 --- a/modules/git/README.md +++ b/modules/git/README.md @@ -67,7 +67,7 @@ zstyle ':prezto:module:git:alias' skip 'yes' - `gcm` records changes to the repository with the given message. - `gcS` records changes to the repository. (Signed) - `gcSa` stages all modified and deleted files. (Signed) - - `gcSm` records changes to the repository with the given message. (Signed) - `gco` checks out a branch or paths to work tree. + - `gcSm` records changes to the repository with the given message. (Signed) - `gcam` stages all modified and deleted files, and records changes to the repository with the given message. - `gco` checks out a branch or paths to work tree. - `gcO` checks out hunks from the index or the tree interactively. @@ -81,7 +81,10 @@ 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. ### Conflict @@ -218,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 @@ -231,7 +235,8 @@ zstyle ':prezto:module:git:alias' skip 'yes' ### Push - `gp` updates remote refs along with associated objects. - - `gpf` forcefully updates remote refs along with associated objects. + - `gpf` forcefully updates remote refs along with associated objects using the safer `--force-with-lease` option. + - `gpF` forcefully updates remote refs along with associated objects using the riskier `--force` option. - `gpa` updates remote branches along with associated objects. - `gpA` updates remote branches and tags along with associated objects. - `gpt` updates remote tags along with associated objects. @@ -288,6 +293,13 @@ zstyle ':prezto:module:git:alias' skip 'yes' - `gSu` fetches and merges the latest changes for all submodule. - `gSx` removes a submodule. +### Tag + + - `gt` lists tags or creates tag. + - `gtl` lists tags matching pattern. + - `gts` creates a signed tag. + - `gtv` validate a signed tag. + ### Working directory - `gws` displays working-tree status in the short format. @@ -307,9 +319,10 @@ zstyle ':prezto:module:git:alias' skip 'yes' The following aliases may shadow system commands: - - `gpt` shadows the [GUID partition table maintenance utility][4]. - - `gs` shadows the [Ghostscript][5]. - `gb` shadows the [GB][9]. + - `gm` shadows the [Graphics Magick image processor][11]. + - `gpt` shadows the [GUID partition table maintenance utility][4]. + - `gs` shadows the [Ghostscript interpreter and previewer][5]. If you frequently use the above commands, you may wish to remove said aliases from this module or to disable them at the bottom of the zshrc with `unalias`. @@ -434,9 +447,10 @@ Authors [2]: https://github.com/defunkt/hub [3]: https://www.github.com [4]: http://www.manpagez.com/man/8/gpt/ -[5]: http://linux.die.net/man/1/gs +[5]: http://www.manpagez.com/man/1/gs/ [6]: https://github.com/sorin-ionescu/prezto/issues [7]: https://github.com/sorin-ionescu/prezto/issues/219 [8]: http://www.kernel.org/pub/software/scm/git/docs/git-log.html [9]: https://getgb.io/ [10]: https://github.com/blog/985-git-io-github-url-shortener +[11]: http://www.manpagez.com/man/1/gm/ diff --git a/modules/git/alias.zsh b/modules/git/alias.zsh index 4a5789fe1d..89ba558733 100644 --- a/modules/git/alias.zsh +++ b/modules/git/alias.zsh @@ -68,7 +68,10 @@ 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' # Conflict (C) alias gCl='git --no-pager diff --name-only --diff-filter=U' @@ -188,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' @@ -250,6 +254,12 @@ if ! zstyle -t ':prezto:module:git:alias' skip 'yes'; then alias gSu='git submodule foreach git pull origin master' alias gSx='git-submodule-remove' + # 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' alias gwS='git status --ignore-submodules=${_git_status_ignore_submodules}' diff --git a/modules/git/functions/_git-hub-browse b/modules/git/functions/_git-hub-browse index 9e6d6f0d5c..075314bb90 100644 --- a/modules/git/functions/_git-hub-browse +++ b/modules/git/functions/_git-hub-browse @@ -8,7 +8,7 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then return 1 fi @@ -21,7 +21,7 @@ _arguments -C -s -S \ case "$state" in (remote) - remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2)) + remotes=($(command git config --get-regexp 'remote.*.url' | cut -d. -f2)) _describe -t branch 'remotes' remotes && ret=0 ;; @@ -29,7 +29,7 @@ case "$state" in remote="$words[(($CURRENT - 1))]" branches_or_tags=($( - git ls-remote --heads --tags "$remote" 2> /dev/null | cut -f2 + command git ls-remote --heads --tags "$remote" 2> /dev/null | cut -f2 )) branches=(HEAD ${${(M)branches_or_tags[@]##refs/heads/?##}##refs/heads/}) @@ -39,7 +39,7 @@ case "$state" in _describe -t tag 'tags' tags && ret=0 ;; (file) - files=(${(0)"$(_call_program files git ls-files -z --exclude-standard 2> /dev/null)"}) + files=(${(0)"$(_call_program files command git ls-files -z --exclude-standard 2> /dev/null)"}) _wanted file expl 'file' _multi_parts - / files && ret=0 ;; esac diff --git a/modules/git/functions/_git-info b/modules/git/functions/_git-info index 1e21bfeb1a..ef6d97026b 100644 --- a/modules/git/functions/_git-info +++ b/modules/git/functions/_git-info @@ -8,7 +8,7 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then return 1 fi diff --git a/modules/git/functions/_git-submodule-move b/modules/git/functions/_git-submodule-move index 44eddb5402..5f2122c4d1 100644 --- a/modules/git/functions/_git-submodule-move +++ b/modules/git/functions/_git-submodule-move @@ -8,7 +8,7 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then return 1 fi @@ -25,7 +25,7 @@ case "$state" in while IFS=$'\n' read submodule; do submodules+=("$submodule") done < <( - git config --file "$(git-root)/.gitmodules" --list \ + command git config --file "$(git-root)/.gitmodules" --list \ | grep '.path=' \ | cut -d= -f2- ) diff --git a/modules/git/functions/_git-submodule-remove b/modules/git/functions/_git-submodule-remove index 87bd7cb006..819dfd8e36 100644 --- a/modules/git/functions/_git-submodule-remove +++ b/modules/git/functions/_git-submodule-remove @@ -8,7 +8,7 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then return 1 fi @@ -18,7 +18,7 @@ local submodule while IFS=$'\n' read submodule; do submodules+=("$submodule") done < <( - git config --file "$(git-root)/.gitmodules" --list \ + command git config --file "$(git-root)/.gitmodules" --list \ | grep '.path=' \ | cut -d= -f2- ) diff --git a/modules/git/functions/git-branch-current b/modules/git/functions/git-branch-current index cadb6f63df..3cf2e191d1 100644 --- a/modules/git/functions/git-branch-current +++ b/modules/git/functions/git-branch-current @@ -7,12 +7,12 @@ # function git-branch-current { -if ! git rev-parse 2> /dev/null; then +if ! command git rev-parse 2> /dev/null; then print "$0: not a repository: $PWD" >&2 return 1 fi -local ref="$(git symbolic-ref HEAD 2> /dev/null)" +local ref="$(command git symbolic-ref HEAD 2> /dev/null)" if [[ -n "$ref" ]]; then print "${ref#refs/heads/}" diff --git a/modules/git/functions/git-commit-lost b/modules/git/functions/git-commit-lost index 62789ac916..1f086d3b95 100644 --- a/modules/git/functions/git-commit-lost +++ b/modules/git/functions/git-commit-lost @@ -7,15 +7,15 @@ # function git-commit-lost { -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 fi -git fsck 2> /dev/null \ +command git fsck 2> /dev/null \ | grep "^dangling commit" \ | awk '{print $3}' \ - | git log \ + | command git log \ --date-order \ --no-walk \ --stdin \ diff --git a/modules/git/functions/git-dir b/modules/git/functions/git-dir index fdb515c5d4..aacaaa8866 100644 --- a/modules/git/functions/git-dir +++ b/modules/git/functions/git-dir @@ -7,7 +7,7 @@ # function git-dir { -local git_dir="${$(git rev-parse --git-dir):A}" +local git_dir="${$(command git rev-parse --git-dir):A}" if [[ -n "$git_dir" ]]; then print "$git_dir" diff --git a/modules/git/functions/git-hub-browse b/modules/git/functions/git-hub-browse index a365a5a9ae..cb3fc60de8 100644 --- a/modules/git/functions/git-hub-browse +++ b/modules/git/functions/git-hub-browse @@ -7,7 +7,7 @@ # function git-hub-browse { -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 fi @@ -15,7 +15,7 @@ fi local remotes remote references reference file url remote="${1:-origin}" -remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2)) +remotes=($(command git config --get-regexp 'remote.*.url' | cut -d. -f2)) if (( $remotes[(i)$remote] == $#remotes + 1 )); then print "$0: remote not found: $remote" >&2 @@ -23,14 +23,14 @@ if (( $remotes[(i)$remote] == $#remotes + 1 )); then fi url=$( - git config --get "remote.${remote}.url" \ + command git config --get "remote.${remote}.url" \ | sed -En "s/(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p" ) reference="${${2:-$(git-branch-current)}:-HEAD}" references=( HEAD - ${$(git ls-remote --heads --tags "$remote" | awk '{print $2}')##refs/(heads|tags)/} + ${$(command git ls-remote --heads --tags "$remote" | awk '{print $2}')##refs/(heads|tags)/} ) if (( $references[(i)$reference] == $#references + 1 )); then @@ -39,7 +39,7 @@ if (( $references[(i)$reference] == $#references + 1 )); then fi if [[ "$reference" == 'HEAD' ]]; then - reference="$(git rev-parse HEAD 2> /dev/null)" + reference="$(command git rev-parse HEAD 2> /dev/null)" fi file="$3" diff --git a/modules/git/functions/git-info b/modules/git/functions/git-info index d27365c243..fe8ca2acd9 100644 --- a/modules/git/functions/git-info +++ b/modules/git/functions/git-info @@ -178,15 +178,15 @@ function git-info { typeset -gA git_info # Return if not inside a Git repository work tree. - if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then + if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then return 1 fi if (( $# > 0 )); then if [[ "$1" == [Oo][Nn] ]]; then - git config --bool prompt.showinfo true + command git config --bool prompt.showinfo true elif [[ "$1" == [Oo][Ff][Ff] ]]; then - git config --bool prompt.showinfo false + command git config --bool prompt.showinfo false else print "usage: $0 [ on | off ]" >&2 fi @@ -194,7 +194,7 @@ function git-info { fi # Return if git-info is disabled. - if ! is-true "${$(git config --bool prompt.showinfo):-true}"; then + if ! is-true "${$(command git config --bool prompt.showinfo):-true}"; then return 1 fi @@ -204,7 +204,7 @@ function git-info { # Format commit. zstyle -s ':prezto:module:git:info:commit' format 'commit_format' if [[ -n "$commit_format" ]]; then - commit="$(git rev-parse HEAD 2> /dev/null)" + commit="$(command git rev-parse HEAD 2> /dev/null)" if [[ -n "$commit" ]]; then zformat -f commit_formatted "$commit_format" "c:$commit" fi @@ -212,10 +212,17 @@ function git-info { # Format stashed. zstyle -s ':prezto:module:git:info:stashed' format 'stashed_format' - if [[ -n "$stashed_format" && -f "$(git-dir)/refs/stash" ]]; then - stashed="$(git stash list 2> /dev/null | wc -l | awk '{print $1}')" - if [[ -n "$stashed" ]]; then - zformat -f stashed_formatted "$stashed_format" "S:$stashed" + if [[ -n "$stashed_format" ]]; then + commondir="" + if [[ -f "$(git-dir)/commondir" ]]; then + commondir="$(<$(git-dir)/commondir)" + [[ "$commondir" =~ ^/ ]] || commondir="$(git-dir)/$commondir" + fi + if [[ -f "$(git-dir)/refs/stash" || ( -n "$commondir" && -f "$commondir/refs/stash" ) ]]; then + stashed="$(command git stash list 2> /dev/null | wc -l | awk '{print $1}')" + if [[ -n "$stashed" ]]; then + zformat -f stashed_formatted "$stashed_format" "S:$stashed" + fi fi fi @@ -229,7 +236,7 @@ function git-info { fi # Get the branch. - branch="${$(git symbolic-ref HEAD 2> /dev/null)#refs/heads/}" + branch="${$(command git symbolic-ref HEAD 2> /dev/null)#refs/heads/}" # Format branch. zstyle -s ':prezto:module:git:info:branch' format 'branch_format' @@ -240,7 +247,7 @@ function git-info { # Format position. zstyle -s ':prezto:module:git:info:position' format 'position_format' if [[ -z "$branch" && -n "$position_format" ]]; then - position="$(git describe --contains --all HEAD 2> /dev/null)" + position="$(command git describe --contains --all HEAD 2> /dev/null)" if [[ -n "$position" ]]; then zformat -f position_formatted "$position_format" "p:$position" fi @@ -250,7 +257,7 @@ function git-info { zstyle -s ':prezto:module:git:info:remote' format 'remote_format' if [[ -n "$branch" && -n "$remote_format" ]]; then # Gets the remote name. - remote_cmd='git rev-parse --symbolic-full-name --verify HEAD@{upstream}' + remote_cmd='command git rev-parse --symbolic-full-name --verify HEAD@{upstream}' remote="${$(${(z)remote_cmd} 2> /dev/null)##refs/remotes/}" if [[ -n "$remote" ]]; then zformat -f remote_formatted "$remote_format" "R:$remote" @@ -261,7 +268,7 @@ function git-info { zstyle -s ':prezto:module:git:info:behind' format 'behind_format' if [[ -n "$branch" && ( -n "$ahead_format" || -n "$behind_format" ) ]]; then # Gets the commit difference counts between local and remote. - ahead_and_behind_cmd='git rev-list --count --left-right HEAD...@{upstream}' + ahead_and_behind_cmd='command git rev-list --count --left-right HEAD...@{upstream}' # Get ahead and behind counts. ahead_and_behind="$(${(z)ahead_and_behind_cmd} 2> /dev/null)" @@ -290,7 +297,7 @@ function git-info { if [[ -n "$indexed_format" ]]; then (( indexed+=$( - git diff-index \ + command git diff-index \ --no-ext-diff \ --name-only \ --cached \ @@ -310,7 +317,7 @@ function git-info { if [[ -n "$unindexed_format" ]]; then (( unindexed+=$( - git diff-files \ + command git diff-files \ --no-ext-diff \ --name-only \ --ignore-submodules=${ignore_submodules:-none} \ @@ -328,7 +335,7 @@ function git-info { if [[ -n "$untracked_format" ]]; then (( untracked+=$( - git ls-files \ + command git ls-files \ --other \ --exclude-standard \ 2> /dev/null \ @@ -343,7 +350,7 @@ function git-info { (( dirty = indexed + unindexed + untracked )) else # Use porcelain status for easy parsing. - status_cmd="git status --porcelain --ignore-submodules=${ignore_submodules:-none}" + status_cmd="command git status --porcelain --ignore-submodules=${ignore_submodules:-none}" # Get current status. while IFS=$'\n' read line; do diff --git a/modules/git/functions/git-root b/modules/git/functions/git-root index f749457205..643f346b36 100644 --- a/modules/git/functions/git-root +++ b/modules/git/functions/git-root @@ -7,7 +7,7 @@ # function git-root { -local root="$(git rev-parse --show-toplevel 2> /dev/null)" +local root="$(command git rev-parse --show-toplevel 2> /dev/null)" if [[ -n "$root" ]]; then print "$root" diff --git a/modules/git/functions/git-stash-clear-interactive b/modules/git/functions/git-stash-clear-interactive index 71468aa0e0..cc665a1829 100644 --- a/modules/git/functions/git-stash-clear-interactive +++ b/modules/git/functions/git-stash-clear-interactive @@ -7,7 +7,7 @@ # function git-stash-clear-interactive { -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 fi @@ -15,10 +15,10 @@ fi local stashed if [[ -f "$(git-dir)/refs/stash" ]]; then - stashed="$(git stash list 2> /dev/null | wc -l | awk '{print $1}')" + stashed="$(command git stash list 2> /dev/null | wc -l | awk '{print $1}')" if (( $stashed > 0 )); then if read -q "?Clear $stashed stashed state(s) [y/N]? "; then - git stash clear + command git stash clear fi fi fi diff --git a/modules/git/functions/git-stash-dropped b/modules/git/functions/git-stash-dropped index 2a0b7a94e7..d9e759e872 100644 --- a/modules/git/functions/git-stash-dropped +++ b/modules/git/functions/git-stash-dropped @@ -7,15 +7,15 @@ # function git-stash-dropped { -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 fi -git fsck --unreachable 2> /dev/null \ +command git fsck --unreachable 2> /dev/null \ | grep 'commit' \ | awk '{print $3}' \ - | git log \ + | command git log \ --pretty=format:${_git_log_oneline_format} \ --extended-regexp \ --grep="${1:-(WIP )?[Oo]n [^:]+:}" \ diff --git a/modules/git/functions/git-stash-recover b/modules/git/functions/git-stash-recover index 5cc949a730..6cb5416e6c 100644 --- a/modules/git/functions/git-stash-recover +++ b/modules/git/functions/git-stash-recover @@ -7,7 +7,7 @@ # function git-stash-recover { -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 fi @@ -15,8 +15,8 @@ fi local commit for commit in "$@"; do - git update-ref \ - -m "$(git log -1 --pretty="format:%s" "$commit")" refs/stash "$commit" + command git update-ref \ + -m "$(command git log -1 --pretty="format:%s" "$commit")" refs/stash "$commit" done # } diff --git a/modules/git/functions/git-submodule-move b/modules/git/functions/git-submodule-move index ec6048e68e..746f46e512 100644 --- a/modules/git/functions/git-submodule-move +++ b/modules/git/functions/git-submodule-move @@ -7,7 +7,7 @@ # function git-submodule-move { -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 elif [[ "$PWD" != "$(git-root)" ]]; then @@ -19,7 +19,7 @@ local src="$1" local dst="$2" local url -url="$(git config --file "$(git-root)/.gitmodules" --get "submodule.${src}.url")" +url="$(command git config --file "$(git-root)/.gitmodules" --get "submodule.${src}.url")" if [[ -z "$url" ]]; then print "$0: submodule not found: $src" >&2 @@ -29,7 +29,7 @@ fi mkdir -p "${dst:h}" git-submodule-remove "$src" -git submodule add "$url" "$dst" +command git submodule add "$url" "$dst" return 0 diff --git a/modules/git/functions/git-submodule-remove b/modules/git/functions/git-submodule-remove index 2490e78c87..c8c11aa8c3 100644 --- a/modules/git/functions/git-submodule-remove +++ b/modules/git/functions/git-submodule-remove @@ -7,22 +7,22 @@ # function git-submodule-remove { -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 elif [[ "$PWD" != "$(git-root)" ]]; then print "$0: must be run from the root of the work tree" >&2 return 1 -elif ! git config --file .gitmodules --get "submodule.${1}.path" &>/dev/null; then +elif ! command git config --file .gitmodules --get "submodule.${1}.path" &> /dev/null; then print "$0: submodule not found: $1" >&2 return 1 fi -git config --file "$(git-dir)/config" --remove-section "submodule.${1}" &>/dev/null -git config --file "$(git-root)/.gitmodules" --remove-section "submodule.${1}" &>/dev/null -git add .gitmodules +command git config --file "$(git-dir)/config" --remove-section "submodule.${1}" &> /dev/null +command git config --file "$(git-root)/.gitmodules" --remove-section "submodule.${1}" &> /dev/null +command git add .gitmodules -git rm --cached -rf "${1}" +command git rm --cached -rf "${1}" rm -rf "${1}" rm -rf "$(git-dir)/modules/${1}" diff --git a/modules/gnu-utility/init.zsh b/modules/gnu-utility/init.zsh index cbf9a4baa8..4675a3ca56 100644 --- a/modules/gnu-utility/init.zsh +++ b/modules/gnu-utility/init.zsh @@ -15,16 +15,16 @@ fi _gnu_utility_cmds=( # Coreutils - '[' 'base64' 'basename' 'cat' 'chcon' 'chgrp' 'chmod' 'chown' + '[' 'b2sum' 'base32' 'base64' 'basename' 'cat' 'chcon' 'chgrp' 'chmod' 'chown' 'chroot' 'cksum' 'comm' 'cp' 'csplit' 'cut' 'date' 'dd' 'df' 'dir' 'dircolors' 'dirname' 'du' 'echo' 'env' 'expand' 'expr' 'factor' 'false' 'fmt' 'fold' 'groups' 'head' 'hostid' 'id' - 'install' 'join' 'kill' 'link' 'ln' 'logname' 'ls' 'md5sum' - 'mkdir' 'mkfifo' 'mknod' 'mktemp' 'mv' 'nice' 'nl' 'nohup' 'nproc' - 'od' 'paste' 'pathchk' 'pinee' 'pr' 'printenv' 'printf' 'ptx' + 'install' 'join' 'kill' 'link' 'ln' 'logname' 'ls' 'md5sum' 'mkdir' + 'mkfifo' 'mknod' 'mktemp' 'mv' 'nice' 'nl' 'nohup' 'nproc' + 'numfmt' 'od' 'paste' 'pathchk' 'pinky' 'pr' 'printenv' 'printf' 'ptx' 'pwd' 'readlink' 'realpath' 'rm' 'rmdir' 'runcon' 'seq' 'sha1sum' 'sha224sum' 'sha256sum' 'sha384sum' 'sha512sum' 'shred' 'shuf' - 'sleep' 'sort' 'split' 'stat' 'stty' 'sum' 'sync' 'tac' 'tail' + 'sleep' 'sort' 'split' 'stat' 'stdbuf' 'stty' 'sum' 'sync' 'tac' 'tail' 'tee' 'test' 'timeout' 'touch' 'tr' 'true' 'truncate' 'tsort' 'tty' 'uname' 'unexpand' 'uniq' 'unlink' 'uptime' 'users' 'vdir' 'wc' 'who' 'whoami' 'yes' diff --git a/modules/history/README.md b/modules/history/README.md index 3dc9a26423..d020688a56 100644 --- a/modules/history/README.md +++ b/modules/history/README.md @@ -3,13 +3,6 @@ History Sets [history][1] options and defines history aliases. -Variables ---------- - - - `HISTFILE` stores the path to the history file. - - `HISTSIZE` stores the maximum number of events to save in the internal history. - - `SAVEHIST` stores the maximum number of events to save in the history file. - Options ------- @@ -26,6 +19,13 @@ Options - `HIST_VERIFY` does not execute immediately upon history expansion. - `HIST_BEEP` beeps when accessing non-existent history. +Variables +--------- + + - `HISTFILE` stores the path to the history file. + - `HISTSIZE` stores the maximum number of events to save in the internal history. + - `SAVEHIST` stores the maximum number of events to save in the history file. + Aliases ------- diff --git a/modules/history/init.zsh b/modules/history/init.zsh index 31db4c5b3a..db357b0259 100644 --- a/modules/history/init.zsh +++ b/modules/history/init.zsh @@ -6,14 +6,6 @@ # Sorin Ionescu # -# -# Variables -# - -HISTFILE="${ZDOTDIR:-$HOME}/.zhistory" # The path to the history file. -HISTSIZE=10000 # The maximum number of events to save in the internal history. -SAVEHIST=10000 # The maximum number of events to save in the history file. - # # Options # @@ -31,6 +23,14 @@ setopt HIST_SAVE_NO_DUPS # Do not write a duplicate event to the history setopt HIST_VERIFY # Do not execute immediately upon history expansion. setopt HIST_BEEP # Beep when accessing non-existent history. +# +# Variables +# + +HISTFILE="${ZDOTDIR:-$HOME}/.zhistory" # The path to the history file. +HISTSIZE=10000 # The maximum number of events to save in the internal history. +SAVEHIST=10000 # The maximum number of events to save in the history file. + # # Aliases # diff --git a/modules/homebrew/README.md b/modules/homebrew/README.md index 98a3444c19..2a37553d15 100644 --- a/modules/homebrew/README.md +++ b/modules/homebrew/README.md @@ -1,7 +1,16 @@ Homebrew ======== -Defines Homebrew aliases. +Defines Homebrew specific environment variables and aliases. + +Variables +--------- + +Execute the following to list the environment variables loaded in the shell: + +```sh +brew shellenv +``` Aliases ------- @@ -20,12 +29,9 @@ Aliases ### Homebrew Cask - `cask` is aliased to `brew cask`. - - `caskc` cleans up old cached downloads. - - `caskC` cleans up all cached downloads. - `caski` installs a cask. - `caskl` lists installed casks. - `casko` lists casks which have an update available. - - `casks` searches for a cask. - `caskx` uninstalls a cask. Authors diff --git a/modules/homebrew/init.zsh b/modules/homebrew/init.zsh index e517c0a5e0..056f1fb5db 100644 --- a/modules/homebrew/init.zsh +++ b/modules/homebrew/init.zsh @@ -10,6 +10,17 @@ if [[ "$OSTYPE" != (darwin|linux)* ]]; then return 1 fi +# +# Variables +# + +# 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 "${(@M)${(f)"$(brew shellenv 2> /dev/null)"}:#export HOMEBREW*}" +fi + # # Aliases # @@ -21,15 +32,25 @@ alias brewi='brew install' alias brewl='brew list' alias brewo='brew outdated' alias brews='brew search' -alias brewu='brew update && brew upgrade' -alias brewx='brew remove' +alias brewu='brew upgrade' +alias brewx='brew uninstall' # Homebrew Cask alias cask='brew cask' -alias caskc='brew cask cleanup --outdated' -alias caskC='brew cask cleanup' +alias caskc='hb_deprecated brew cask cleanup' +alias caskC='hb_deprecated brew cask cleanup' alias caski='brew cask install' alias caskl='brew cask list' alias casko='brew cask outdated' -alias casks='brew cask search' +alias casks='hb_deprecated brew cask search' alias caskx='brew cask uninstall' + +function hb_deprecated { + local cmd="${@[3]}" + local cmd_args="${@:4}" + + printf "'brew cask %s' has been deprecated, " "${cmd}" + printf "using 'brew %s' instead\n" "${cmd}" + + command brew "${cmd}" "${=cmd_args}" +} diff --git a/modules/node/functions/node-info b/modules/node/functions/node-info index 22ac31bd5c..9feca3e16e 100644 --- a/modules/node/functions/node-info +++ b/modules/node/functions/node-info @@ -19,6 +19,8 @@ if (( $+functions[nvm_version] )); then version="${$(nvm_version)#v}" elif (( $+commands[nodenv] )); then version="${${$(nodenv version)#v}[(w)0]}" +elif (( $+commands[node] )) ; then + version="${$(node -v)#v}" fi if [[ "$version" != (none|) ]]; then diff --git a/modules/node/init.zsh b/modules/node/init.zsh index 578c642436..f452ec5a53 100644 --- a/modules/node/init.zsh +++ b/modules/node/init.zsh @@ -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 @@ -28,16 +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" || ! -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,} diff --git a/modules/osx/README.md b/modules/osx/README.md index 870b486408..1f93a2c332 100644 --- a/modules/osx/README.md +++ b/modules/osx/README.md @@ -1,7 +1,7 @@ OSX === -Defines [Mac OS X][1] aliases and functions. +Defines [macOS][1] aliases and functions. Settings -------- @@ -34,8 +34,8 @@ Functions - `tab` creates a new tab (works in both _Terminal_ and [_iTerm_][3]). - `ql` previews files in Quick Look. - `osx-rm-dir-metadata` deletes .DS\_Store, \_\_MACOSX cruft. - - `osx-ls-download-history` displays the Mac OS X download history. - - `osx-rm-download-history` deletes the Mac OS X download history. + - `osx-ls-download-history` displays the macOS download history. + - `osx-rm-download-history` deletes the macOS download history. Authors ------- diff --git a/modules/osx/functions/osx-ls-download-history b/modules/osx/functions/osx-ls-download-history index ba6a40c7ea..8b6eaab260 100644 --- a/modules/osx/functions/osx-ls-download-history +++ b/modules/osx/functions/osx-ls-download-history @@ -1,5 +1,5 @@ # -# Displays the Mac OS X download history. +# Displays the macOS download history. # # Authors: # Sorin Ionescu diff --git a/modules/osx/functions/osx-rm-download-history b/modules/osx/functions/osx-rm-download-history index c6a368cafb..068ba3db93 100644 --- a/modules/osx/functions/osx-rm-download-history +++ b/modules/osx/functions/osx-rm-download-history @@ -1,5 +1,5 @@ # -# Deletes the Mac OS X download history. +# Deletes the macOS download history. # # Authors: # Sorin Ionescu diff --git a/modules/osx/init.zsh b/modules/osx/init.zsh index edf6ed3d5f..f7871ca718 100644 --- a/modules/osx/init.zsh +++ b/modules/osx/init.zsh @@ -1,5 +1,5 @@ # -# Defines Mac OS X aliases and functions. +# Defines macOS aliases and functions. # # Authors: # Sorin Ionescu diff --git a/modules/pacman/README.md b/modules/pacman/README.md index 855c8efad3..a619a74777 100644 --- a/modules/pacman/README.md +++ b/modules/pacman/README.md @@ -8,23 +8,20 @@ Settings -------- It is possible to use a Pacman frontend with the pacman aliases provided by this -package as long as that frontend supports the same command line options (Such as -[Pacaur][2] or [Yaourt][3]). +package as long as that frontend supports the same command line options (The +[AUR Helpers][2] page has a good comparison which lists if the command line +options are pacman compatible). -To enable a Pacman frontend, for example, [Pacaur][2], add the following line to -*zpreztorc*: +Please note that installing packages with an AUR Helper is not officially +supported by Archlinux. It is currently recommended to manually build AUR +packages using the [provided instructions][3]. The [aurutils][4] project has a +set of small utilities to make this easier. -```sh -zstyle ':prezto:module:pacman' frontend 'pacaur' -``` - -If you have enabled color globally in *zpreztorc*, you may disable it for certain -commands. - -To disable `yaourt` highlighting, add the following line to *zpreztorc*: +To enable a Pacman frontend, add the following line to *zpreztorc*, substituting +`pacman_frontend` with the name of the frontent: ```sh -zstyle ':prezto:module:pacman:yaourt' color 'no' +zstyle ':prezto:module:pacman' frontend 'pacman_frontend' ``` Aliases @@ -50,28 +47,23 @@ Aliases ### Frontends -#### Yaourt - -Note that there are currently potential security concerns relating to yaourt, so -other frontends are recommended. - - - `pacc` manages *.pac\** files. - Functions --------- + - `aurget` clone an aur package - `pacman-list-explicit` lists explicitly installed pacman packages. - `pacman-list-disowned` lists pacman disowned files. Authors ------- -*The authors of this module should be contacted via the [issue tracker][4].* +*The authors of this module should be contacted via the [issue tracker][5].* - [Benjamin Boudreau](https://github.com/dreur) - [Sorin Ionescu](https://github.com/sorin-ionescu) [1]: http://www.archlinux.org/pacman/ -[2]: https://github.com/rmarquis/pacaur -[3]: http://archlinux.fr/yaourt-en -[4]: https://github.com/sorin-ionescu/prezto/issues +[2]: https://wiki.archlinux.org/index.php/AUR_helpers#Comparison_table +[3]: https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages +[4]: https://github.com/AladW/aurutils +[5]: https://github.com/sorin-ionescu/prezto/issues diff --git a/modules/pacman/init.zsh b/modules/pacman/init.zsh index a5cacf2c44..88c977f6b3 100644 --- a/modules/pacman/init.zsh +++ b/modules/pacman/init.zsh @@ -23,10 +23,6 @@ zstyle -s ':prezto:module:pacman' frontend '_pacman_frontend' if (( $+commands[$_pacman_frontend] )); then alias pacman="$_pacman_frontend" - - if [[ -s "${0:h}/${_pacman_frontend}.zsh" ]]; then - source "${0:h}/${_pacman_frontend}.zsh" - fi else _pacman_frontend='pacman' _pacman_sudo='sudo ' @@ -81,4 +77,12 @@ fi # upgrades outdated packages. alias pacU="${_pacman_sudo}${_pacman_frontend} --sync --refresh --sysupgrade" +function aurget { + local target_dir="$1" + if [[ -n "$2" ]]; then + target_dir="$2" + fi + git clone "https://aur.archlinux.org/$1" "$target_dir" +} + unset _pacman_{frontend,sudo} diff --git a/modules/pacman/yaourt.zsh b/modules/pacman/yaourt.zsh deleted file mode 100644 index 819fad16be..0000000000 --- a/modules/pacman/yaourt.zsh +++ /dev/null @@ -1,18 +0,0 @@ -# -# Defines Yaourt aliases. -# -# Authors: -# Sorin Ionescu -# - -# -# Aliases -# - -# Disable color. -if ! zstyle -t ':prezto:module:pacman:yaourt' color; then - alias pacman='yaourt --nocolor' -fi - -# Manages .pac* files. -alias pacc='yaourt -C' diff --git a/modules/perl/README.md b/modules/perl/README.md index 092c922478..67f2a17798 100644 --- a/modules/perl/README.md +++ b/modules/perl/README.md @@ -1,14 +1,14 @@ Perl ==== -Enables local [Perl][1] module installation on Mac OS X and defines aliases. +Enables local [Perl][1] module installation on macOS and defines aliases. Local Module Installation ------------------------- Perl versions older than 5.14 do not support the local installation of Perl modules natively. This module allows for local installation of Perl modules on -Mac OS X in *~/Library/Perl/5.12* by altering the environment. +macOS in *~/Library/Perl/5.12* by altering the environment. ### Usage diff --git a/modules/perl/init.zsh b/modules/perl/init.zsh index ffd5f0dfd8..b7a794797a 100644 --- a/modules/perl/init.zsh +++ b/modules/perl/init.zsh @@ -1,5 +1,5 @@ # -# Enables local Perl module installation on Mac OS X and defines aliases. +# Enables local Perl module installation on macOS and defines aliases. # # Authors: # Sorin Ionescu @@ -43,7 +43,7 @@ if [[ "$OSTYPE" == darwin* ]]; then perl_path="$HOME/Library/Perl/5.12" if [[ -f "$perl_path/lib/perl5/local/lib.pm" ]]; then - if [[ ! -s "$cache_file" ]]; then + if [[ "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" || ! -s "$cache_file" ]]; then perl -I$perl_path/lib/perl5 -Mlocal::lib=$perl_path >! "$cache_file" fi diff --git a/modules/prompt/functions/prompt_minimal_setup b/modules/prompt/functions/prompt_minimal_setup index 7456ffdb1d..b600768bd0 100644 --- a/modules/prompt/functions/prompt_minimal_setup +++ b/modules/prompt/functions/prompt_minimal_setup @@ -47,4 +47,13 @@ function prompt_minimal_setup { RPROMPT='' } +function prompt_minimal_preview { + local +h PROMPT='' + local +h RPROMPT='' + local +h SPROMPT='' + + editor-info 2> /dev/null + prompt_preview_theme 'minimal' +} + prompt_minimal_setup "$@" diff --git a/modules/prompt/functions/prompt_smiley_setup b/modules/prompt/functions/prompt_smiley_setup index 3066a2dc2b..3d41b3af46 100644 --- a/modules/prompt/functions/prompt_smiley_setup +++ b/modules/prompt/functions/prompt_smiley_setup @@ -36,7 +36,7 @@ function prompt_smiley_precmd { function prompt_smiley_setup { unsetopt XTRACE KSH_ARRAYS - prompt_opts=(percent subst) + prompt_opts=(cr percent sp subst) # Add hook for calling git-info before each command. add-zsh-hook precmd prompt_smiley_precmd diff --git a/modules/prompt/functions/prompt_sorin_setup b/modules/prompt/functions/prompt_sorin_setup index 30e71a9285..14f8858c1c 100644 --- a/modules/prompt/functions/prompt_sorin_setup +++ b/modules/prompt/functions/prompt_sorin_setup @@ -144,16 +144,17 @@ function prompt_sorin_setup { zstyle ':prezto:module:git:info:keys' format \ 'status' '%b %p %c:%s%A%B%S%a%d%m%r%U%u' + # Set python-info parameters. + zstyle ':prezto:module:python:info:virtualenv' format '%f%F{3}(%v)%F{7} ' + # Set up non-zero return value display local show_return="✘ " # Default is to show the return value if zstyle -T ':prezto:module:prompt' show-return-val; then show_return+='%? ' fi - # Set python-info format - zstyle ':prezto:module:python:info:virtualenv' format '%f%F{3}(%v)%F{7} ' - # Get the async worker set up + # Get the async worker set up. _sorin_cur_git_root='' _prompt_sorin_git='' diff --git a/modules/prompt/functions/prompt_steeef_setup b/modules/prompt/functions/prompt_steeef_setup index b241f9aa35..ca39f9321d 100644 --- a/modules/prompt/functions/prompt_steeef_setup +++ b/modules/prompt/functions/prompt_steeef_setup @@ -72,6 +72,9 @@ function prompt_steeef_setup { local unstaged_format="${_prompt_steeef_colors[2]}●%f" local staged_format="${_prompt_steeef_colors[5]}●%f" + # Set editor-info parameters. + zstyle ':prezto:module:editor:info:keymap:primary' format '$' + # Set vcs_info parameters. zstyle ':vcs_info:*' enable bzr git hg svn zstyle ':vcs_info:*:prompt:*' check-for-changes true @@ -87,8 +90,17 @@ function prompt_steeef_setup { # Define prompts. PROMPT=" ${_prompt_steeef_colors[3]}%n%f at ${_prompt_steeef_colors[2]}%m%f in ${_prompt_steeef_colors[5]}%~%f "'${vcs_info_msg_0_}'" -"'$python_info[virtualenv]'"$ " +"'$python_info[virtualenv]${editor_info[keymap]} ' RPROMPT='' } +function prompt_steeef_preview { + local +h PROMPT='' + local +h RPROMPT='' + local +h SPROMPT='' + + editor-info 2> /dev/null + prompt_preview_theme 'steeef' +} + prompt_steeef_setup "$@" diff --git a/modules/python/README.md b/modules/python/README.md index e7b72c480b..121ea37395 100644 --- a/modules/python/README.md +++ b/modules/python/README.md @@ -6,7 +6,9 @@ Enables local Python and local Python package installation. Settings -------- -This module supports virtual environments from conda and virtualenvwrapper. By default, only virtualenvwrapper is enabled. To disable virtualenvwrapper, add the following to *zpreztorc*. +This module supports virtual environments from conda and virtualenvwrapper. By +default, only virtualenvwrapper is enabled. To disable virtualenvwrapper, add +the following to *zpreztorc*. ```sh zstyle ':prezto:module:python' skip-virtualenvwrapper-init 'on' @@ -52,8 +54,8 @@ virtualenvwrapper [`virtualenvwrapper`][2] is a frontend to the popular [`virtualenv`][3] utility. -`virtualenv` creates isolated Python environments and `virtualenvwrapper` provides -convenient shell functions to create, switch, and manage them. +`virtualenv` creates isolated Python environments and `virtualenvwrapper` +provides convenient shell functions to create, switch, and manage them. ### Usage diff --git a/modules/python/init.zsh b/modules/python/init.zsh index 94eeab7987..44043f1c35 100644 --- a/modules/python/init.zsh +++ b/modules/python/init.zsh @@ -7,19 +7,22 @@ # Patrick Bos # -# Load manually installed pyenv into the shell session. -if [[ -s "$HOME/.pyenv/bin/pyenv" ]]; then +# Load manually installed pyenv into the path +if [[ -n "$PYENV_ROOT" && -s "$PYENV_ROOT/bin/pyenv" ]]; then + path=("$PYENV_ROOT/bin" $path) +elif [[ -s "$HOME/.pyenv/bin/pyenv" ]]; then path=("$HOME/.pyenv/bin" $path) - export PYENV_ROOT=$(pyenv root) - eval "$(pyenv init -)" +fi -# Load package manager installed pyenv into the shell session. -elif (( $+commands[pyenv] )); then - export PYENV_ROOT=$(pyenv root) - eval "$(pyenv init -)" +# Load pyenv into the current python session +if (( $+commands[pyenv] )); then + if [[ -z "$PYENV_ROOT" ]]; then + export PYENV_ROOT=$(pyenv root) + fi + eval "$(pyenv init - --no-rehash zsh)" # Prepend PEP 370 per user site packages directory, which defaults to -# ~/Library/Python on Mac OS X and ~/.local elsewhere, to PATH. The +# ~/Library/Python on macOS and ~/.local elsewhere, to PATH. The # path can be overridden using PYTHONUSERBASE. else if [[ -n "$PYTHONUSERBASE" ]]; then @@ -57,7 +60,7 @@ function _python-workon-cwd { local ENV_NAME="" if [[ -f "$PROJECT_ROOT/.venv" ]]; then ENV_NAME="$(cat "$PROJECT_ROOT/.venv")" - elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then + elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]]; then ENV_NAME="$PROJECT_ROOT/.venv" elif [[ "$PROJECT_ROOT" != "." ]]; then ENV_NAME="${PROJECT_ROOT:t}" @@ -82,6 +85,7 @@ function _python-workon-cwd { # Load auto workon cwd hook if zstyle -t ':prezto:module:python:virtualenv' auto-switch 'yes'; then # Auto workon when changing directory + autoload -Uz add-zsh-hook add-zsh-hook chpwd _python-workon-cwd fi @@ -92,8 +96,11 @@ if (( $+VIRTUALENVWRAPPER_VIRTUALENV || $+commands[virtualenv] )) && \ # Set the directory where virtual environments are stored. export WORKON_HOME="${WORKON_HOME:-$HOME/.virtualenvs}" - # Disable the virtualenv prompt. - VIRTUAL_ENV_DISABLE_PROMPT=1 + # Disable the virtualenv prompt. Note that we use the magic value used by the + # pure prompt because there's some additional logic in that prompt which tries + # to figure out if a user set this variable and disable the python portion of + # that prompt based on it which is the exact opposite of what we want to do. + export VIRTUAL_ENV_DISABLE_PROMPT=12 # Create a sorted array of available virtualenv related 'pyenv' commands to # look for plugins of interest. Scanning shell '$path' isn't enough as they @@ -105,7 +112,7 @@ if (( $+VIRTUALENVWRAPPER_VIRTUALENV || $+commands[virtualenv] )) && \ if (( $pyenv_plugins[(i)virtualenv-init] <= $#pyenv_plugins )); then # Enable 'virtualenv' with 'pyenv'. - eval "$(pyenv virtualenv-init -)" + eval "$(pyenv virtualenv-init - zsh)" # Optionally activate 'virtualenvwrapper' plugin when available. if (( $pyenv_plugins[(i)virtualenvwrapper(_lazy|)] <= $#pyenv_plugins )); then @@ -143,18 +150,23 @@ 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])]" - if [[ "$pip_command" -nt "$cache_file" || ! -s "$cache_file" ]]; then + if [[ "$pip_command" -nt "$cache_file" \ + || "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" \ + || ! -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{,2,3}{,.{0..9}}/" \ + >! "$cache_file" \ + 2> /dev/null fi source "$cache_file" + unset cache_file pip_command fi diff --git a/modules/rsync/README.md b/modules/rsync/README.md index b418780b87..77d78ea54c 100644 --- a/modules/rsync/README.md +++ b/modules/rsync/README.md @@ -3,7 +3,7 @@ Rsync Defines [rsync][1] aliases. -Mac OS X users are encouraged to use [Bombich's rsync][2], which has HFS+ +macOS users are encouraged to use [Bombich's rsync][2], which has HFS+ enhancements. Aliases diff --git a/modules/rsync/init.zsh b/modules/rsync/init.zsh index 3afebdb4dd..b3010ede32 100644 --- a/modules/rsync/init.zsh +++ b/modules/rsync/init.zsh @@ -14,14 +14,15 @@ fi # Aliases # -_rsync_cmd='rsync --verbose --progress --human-readable --compress --archive --hard-links --one-file-system' +_rsync_cmd='rsync --verbose --progress --human-readable --compress --archive \ + --hard-links --one-file-system' if grep -q 'xattrs' <(rsync --help 2>&1); then _rsync_cmd="${_rsync_cmd} --acls --xattrs" fi -# Mac OS X and HFS+ Enhancements -# http://help.bombich.com/kb/overview/credits#opensource +# macOS and HFS+ Enhancements +# 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 diff --git a/modules/ruby/init.zsh b/modules/ruby/init.zsh index 3f666c3e0b..4ede36675f 100644 --- a/modules/ruby/init.zsh +++ b/modules/ruby/init.zsh @@ -25,9 +25,14 @@ elif (( $+commands[rbenv] )); then # Load package manager installed chruby into the shell session. elif (( $+commands[chruby-exec] )); then - source "${commands[chruby-exec]:h:h}/share/chruby/chruby.sh" + if (( ! $+functions[chruby] )); then + source "${commands[chruby-exec]:h:h}/share/chruby/chruby.sh" + fi + if zstyle -t ':prezto:module:ruby:chruby' auto-switch; then - source "${commands[chruby-exec]:h:h}/share/chruby/auto.sh" + if (( ! $+functions[chruby_auto] )); then + source "${commands[chruby-exec]:h:h}/share/chruby/auto.sh" + fi # If a default Ruby is set, switch to it. chruby_auto diff --git a/modules/syntax-highlighting/README.md b/modules/syntax-highlighting/README.md index 5dad5bbad9..7a5a30c356 100644 --- a/modules/syntax-highlighting/README.md +++ b/modules/syntax-highlighting/README.md @@ -3,9 +3,14 @@ Syntax Highlighting Integrates [zsh-syntax-highlighting][1] into Prezto. -This module should be loaded *second to last*, where last is the *prompt* -module, unless used in conjuncture with the *history-substring-search* module -where it must be loaded **before** it. +This module should be loaded before the *prompt* module. + +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 ------------ diff --git a/modules/tmux/README.md b/modules/tmux/README.md index 3d742ba684..0738d7cfad 100644 --- a/modules/tmux/README.md +++ b/modules/tmux/README.md @@ -62,7 +62,7 @@ Aliases Caveats ------- -On Mac OS X, launching tmux can cause the error **launch_msg(...): Socket is not +On macOS, launching tmux can cause the error **launch_msg(...): Socket is not connected** to be displayed, which can be fixed by installing [reattach-to-user-namespace][3], available in [Homebrew][4], and adding the following to *tmux.conf*: @@ -71,7 +71,7 @@ following to *tmux.conf*: set-option -g default-command "reattach-to-user-namespace -l $SHELL -l" ``` -Furthermore, tmux is known to cause **kernel panics** on Mac OS X. A discussion +Furthermore, tmux is known to cause **kernel panics** on macOS. A discussion about this and Prezto has already been [opened][2]. Authors diff --git a/modules/tmux/init.zsh b/modules/tmux/init.zsh index a361a6a60b..fb56d07603 100644 --- a/modules/tmux/init.zsh +++ b/modules/tmux/init.zsh @@ -23,7 +23,7 @@ if ([[ "$TERM_PROGRAM" = 'iTerm.app' ]] && \ _tmux_iterm_integration='-CC' fi -if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" && -z "$INSIDE_EMACS" ]] && ( \ +if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" && -z "$INSIDE_EMACS" && -z "$VSCODE_PID" ]] && ( \ ( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' remote ) || ( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' local ) \ ); then diff --git a/modules/utility/README.md b/modules/utility/README.md index 84e81f5c28..3b25b3a75b 100644 --- a/modules/utility/README.md +++ b/modules/utility/README.md @@ -8,8 +8,8 @@ Settings ### Highlighting -If you have enabled color globally in *zpreztorc*, you may disable it for certain -commands. +If you have enabled color globally in *zpreztorc*, you may disable it for +certain commands. To disable `ls` color, add the following line to *zpreztorc*; when coloring is disabled, type indicators (\*, /, =>, @, =, |, %) will be appended to entries. @@ -18,6 +18,12 @@ disabled, type indicators (\*, /, =>, @, =, |, %) will be appended to entries. zstyle ':prezto:module:utility:ls' color 'no' ``` +To disable GNU coreutils `ls` to list directories grouped first, add the following line to *zpreztorc*: + +```sh +zstyle ':prezto:module:utility:ls' dirs-first 'no' +``` + To disable `diff` highlighting, add the following line to *zpreztorc*: ```sh @@ -109,7 +115,8 @@ Aliases ### Resource Usage - - `df` displays free disk space using human readable units (aliases to `pydf`, if installed). + - `df` displays free disk space using human readable units (aliases to `pydf`, + if installed). - `du` displays disk usage using human readable units. - `top` displays information about processes. - `topc` displays information about processes sorted by CPU usage. diff --git a/modules/utility/functions/wdiff b/modules/utility/functions/wdiff index c93ead1c6d..ebfad0b82f 100644 --- a/modules/utility/functions/wdiff +++ b/modules/utility/functions/wdiff @@ -17,7 +17,7 @@ function wdiff { "$@" \ | sed 's/^\(@@\( [+-][[:digit:]]*,[[:digit:]]*\)\{2\} @@\)$/;5;6m\10m/g' elif (( $+commands[git] )); then - git --no-pager diff --color=auto --no-ext-diff --no-index --color-words "$@" + command git --no-pager diff --color=auto --no-ext-diff --no-index --color-words "$@" else command wdiff "$@" fi diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index 1ccf13b73d..6b07bf0f9e 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -73,13 +73,19 @@ fi # ls if is-callable 'dircolors'; then # GNU Core Utilities - alias ls='ls --group-directories-first' + + if zstyle -T ':prezto:module:utility:ls' dirs-first; then + alias ls="${aliases[ls]:-ls} --group-directories-first" + fi if zstyle -t ':prezto:module:utility:ls' color; then - if [[ -s "$HOME/.dir_colors" ]]; then - eval "$(dircolors --sh "$HOME/.dir_colors")" - else - eval "$(dircolors --sh)" + # Call dircolors to define colors if they're missing + if [[ -z "$LS_COLORS" ]]; then + if [[ -s "$HOME/.dir_colors" ]]; then + eval "$(dircolors --sh "$HOME/.dir_colors")" + else + eval "$(dircolors --sh)" + fi fi alias ls="${aliases[ls]:-ls} --color=auto" @@ -89,11 +95,15 @@ if is-callable 'dircolors'; then else # BSD Core Utilities if zstyle -t ':prezto:module:utility:ls' color; then - # Define colors for BSD ls. - export LSCOLORS='exfxcxdxbxGxDxabagacad' + # Define colors for BSD ls if they're not already defined + if [[ -z "$LSCOLORS" ]]; then + export LSCOLORS='exfxcxdxbxGxDxabagacad' + fi - # Define colors for the completion system. - export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:' + # Define colors for the completion system if they're not already defined + if [[ -z "$LS_COLORS" ]]; then + export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:' + fi alias ls="${aliases[ls]:-ls} -G" else @@ -121,7 +131,7 @@ if zstyle -t ':prezto:module:utility:grep' color; then alias grep="${aliases[grep]:-grep} --color=auto" fi -# Mac OS X Everywhere +# macOS Everywhere if [[ "$OSTYPE" == darwin* ]]; then alias o='open' elif [[ "$OSTYPE" == cygwin* ]]; then @@ -151,12 +161,7 @@ elif (( $+commands[wget] )); then fi # Resource Usage -if (( $+commands[pydf] )); then - alias df=pydf -else - alias df='df -kh' -fi - +alias df='df -kh' alias du='du -kh' if [[ "$OSTYPE" == (darwin*|*bsd*) ]]; then diff --git a/runcoms/README.md b/runcoms/README.md index 9df890e51a..29d9f8a98d 100644 --- a/runcoms/README.md +++ b/runcoms/README.md @@ -10,7 +10,7 @@ in */etc* by default. User-local configuration files have the same name as their global counterparts but are prefixed with a dot (hidden). Zsh looks for these files in the path -stored in the `$ZDOTDIR` environmental variable. However, if said variable is +stored in the `$ZDOTDIR` environment variable. However, if said variable is not defined, Zsh will use the user's home directory. File Descriptions diff --git a/runcoms/zlogout b/runcoms/zlogout index 56b6b5515e..b5d9858c08 100644 --- a/runcoms/zlogout +++ b/runcoms/zlogout @@ -8,11 +8,12 @@ # Execute code only if STDERR is bound to a TTY. [[ -o INTERACTIVE && -t 2 ]] && { -# Print the message. -cat <<-EOF +SAYINGS=( + "So long and thanks for all the fish.\n -- Douglas Adams" + "Good morning! And in case I don't see ya, good afternoon, good evening and goodnight.\n --Truman Burbank" +) -Thank you. Come again! - -- Dr. Apu Nahasapeemapetilon -EOF +# Print a randomly-chosen message: +echo $SAYINGS[$(($RANDOM % ${#SAYINGS} + 1))] } >&2 diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index 84074215d8..c6d9a18242 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -98,7 +98,7 @@ bindkey "^s" history-incremental-search-forward # zstyle ':prezto:module:history-substring-search' globbing-flags '' # -# OS X +# macOS # # Set the keyword used by `mand` to open man pages in Dash.app @@ -129,13 +129,6 @@ zstyle ':prezto:module:prompt' theme 'psomasundar' # return codes. This is not supported by all prompts. # zstyle ':prezto:module:prompt' show-return-val 'yes' -# -# Ruby -# - -# Auto switch the Ruby version on directory change. -# zstyle ':prezto:module:ruby:chruby' auto-switch 'yes' - # # Python # @@ -146,6 +139,13 @@ zstyle ':prezto:module:prompt' theme 'psomasundar' # Automatically initialize virtualenvwrapper if pre-requisites are met. # zstyle ':prezto:module:python:virtualenv' initialize 'yes' +# +# Ruby +# + +# Auto switch the Ruby version on directory change. +# zstyle ':prezto:module:ruby:chruby' auto-switch 'yes' + # # Screen #