Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master: (59 commits)
  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"
  Feat (git): add an alias displaying the commits yet to be applied to upstream (sorin-ionescu#1565)
  Allow users to easily define LS_COLORS and LSCOLORS (sorin-ionescu#1546)
  Ignore tmux autostart in vscode terminal
  Replace git with 'command git' (sorin-ionescu#1551)
  python: autoload add-zsh-hook when needed (sorin-ionescu#1549)
  Remove support for pydf to make options more consistent
  Add another shadow to the git aliases
  git: add tag aliases
  Only call reset-prompt when the appropriate zstyle is set
  Don't double-source chruby
  autosuggestions: add basic history troubleshooting information
  Add vi-pound-insert as # in vicmd mode
  Add `pound-toggle` zle widget to work around the buggy built-in `pound-insert`
  Move INTERACTIVE_COMMENTS from editor to environment
  ...
  • Loading branch information
tunght13488 committed May 7, 2018
2 parents c9d8830 + 2995b7d commit 8eab343
Show file tree
Hide file tree
Showing 61 changed files with 483 additions and 247 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.zwc.old
modules/*/cache.zsh
.ztoken
contrib
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ accompanying README files to learn of what is available.

![sorin theme][2]

### 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 Down
68 changes: 46 additions & 22 deletions init.zsh
Original file line number Diff line number Diff line change
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
4 changes: 2 additions & 2 deletions modules/README.md
Original file line number Diff line number Diff line change
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
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
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
55 changes: 49 additions & 6 deletions modules/editor/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ fi
# Options
#

# Beep on error in line editor.
setopt BEEP
setopt BEEP # Beep on error in line editor.

#
# Variables
Expand Down Expand Up @@ -211,6 +210,14 @@ zle -N expand-dot-to-parent-directory-path
function expand-or-complete-with-indicator {
local indicator
zstyle -s ':prezto:module:editor:info:completing' format 'indicator'

# This is included to work around a bug in zsh which shows up when interacting
# with multi-line prompts.
if [[ -z "$indicator" ]]; then
zle expand-or-complete
return
fi

print -Pn "$indicator"
zle expand-or-complete
zle redisplay
Expand All @@ -234,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

Expand Down Expand Up @@ -269,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
#
Expand All @@ -288,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
#
Expand Down Expand Up @@ -322,18 +359,24 @@ for keymap in $unbound_keys; do
bindkey -M viins "${keymap}" _prezto-zle-noop
bindkey -M vicmd "${keymap}" _prezto-zle-noop
done
# Ctrl + Left and Ctrl + Right bindings to forward/backward word

# Keybinds for all keymaps
for keymap in 'emacs' 'viins' 'vicmd'; do
bindkey -M "$keymap" "$key_info[Home]" beginning-of-line
bindkey -M "$keymap" "$key_info[End]" end-of-line
done

# Keybinds for all vi keymaps
for keymap in viins vicmd; do
# Ctrl + Left and Ctrl + Right bindings to forward/backward word
for key in "${(s: :)key_info[ControlLeft]}"
bindkey -M "$keymap" "$key" vi-backward-word
for key in "${(s: :)key_info[ControlRight]}"
bindkey -M "$keymap" "$key" vi-forward-word
done

# Keybinds for emacs and vi insert mode
for keymap in 'emacs' 'viins'; do
bindkey -M "$keymap" "$key_info[Home]" beginning-of-line
bindkey -M "$keymap" "$key_info[End]" end-of-line

bindkey -M "$keymap" "$key_info[Insert]" overwrite-mode
bindkey -M "$keymap" "$key_info[Delete]" delete-char
bindkey -M "$keymap" "$key_info[Backspace]" backward-delete-char
Expand Down
30 changes: 23 additions & 7 deletions modules/environment/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,34 @@
# Smart URLs
#

autoload -Uz url-quote-magic
zle -N self-insert url-quote-magic
# This logic comes from an old version of zim. Essentially, bracketed-paste was
# added as a requirement of url-quote-magic in 5.1, but in 5.1.1 bracketed
# 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 is-at-least 5.2; then
autoload -Uz bracketed-paste-url-magic
zle -N bracketed-paste bracketed-paste-url-magic
else
if is-at-least 5.1; then
autoload -Uz bracketed-paste-magic
zle -N bracketed-paste bracketed-paste-magic
fi
fi
autoload -Uz url-quote-magic
zle -N self-insert url-quote-magic
fi

#
# General
#

setopt BRACE_CCL # Allow brace character class list expansion.
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
Expand Down
6 changes: 4 additions & 2 deletions modules/fasd/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ fi
# Initialization
#

cache_file="${0:h}/cache.zsh"
if [[ "${commands[fasd]}" -nt "$cache_file" || ! -s "$cache_file" ]]; then
cache_file="${TMPDIR:-/tmp}/prezto-fasd-cache.$UID.zsh"
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)

Expand Down
Loading

0 comments on commit 8eab343

Please sign in to comment.