Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sorin-ionescu/prezto
Browse files Browse the repository at this point in the history
* 'master' of github.com:sorin-ionescu/prezto: (81 commits)
  Add explanation for extra git theme symbols in README.md
  Correct alphabetical order in zprestorc
  Update submodules (sorin-ionescu#1615)
  Improve startup time by skipping pyenv rehash
  Make node-info work without nvm/nodenv
  Fix broken gitref link in README.md
  coreutils: update list of included coreutils (sorin-ionescu#1592)
  completion: Compact path to global ssh known hosts file
  syntax-highlighting: Update README to clarify module load order
  Fix path to global ssh known hosts file
  Fix spelling error in CONTRIBUTING.md (sorin-ionescu#1590)
  Remove zlogout's Apu quote (sorin-ionescu#1583)
  Document `gpf` vs `gpF`
  Document macOS support for `command-not-found`
  Update cache files when .zpreztorc file is modified
  Export VIRTUAL_ENV_DISABLE_PROMPT when enabling virutalenv
  command-not-found: Directly source homebrew command-not-found handler
  Rename "Mac OS X" to "macOS" in comments
  Add proper prompt_opts to smiley prompt
  Revert "Only call reset-prompt when the appropriate zstyle is set"
  ...
  • Loading branch information
ezintz committed Aug 26, 2018
2 parents 17b3065 + 7bb7a7c commit 76bafe4
Show file tree
Hide file tree
Showing 67 changed files with 554 additions and 285 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.zwc
*.zwc.old
modules/*/cache.zsh
contrib
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Installation
------------

Prezto will work with any recent release of Zsh, but the minimum required
version is 4.3.17.
version is 4.3.11.

1. Launch Zsh:

Expand Down Expand Up @@ -88,7 +88,20 @@ accompanying README files to learn of what is available.
3. Load the theme you like in *~/.zpreztorc* then open a new Zsh terminal
window or tab.

![sorin theme][2]
![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 list under `zstyle ':prezto:load' pmodule \ ` in your `.zpreztorc` to enable this module.
### External Modules

1. By default modules will be loaded from */modules* and */contrib*.
2. Additional module directories can be added to the
`:prezto:load:pmodule-dirs` setting in *~/.zpreztorc*.

Note that module names need to be unique or they will cause an error when
loading.

```console
zstyle ':prezto:load' pmodule-dirs $HOME/.zprezto-contrib
```

Customization
-------------
Expand All @@ -113,6 +126,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
74 changes: 49 additions & 25 deletions init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#

# Check for the minimum supported version.
min_zsh_version='4.3.17'
min_zsh_version='4.3.11'
if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then
printf "prezto: old shell detected, minimum required: %s\n" "$min_zsh_version" >&2
return 1
Expand All @@ -34,9 +34,9 @@ function zprezto-update {
if [[ "$orig_branch" == "master" ]]; then
git fetch || return "$?"
local UPSTREAM=$(git rev-parse '@{u}')
local LOCAL=$(git rev-parse @)
local LOCAL=$(git rev-parse HEAD)
local REMOTE=$(git rev-parse "$UPSTREAM")
local BASE=$(git merge-base @ "$UPSTREAM")
local BASE=$(git merge-base HEAD "$UPSTREAM")
if [[ $LOCAL == $REMOTE ]]; then
printf "There are no updates.\n"
return 0
Expand Down Expand Up @@ -72,44 +72,68 @@ function zprezto-update {
# Loads Prezto modules.
function pmodload {
local -a pmodules
local -a pmodule_dirs
local -a locations
local pmodule
local pmodule_location
local pfunction_glob='^([_.]*|prompt_*_setup|README*|*~)(-.N:t)'

# $argv is overridden in the anonymous function.
pmodules=("$argv[@]")

# Add functions to $fpath.
fpath=(${pmodules:+$ZPREZTODIR/modules/${^pmodules}/functions(/FN)} $fpath)

function {
local pfunction
# Load in any additional directories and warn if they don't exist
zstyle -a ':prezto:load' pmodule-dirs 'user_pmodule_dirs'
for user_dir in "$user_pmodule_dirs[@]"; do
if [[ ! -d "$user_dir" ]]; then
echo "$0: Missing user module dir: $user_dir"
fi
done

# Extended globbing is needed for listing autoloadable function directories.
setopt LOCAL_OPTIONS EXTENDED_GLOB
pmodule_dirs=("$ZPREZTODIR/modules" "$ZPREZTODIR/contrib" "$user_pmodule_dirs[@]")

# Load Prezto functions.
for pfunction in $ZPREZTODIR/modules/${^pmodules}/functions/$~pfunction_glob; do
autoload -Uz "$pfunction"
done
}
# $argv is overridden in the anonymous function.
pmodules=("$argv[@]")

# Load Prezto modules.
for pmodule in "$pmodules[@]"; do
if zstyle -t ":prezto:module:$pmodule" loaded 'yes' 'no'; then
continue
elif [[ ! -d "$ZPREZTODIR/modules/$pmodule" ]]; then
print "$0: no such module: $pmodule" >&2
continue
else
if [[ -s "$ZPREZTODIR/modules/$pmodule/init.zsh" ]]; then
source "$ZPREZTODIR/modules/$pmodule/init.zsh"
locations=(${pmodule_dirs:+${^pmodule_dirs}/$pmodule(-/FN)})
if (( ${#locations} > 1 )); then
print "$0: conflicting module locations: $locations"
continue
elif (( ${#locations} < 1 )); then
print "$0: no such module: $pmodule"
continue
fi

# Grab the full path to this module
pmodule_location=${locations[1]}

# Add functions to $fpath.
fpath=(${pmodule_location}/functions(/FN) $fpath)

function {
local pfunction

# Extended globbing is needed for listing autoloadable function directories.
setopt LOCAL_OPTIONS EXTENDED_GLOB

# Load Prezto functions.
for pfunction in ${pmodule_location}/functions/$~pfunction_glob; do
autoload -Uz "$pfunction"
done
}

if [[ -s "${pmodule_location}/init.zsh" ]]; then
source "${pmodule_location}/init.zsh"
elif [[ -s "${pmodule_location}/${pmodule}.plugin.zsh" ]]; then
source "${pmodule_location}/${pmodule}.plugin.zsh"
fi

if (( $? == 0 )); then
zstyle ":prezto:module:$pmodule" loaded 'yes'
else
# Remove the $fpath entry.
fpath[(r)${ZPREZTODIR}/modules/${pmodule}/functions]=()
fpath[(r)${pmodule_location}/functions]=()

function {
local pfunction
Expand All @@ -119,7 +143,7 @@ function pmodload {
setopt LOCAL_OPTIONS EXTENDED_GLOB

# Unload Prezto functions.
for pfunction in $ZPREZTODIR/modules/$pmodule/functions/$~pfunction_glob; do
for pfunction in ${pmodule_location}/functions/$~pfunction_glob; do
unfunction "$pfunction"
done
}
Expand Down
6 changes: 3 additions & 3 deletions modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down Expand Up @@ -122,7 +122,7 @@ Initializes OCaml package management.
OSX
---

Defines Mac OS X aliases and functions.
Defines macOS aliases and functions.

Pacman
------
Expand All @@ -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
------
Expand Down
8 changes: 7 additions & 1 deletion modules/archive/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ Additionally, if `pigz` and/or `pbzip2` are installed, `archive` will use them o
their traditional counterparts, `gzip` and `bzip2` respectively, to take full advantage
of all available CPU cores for compression.

Alternatives
------------

Specifically on macOS, [The Unarchiver][1] provides a similar command line tool
which doesn't depend on a number of other programs being installed.

Authors
-------

Expand All @@ -43,4 +49,4 @@ Authors
- [Sorin Ionescu](https://github.com/sorin-ionescu)
- [Matt Hamilton](https://github.com/Eriner)

[1]: https://github.com/sorin-ionescu/prezto/issues
[1]: https://theunarchiver.com/command-line
8 changes: 8 additions & 0 deletions modules/autosuggestions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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
-------

Expand Down
16 changes: 12 additions & 4 deletions modules/command-not-found/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
Command-Not-Found
=================

Displays installation information for not found commands by loading the
[command-not-found][1] tool on Debian-based and Arch Linux-based distributions.
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.

Debian-based 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].


Authors
-------

*The authors of this module should be contacted via the [issue tracker][2].*
*The authors of this module should be contacted via the [issue tracker][4].*

- [Joseph Booker](https://github.com/sargas)

[1]: https://code.launchpad.net/command-not-found
[2]: https://github.com/sorin-ionescu/prezto/issues
[2]: https://github.com/Homebrew/homebrew-command-not-found
[3]: https://github.com/Homebrew/homebrew-command-not-found#install
[4]: https://github.com/sorin-ionescu/prezto/issues
6 changes: 3 additions & 3 deletions modules/command-not-found/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ 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.
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'
# Return if requirements are not found.
else
return 1
Expand Down
2 changes: 1 addition & 1 deletion modules/completion/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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 }:#*\**}:#*\?*}}
)'
Expand Down
1 change: 0 additions & 1 deletion modules/directory/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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 >>.
Expand Down
Loading

0 comments on commit 76bafe4

Please sign in to comment.