Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/sorin-ionescu/prezto
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkiss committed Dec 26, 2017
2 parents c07d47d + 82d3265 commit aba026f
Show file tree
Hide file tree
Showing 27 changed files with 310 additions and 106 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
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
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
33 changes: 29 additions & 4 deletions modules/editor/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,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 @@ -226,6 +234,14 @@ function prepend-sudo {
}
zle -N prepend-sudo

# Expand aliases
function glob-alias {
zle _expand_alias
zle expand-word
zle magic-space
}
zle -N glob-alias

# Reset to default key bindings.
bindkey -d

Expand Down Expand Up @@ -314,18 +330,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 Expand Up @@ -368,6 +390,9 @@ for keymap in 'emacs' 'viins'; do

# Insert 'sudo ' at the beginning of the line.
bindkey -M "$keymap" "$key_info[Control]X$key_info[Control]S" prepend-sudo

# control-space expands all aliases, including global
bindkey -M "$keymap" "$key_info[Control] " glob-alias
done

# Delete key deletes character in vimcmd cmd mode instead of weird default functionality
Expand Down
21 changes: 18 additions & 3 deletions modules/environment/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,29 @@
# 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'.
Expand Down
2 changes: 1 addition & 1 deletion modules/fasd/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fi
# Initialization
#

cache_file="${0:h}/cache.zsh"
cache_file="${TMPDIR:-/tmp}/prezto-fasd-cache.$UID.zsh"
if [[ "${commands[fasd]}" -nt "$cache_file" || ! -s "$cache_file" ]]; then
# Set the base init arguments.
init_args=(zsh-hook)
Expand Down
7 changes: 6 additions & 1 deletion modules/git/functions/_git-hub-shorten-url
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#

_arguments '::GitHub URL:_urls' && return 0
local service="$service"

zstyle ":completion:*:${service}:*:prefixes" ignored-patterns '^http(|s)://'
zstyle ":completion:*:${service}:*:hosts" ignored-patterns '^*github.com'

_arguments '1::GitHub URL:_urls' '2::code:' && return 0
8 changes: 5 additions & 3 deletions modules/git/functions/git-hub-shorten-url
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,22 @@

# function git-hub-shorten-url {

local url="$1"
local url="$1" code="$2"

if [[ "$url" == '-' ]]; then
read url <&0
fi

if [[ -z "$url" || ! "$url" =~ ^https?:\/\/.*github.com\/ ]]; then
print "usage: $0 [ url | - ] ; must be a github.com URL" >&2
print "usage: $0 [ url | - ] [code] ; url must be a github.com URL" >&2
return 1
fi

if (( $+commands[curl] )); then
curl -s -i 'https://git.io' -F "url=$url" | sed -n 's/^Location: //p'
curl -s -i 'https://git.io' -F "url=$url" ${(s: :)code:+ -F "code=$code"} | sed -n 's/^Location: //p'
else
print "$0: command not found: curl" >&2
return 1
fi

# }
2 changes: 1 addition & 1 deletion modules/gnu-utility/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ _gnu_utility_cmds=(
# Wrap GNU utilities in functions.
for _gnu_utility_cmd in "${_gnu_utility_cmds[@]}"; do
_gnu_utility_pcmd="${_gnu_utility_p}${_gnu_utility_cmd}"
if (( ${+commands[${_gnu_utility_pcmd}]} )); then
if (( ${+commands[${_gnu_utility_pcmd}]} && ! ${+builtins[${_gnu_utility_cmd}]} )); then
eval "
function ${_gnu_utility_cmd} {
'${commands[${_gnu_utility_pcmd}]}' \"\$@\"
Expand Down
6 changes: 3 additions & 3 deletions modules/gpg/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ fi
_gpg_agent_conf="${GNUPGHOME:-$HOME/.gnupg}/gpg-agent.conf"
_gpg_agent_env="${TMPDIR:-/tmp}/gpg-agent.env.$UID"

# Load environment variables from previous run
source "$_gpg_agent_env" 2> /dev/null

# Start gpg-agent if not started.
if [[ -z "$GPG_AGENT_INFO" && ! -S "${GNUPGHOME:-$HOME/.gnupg}/S.gpg-agent" ]]; then
# Export environment variables.
source "$_gpg_agent_env" 2> /dev/null

# Start gpg-agent if not started.
if ! ps -U "$LOGNAME" -o pid,ucomm | grep -q -- "${${${(s.:.)GPG_AGENT_INFO}[2]}:--1} gpg-agent"; then
eval "$(gpg-agent --daemon | tee "$_gpg_agent_env")"
Expand Down
2 changes: 1 addition & 1 deletion modules/node/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fi

# Load NPM completion.
if (( $+commands[npm] )); then
cache_file="${0:h}/cache.zsh"
cache_file="${TMPDIR:-/tmp}/prezto-node-cache.$UID.zsh"

if [[ "$commands[npm]" -nt "$cache_file" || ! -s "$cache_file" ]]; then
# npm is slow; cache its output.
Expand Down
18 changes: 13 additions & 5 deletions modules/pacman/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ frontends.
Settings
--------

To enable a Pacman frontend, for example, [Yaourt][2], add the following line to
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]).

To enable a Pacman frontend, for example, [Pacaur][2], add the following line to
*zpreztorc*:

```sh
zstyle ':prezto:module:pacman' frontend 'yaourt'
zstyle ':prezto:module:pacman' frontend 'pacaur'
```

If you have enabled color globally in *zpreztorc*, you may disable it for certain
Expand Down Expand Up @@ -48,6 +52,9 @@ Aliases

#### Yaourt

Note that there are currently potential security concerns relating to yaourt, so
other frontends are recommended.

- `pacc` manages *.pac\** files.

Functions
Expand All @@ -59,11 +66,12 @@ Functions
Authors
-------

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

- [Benjamin Boudreau](https://github.com/dreur)
- [Sorin Ionescu](https://github.com/sorin-ionescu)

[1]: http://www.archlinux.org/pacman/
[2]: http://archlinux.fr/yaourt-en
[3]: https://github.com/sorin-ionescu/prezto/issues
[2]: https://github.com/rmarquis/pacaur
[3]: http://archlinux.fr/yaourt-en
[4]: https://github.com/sorin-ionescu/prezto/issues
2 changes: 1 addition & 1 deletion modules/perl/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fi

if [[ "$OSTYPE" == darwin* ]]; then
# Perl is slow; cache its output.
cache_file="${0:h}/cache.zsh"
cache_file="${TMPDIR:-/tmp}/prezto-perl-cache.$UID.zsh"
perl_path="$HOME/Library/Perl/5.12"

if [[ -f "$perl_path/lib/perl5/local/lib.pm" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion modules/prompt/external/async
Submodule async updated 4 files
+1 −0 .travis.yml
+2 −0 README.md
+15 −12 async.zsh
+67 −12 async_test.zsh
Loading

0 comments on commit aba026f

Please sign in to comment.