diff --git a/.gitmodules b/.gitmodules
index a898a30646..7a7a7b5ecb 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -7,6 +7,3 @@
[submodule "modules/completion/external"]
path = modules/completion/external
url = https://github.com/zsh-users/zsh-completions.git
-[submodule "modules/z/external"]
- path = modules/z/external
- url = https://github.com/rupa/z.git
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000000..07e21976f9
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,42 @@
+Contributing
+------------
+
+This project would not exist without all of its users and [contributors][1].
+
+If you have ideas on how to make the configuration easier to maintain or
+improve its performance, do not hesitate to fork and send pull requests.
+
+### Issue Reporting
+
+ - Check that the issue has not already been reported.
+ - Check that the issue has not already been fixed in the latest code.
+ - Open an issue with a clear title and description in grammatically correct,
+ complete sentences.
+
+### Pull Request
+
+ - Read [how to properly contribute to open source projects on GitHub][2].
+ - Use a topic branch to easily amend a pull request later, if necessary.
+ - Write [good commit messages][3].
+ - Squash commits on the topic branch before opening a pull request.
+ - Use the same coding style and spacing.
+ - Open a [pull request][4] that relates to but one subject with a clear
+ title and description in grammatically correct, complete sentences.
+
+#### Modules
+
+ - A *README.md* must be present.
+ - Large functions must be placed in a *functions* directory.
+ - Functions that take arguments must have completion.
+
+#### Themes
+
+ - A screenshots section must be present in the file header.
+ - The pull request description must have [embedded screenshots][5].
+
+[1]: https://github.com/sorin-ionescu/prezto/contributors
+[2]: http://gun.io/blog/how-to-github-fork-branch-and-pull-request
+[3]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
+[4]: https://help.github.com/articles/using-pull-requests
+[5]: http://daringfireball.net/projects/markdown/syntax#img
+
diff --git a/README.md b/README.md
index 5172bd46f4..2955fe57dd 100644
--- a/README.md
+++ b/README.md
@@ -91,43 +91,6 @@ Resources
The [Zsh Reference Card][7] and the [zsh-lovers][8] man page are indispensable.
-Contribute
-----------
-
-This project would not exist without all of its users and [contributors][9].
-
-If you have ideas on how to make the configuration easier to maintain or
-improve its performance, do not hesitate to fork and send pull requests.
-
-### Issue Reporting
-
- - Check that the issue has not already been reported.
- - Check that the issue has not already been fixed in the latest code.
- - Open an issue with a clear title and description in grammatically correct,
- complete sentences.
-
-### Pull Request
-
- - Read [how to properly contribute to open source projects on GitHub][10].
- - Use a topic branch to easily amend a pull request later, if necessary.
- - Write [good commit messages][11].
- - Squash commits on the topic branch before opening a pull request.
- - Use the same coding style and spacing.
- - Open a [pull request][12] that relates to but one subject with a clear
- title and description in grammatically correct, complete sentences.
-
-#### Modules
-
- - A *README.md* must be present.
- - Large functions must be placed in a *functions* directory.
- - Functions that take arguments must have completion.
-
-#### Themes
-
- - A screenshots section must be present in the file header.
- - The pull request description must have [embedded
- screenshots][13].
-
License
-------
@@ -154,16 +117,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
[1]: http://www.zsh.org
-[2]: http://i.imgur.com/ij8Lv.png "sorin theme"
+[2]: http://i.imgur.com/nBEEZ.png "sorin theme"
[3]: http://git-scm.com
[4]: https://github.com
[5]: http://gitimmersion.com
[6]: http://gitref.org
[7]: http://www.bash2zsh.com/zsh_refcard/refcard.pdf
[8]: http://grml.org/zsh/zsh-lovers.html
-[9]: https://github.com/sorin-ionescu/prezto/contributors
-[10]: http://gun.io/blog/how-to-github-fork-branch-and-pull-request
-[11]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
-[12]: https://help.github.com/articles/using-pull-requests
-[13]: http://daringfireball.net/projects/markdown/syntax#img
diff --git a/init.zsh b/init.zsh
index 4c19daf3ce..fc12297c6f 100644
--- a/init.zsh
+++ b/init.zsh
@@ -47,7 +47,7 @@ function pmodload {
# Load Prezto modules.
for pmodule in "$pmodules[@]"; do
- if zstyle -t ":prezto:module:$pmodule" loaded; then
+ if zstyle -t ":prezto:module:$pmodule" loaded 'yes' 'no'; then
continue
elif [[ ! -d "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule" ]]; then
print "$0: no such module: $pmodule" >&2
diff --git a/modules/README.md b/modules/README.md
new file mode 100644
index 0000000000..79a472536b
--- /dev/null
+++ b/modules/README.md
@@ -0,0 +1,169 @@
+Modules
+=======
+
+Load modules in *zpreztorc*. The order matters.
+
+ zstyle ':prezto:load' pmodule 'environment' 'terminal'
+
+Archive
+-------
+
+Provides functions to extract and list popular archive formats.
+
+Command-Not-Found
+-----------------
+
+Loads the command-not-found tool on Debian-based distributions.
+
+Completion
+----------
+
+Loads and configures tab completion and provides additional completions from
+the zsh-completions project.
+
+Directory
+---------
+
+Sets directory options and defines directory aliases.
+
+Dpkg
+----
+
+Defines dpkg aliases and functions.
+
+Environment
+-----------
+
+Sets general shell options and defines environment variables.
+
+Fasd
+----
+
+Maintains a frequently used file and directory list for fast access.
+
+GNU Utility
+-----------
+
+Provides for the interactive use of GNU utilities on non-GNU systems.
+
+GPG-Agent
+---------
+
+Provides for an easier use of gpg-agent.
+
+Haskell
+-------
+
+Enables local Haskell package installation.
+
+Helper
+------
+
+Provides helper functions for developing modules.
+
+History Substring Search
+------------------------
+
+Integrates zsh-history-substring-search into Prezto.
+
+History
+-------
+
+Sets history options and defines history aliases.
+
+Macports
+--------
+
+Defines MacPorts aliases and adds MacPorts directories to path variables.
+
+Node.js
+-------
+
+Provides utility functions for Node.js and loads npm completion.
+
+OSX
+---
+
+Defines Mac OS X aliases and functions.
+
+Pacman
+------
+
+Provides aliases and functions for the Pacman package manager and frontends.
+
+Perl
+----
+
+Enables local Perl module installation on Mac OS X and defines alises.
+
+Prompt
+------
+
+Loads prompt themes.
+
+Python
+------
+
+Enables local Python and local Python package installation.
+
+Ruby on Rails
+-------------
+
+Defines Ruby on Rails aliases.
+
+Rsync
+-----
+
+Defines rsync aliases.
+
+Ruby
+----
+
+Configures Ruby local gem installation, loads version managers, and defines
+aliases.
+
+GNU Screen
+----------
+
+Defines GNU Screen aliases and provides for auto launching it at start-up.
+
+Spectrum
+--------
+
+Provides for easier use of 256 colors and effects.
+
+SSH-Agent
+---------
+
+Provides for an easier use of ssh-agent.
+
+Syntax Highlighting
+-------------------
+
+Integrates zsh-syntax-highlighting into Prezto.
+
+Terminal
+--------
+
+Sets terminal window and tab titles.
+
+Tmux
+----
+
+Defines tmux aliases and provides for auto launching it at start-up.
+
+Utility
+-------
+
+Defines general aliases and functions.
+
+Wake-on-LAN
+-----------
+
+This module provides a wrapper around the wakeonlan tool.
+
+Yum
+---
+
+Defines yum aliases.
+
diff --git a/modules/completion/external b/modules/completion/external
index 589938ffc9..9ef8d2f088 160000
--- a/modules/completion/external
+++ b/modules/completion/external
@@ -1 +1 @@
-Subproject commit 589938ffc9c241952743051d907f7cb451eb157f
+Subproject commit 9ef8d2f088d302fdedfa89b9cfd88ef926166a7c
diff --git a/modules/editor/init.zsh b/modules/editor/init.zsh
index 5f035b677e..dc2cfa500d 100644
--- a/modules/editor/init.zsh
+++ b/modules/editor/init.zsh
@@ -18,27 +18,27 @@
# To indicate when the editor is in the primary keymap (emacs or viins), add
# the following to your theme prompt setup function.
#
-# zstyle ':prezto:module:editor:keymap' primary '>>>'
+# zstyle ':prezto:module:editor:info:keymap:primary' format '>>>'
#
# To indicate when the editor is in the primary keymap (emacs or viins) insert
# mode, add the following to your theme prompt setup function.
#
-# zstyle ':prezto:module:editor:keymap:primary' insert 'I'
+# zstyle ':prezto:module:editor:info:keymap:primary:insert' format 'I'
#
# To indicate when the editor is in the primary keymap (emacs or viins)
# overwrite mode, add the following to your theme prompt setup function.
#
-# zstyle ':prezto:module:editor:keymap:primary' overwrite 'O'
+# zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format 'O'
#
# To indicate when the editor is in the alternate keymap (vicmd), add the
# following to your theme prompt setup function.
#
-# zstyle ':prezto:module:editor:keymap' alternate '<<<'
+# zstyle ':prezto:module:editor:info:keymap:alternate' format '<<<'
#
# To indicate when the editor is completing, add the following to your theme
# prompt setup function.
#
-# zstyle ':prezto:module:editor' completing '...'
+# zstyle ':prezto:module:editor:info:completing' format '...'
#
# Return if requirements are not found.
@@ -53,10 +53,6 @@ fi
# Beep on error in line editor.
setopt BEEP
-# Allow command line editing in an external editor.
-autoload -Uz edit-command-line
-zle -N edit-command-line
-
#
# Variables
#
@@ -95,13 +91,22 @@ key_info=(
)
# Do not bind any keys if there are empty values in $key_info.
-for key in "$key_info[@]"; do
- if [[ -z "$key" ]]; then
+for key in "${(k)key_info[@]}"; do
+ if [[ -z "$key_info[$key]" ]]; then
print "prezto: one or more keys are non-bindable" >&2
+ unset key{,_info}
return 1
fi
done
+#
+# External Editor
+#
+
+# Allow command line editing in an external editor.
+autoload -Uz edit-command-line
+zle -N edit-command-line
+
#
# Functions
#
@@ -114,17 +119,17 @@ function editor-info {
typeset -gA editor_info
if [[ "$KEYMAP" == 'vicmd' ]]; then
- zstyle -s ':prezto:module:editor:keymap' alternate 'REPLY'
+ zstyle -s ':prezto:module:editor:info:keymap:alternate' format 'REPLY'
editor_info[keymap]="$REPLY"
else
- zstyle -s ':prezto:module:editor:keymap' primary 'REPLY'
+ zstyle -s ':prezto:module:editor:info:keymap:primary' format 'REPLY'
editor_info[keymap]="$REPLY"
if [[ "$ZLE_STATE" == *overwrite* ]]; then
- zstyle -s ':prezto:module:editor:keymap:primary' overwrite 'REPLY'
+ zstyle -s ':prezto:module:editor:info:keymap:primary:overwrite' format 'REPLY'
editor_info[overwrite]="$REPLY"
else
- zstyle -s ':prezto:module:editor:keymap:primary' insert 'REPLY'
+ zstyle -s ':prezto:module:editor:info:keymap:primary:insert' format 'REPLY'
editor_info[overwrite]="$REPLY"
fi
fi
@@ -186,7 +191,7 @@ zle -N expand-dot-to-parent-directory-path
# Displays an indicator when completing.
function expand-or-complete-with-indicator {
local indicator
- zstyle -s ':prezto:module:editor' completing 'indicator'
+ zstyle -s ':prezto:module:editor:info:completing' format 'indicator'
print -Pn "$indicator"
zle expand-or-complete
zle redisplay
diff --git a/modules/fasd/README.md b/modules/fasd/README.md
new file mode 100644
index 0000000000..5cfc2cc75d
--- /dev/null
+++ b/modules/fasd/README.md
@@ -0,0 +1,39 @@
+Fasd
+====
+
+[Fasd][1] is a command-line productivity booster, inspired by tools like
+[autojump][2], [z][3] and [v][4], it offers quick access to files and
+directories by keeping track of files and directories that were previously
+accessed.
+
+For completion to work, this module must be loaded **after** the *completion*
+module.
+
+The Prezto Fasd configuration differs from the default. The default aliases have
+been disabled.
+
+Aliases
+-------
+
+ - `j` changes the current working directory interactively.
+
+Completion
+----------
+
+Type `,`, `f,`, `d,` in front of a comma-separated query or type `,,`, `,,f`,
+`,,d` at the end of a comma-separated query then hit tab.
+
+Authors
+-------
+
+*The authors of this module should be contacted via the [issue tracker][5].*
+
+ - [Wei Dai](https://github.com/clvv)
+ - [Sorin Ionescu](https://github.com/sorin-ionescu)
+
+[1]: https://github.com/clvv/fasd
+[2]: https://github.com/joelthelion/autojump
+[3]: https://github.com/rupa/z
+[4]: https://github.com/rupa/v
+[5]: https://github.com/sorin-ionescu/prezto/issues
+
diff --git a/modules/fasd/init.zsh b/modules/fasd/init.zsh
new file mode 100644
index 0000000000..7088e9c681
--- /dev/null
+++ b/modules/fasd/init.zsh
@@ -0,0 +1,54 @@
+#
+# Maintains a frequently used file and directory list for fast access.
+#
+# Authors:
+# Wei Dai
+# Sorin Ionescu
+#
+
+# Load dependencies.
+pmodload 'editor'
+
+# Return if requirements are not found.
+if (( ! $+commands[fasd] )); then
+ return 1
+fi
+
+#
+# Initialization
+#
+
+cache_file="${0:h}/cache.zsh"
+if [[ "${commands[fasd]}" -nt "$cache_file" || ! -s "$cache_file" ]]; then
+ # Set the base init arguments.
+ init_args=(zsh-hook)
+
+ # Set fasd completion init arguments, if applicable.
+ if zstyle -t ':prezto:module:completion' loaded; then
+ init_args+=(zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install)
+ fi
+
+ # Cache init code.
+ fasd --init "$init_args[@]" >! "$cache_file" 2> /dev/null
+fi
+
+source "$cache_file"
+
+unset cache_file init_args
+
+function fasd_cd {
+ local fasd_ret="$(fasd -d "$@")"
+ if [[ -d "$fasd_ret" ]]; then
+ cd "$fasd_ret"
+ else
+ print "$fasd_ret"
+ fi
+}
+
+#
+# Aliases
+#
+
+# Changes the current working directory interactively.
+alias j='fasd_cd -i'
+
diff --git a/modules/git/README.md b/modules/git/README.md
new file mode 100644
index 0000000000..806bc9ca15
--- /dev/null
+++ b/modules/git/README.md
@@ -0,0 +1,315 @@
+Git
+===
+
+Enhances the [Git][1] distributed version control system by providing aliases, functions and by exposing repository status information to prompts.
+
+Git **1.7.2** is the [minimum required version][7].
+
+Settings
+--------
+
+### Log
+
+The format of the [git-log][8] output is configurable via the following style,
+where context is *brief*, *oneline*, and *medium*, which will be passed to the
+`--prety=format:` switch.
+
+ zstyle ':prezto:module:git:log:context' format ''
+
+### Status
+
+Retrieving the status of a repository with submodules can take a long time.
+Submodules may be ignored when they are *dirty*, *untracked*, *all*, or *none*.
+
+ zstyle ':prezto:module:git:status:ignore' submodules 'all'
+
+This setting affects all aliases and functions that call `git-status`.
+
+Aliases
+-------
+
+### Git
+
+ - `g` is short for `git`.
+
+### Branch
+
+ - `gb` lists, creates, renames, and deletes branches.
+ - `gbc` creates a new branch.
+ - `gbl` lists branches and their commits.
+ - `gbL` lists local and remote branches and their commits.
+ - `gbs` lists branches and their commits with ancestery graphs.
+ - `gbS` lists local and remote branches and their commits with ancestery
+ graphs.
+ - `gbx` deletes a branch.
+ - `gbX` deletes a branch irrespective of its merged status.
+ - `gbm` renames a branch.
+ - `gbM` renames a branch even if the new branch name already exists.
+
+
+### Commit
+
+ - `gc` records changes to the repository.
+ - `gca` stages all modified and deleted files.
+ - `gcm` records changes to the repository with the given message.
+ - `gco` checks out a branch or paths to work tree.
+ - `gcO` checks out paths to work tree using the *HEAD* commit.
+ - `gcf` amends the tip of the current branch using the same log message as
+ *HEAD*.
+ - `gcp` applies changes introduced by existing commits.
+ - `gcP` applies changes introduced by existing commits without committing.
+ - `gcr` reverts existing commits by reverting patches and recording new
+ commits.
+ - `gcR` removes the *HEAD* commit.
+ - `gcs` displays various types of objects.
+ - `gcl` displays lost commits.
+
+### Data
+
+ - `gd` displays information about files in the index and the work tree.
+ - `gdc` lists cached files.
+ - `gdx` lists deleted files.
+ - `gdm` lists modified files.
+ - `gdu` lists untracked files.
+ - `gdk` lists killed files.
+ - `gdi` lists ignored files.
+
+### Fetch
+
+ - `gf` downloads objects and references from another repository.
+ - `gfc` clones a repository into a new directory.
+ - `gfm` fetches from and merges with another repository or local branch.
+ - `gfr` fetches from and rebases on another repository or local branch.
+
+### Grep
+
+ - `gg` displays lines matching a pattern.
+ - `ggi` displays lines matching a pattern ignoring case.
+ - `ggl` displays files matching a pattern.
+ - `ggL` displays files are not matching a pattern.
+ - `ggv` displays lines not matching a pattern.
+ - `ggw` displays lines matching a pattern at word boundary.
+
+### Index
+
+ - `gia` adds file contents to the index.
+ - `giA` adds file contents to the index interactively.
+ - `giu` adds file contents to the index (updates only known files).
+ - `gid` displays changes between the index and a named commit (diff).
+ - `giD` displays changes between the index and a named commit (word diff).
+ - `gir` resets current HEAD to the specified state.
+ - `giR` resets current index to the specified state.
+ - `gix` removes files/directories from the index (recursively).
+ - `giX` removes files/directories from the index (recursively and forced).
+
+### Conflict
+
+ - `gCl` lists unmerged files.
+ - `gCa` adds unmerged file contents to the index.
+ - `gCe` executes merge-tool on all unmerged file.
+ - `gCo` checks out our changes for unmerged paths.
+ - `gCO` checks out our changes for all unmerged paths.
+ - `gCt` checks out their changes for unmerged paths.
+ - `gCT` checks out their changes for all unmerged paths.
+
+### Log
+
+ - `gl` displays the log.
+ - `gls` displays the stats log.
+ - `gld` displays the diff log.
+ - `glo` displays the one line log.
+ - `glg` displays the graph log.
+ - `glb` displays the brief commit log.
+ - `glc` displays the commit count for each contributor in descending order.
+
+### Merge
+
+ - `gm` joins two or more development histories together.
+ - `gmC` joins two or more development histories together but does not commit.
+ - `gmF` joins two or more development histories together but does not commit
+ generating a merge commit even if the merge resolved as a fast-forward.
+ - `gma` aborts the conflict resolution, and reconstructs the pre-merge state.
+ - `gmt` runs the merge conflict resolution tools to resolve conflicts.
+
+### Push
+
+ - `gp` updates remote refs along with associated objects.
+ - `gpf` forcefully updates remote refs along with associated objects.
+ - `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.
+ - `gpc` updates remote refs along with associated objects and adds *origin*
+ as an upstream reference for the current branch.
+ - `gpp` pulls and pushes from origin to origin.
+
+### Rebase
+
+ - `gr` forward-ports local commits to the updated upstream head.
+ - `gra` aborts the rebase.
+ - `grc` continues the rebase after merge conflicts are resolved.
+ - `gri` makes a list of commits to be rebased and opens the editor.
+ - `grs` skips the current patch.
+
+### Remote
+
+ - `gR` manages tracked repositories.
+ - `gRl` displays remote names and URLs.
+ - `gRa` adds a new remote.
+ - `gRx` removes a remote.
+ - `gRm` renames a remote.
+ - `gRu` fetches remotes updates.
+ - `gRc` deletes all stale remote tracking branches.
+ - `gRs` displays information about a given remote.
+ - `gRb` opens a remote on [GitHub][3] in the default browser.
+
+### Stash
+
+ - `gs` stashes the changes of the dirty working directory.
+ - `gsa` applies the changes recorded in a stash to the working directory.
+ - `gsx` drops a stashed state.
+ - `gsX` drops all the stashed states.
+ - `gsd` lists dropped stashed states.
+ - `gsl` lists stashed states.
+ - `gsL` displays the changes recorded in the stash as a diff between the
+ stashed state and its original parent.
+ - `gsp` removes and applies a single stashed state from the stash list.
+ - `gsr` recovers a given stashed state.
+ - `gss` stashes the changes of the dirty working directory, including untracked.
+ - `gsS` stashes the changes of the dirty working directory interactively.
+ - `gsw` stashes the changes of the dirty working directory retaining the index.
+
+### Submodule
+
+ - `gS` initializes, updates, or inspects submodules.
+ - `gSa` adds given a repository as a submodule.
+ - `gSf` evaluates a shell command in each of checked out submodules.
+ - `gSi` initializes submodules.
+ - `gSI` initializes and clones submodules recursively.
+ - `gSl` lists the commits of all submodules.
+ - `gSm` moves a submodule.
+ - `gSs` synchronizes submodules' remote URL to the value specified in
+ .gitmodules.
+ - `gSu` fetches and merges the latest changes for all submodule.
+ - `gSx` removes a submodule.
+
+### Working directory
+
+ - `gws` displays working-tree status in the short format.
+ - `gwS` displays working-tree status.
+ - `gwd` displays changes between the working tree and the index (diff).
+ - `gwD` displays changes between the working tree and the index (word diff).
+ - `gwr` resets the current HEAD to the specified state, does not touch the
+ index nor the working tree.
+ - `gwR` resets the current HEAD, index and working tree to the specified state.
+ - `gwc` removes untracked files from the working tree (dry-run).
+ - `gwC` removes untracked files from the working tree.
+ - `gwx` removes files from the working tree and from the index recursively.
+ - `gwX` removes files from the working tree and from the index recursively and
+ forcefully.
+
+### Shadows
+
+The following aliases may shadow system commands:
+
+ - `gpt` shadows the [GUID partition table maintenance utility][4].
+ - `gs` shadows the [Ghostscript][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`.
+
+You can temporarily bypass an alias by prefixing it with a backward slash:
+`\gpt`.
+
+Functions
+---------
+
+ - `git-branch-current` displays the current branch.
+ - `git-commit-lost` lists lost commits.
+ - `git-dir` displays the path to the Git directory.
+ - `git-hub-browse` opens the [GitHub][3] repository in the default browser.
+ - `git-hub-shorten-url` shortens GitHub URLs.
+ - `git-info` exposes repository information via the `$git_info` associative
+ array.
+ - `git-root` displays the path to the working tree root.
+ - `git-stash-clear-interactive` asks for confirmation before clearing the stash.
+ - `git-stash-dropped` lists dropped stashed states.
+ - `git-stash-recover` recovers given dropped stashed states.
+ - `git-submodule-move` moves a submodule.
+ - `git-submodule-remove` removes a submodule.
+
+Theming
+-------
+
+To display information about the current repository in a prompt, define the
+following styles in the `prompt_name_setup` function, where the syntax for
+setting a style is as follows.
+
+ zstyle ':prezto:module:git:info:context:subcontext' format 'string'
+
+### Main Contexts
+
+| Name | Format Code | Description
+| --------- | :---------: | ---------------------------------------------------
+| action | %s | Special action name
+| added | %a | Added files count
+| ahead | %A | Commits ahead of remote count
+| behind | %B | Commits behind of remote count
+| branch | %b | Branch name
+| commit | %c | Commit hash
+| clean | %C | Clean state
+| deleted | %d | Deleted files count
+| dirty | %D | Dirty files count
+| modified | %m | Modified files count
+| position | %p | Commits from the nearest tag count
+| remote | %R | Remote name
+| renamed | %r | Renamed files count
+| stashed | %S | Stashed states count
+| unmerged | %U | Unmerged files count
+| untracked | %u | Untracked files count
+
+### Special Action Contexts
+
+| Name | Format | Description
+| -------------------- | :---------: | -----------------------------------------
+| apply | value | Applying patches
+| bisect | value | Binary searching for changes
+| cherry-pick | value | Cherry picking
+| cherry-pick-sequence | value | Cherry picking sequence
+| merge | value | Merging
+| rebase | value | Rebasing
+| rebase-interactive | value | Rebasing interactively
+| rebase-merge | value | Rebasing merge
+
+First, format the repository state attributes. For example, to format the branch
+and remote names, define the following styles.
+
+ zstyle ':prezto:module:git:info:branch' format 'branch:%b'
+ zstyle ':prezto:module:git:info:remote' format 'remote:%R'
+
+Second, format how the above attributes are displayed in prompts.
+
+ zstyle ':prezto:module:git:info:keys' format \
+ 'prompt' ' git(%b)' \
+ 'rprompt' '[%R]'
+
+Last, add `$git_info[prompt]` to `$PROMPT` and `$git_info[prompt]` to
+`$RPROMPT` respectively and call `git-info` in the `prompt_name_preexec` hook
+function.
+
+Authors
+-------
+
+*The authors of this module should be contacted via the [issue tracker][6].*
+
+ - [Sorin Ionescu](https://github.com/sorin-ionescu)
+ - [Colin Hebert](https://github.com/ColinHebert)
+
+[1]: http://www.git-scm.com
+[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
+[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
+
diff --git a/modules/git/alias.zsh b/modules/git/alias.zsh
index 9608c5a765..8d84d92387 100644
--- a/modules/git/alias.zsh
+++ b/modules/git/alias.zsh
@@ -5,6 +5,27 @@
# Sorin Ionescu
#
+#
+# Settings
+#
+#
+
+# Log
+zstyle -s ':prezto:module:git:log:medium' format '_git_log_medium_format' \
+ || _git_log_medium_format='%C(bold)Commit:%C(reset) %C(green)%H%C(red)%d%n%C(bold)Author:%C(reset) %C(cyan)%an <%ae>%n%C(bold)Date:%C(reset) %C(blue)%ai (%ar)%C(reset)%n%+B'
+zstyle -s ':prezto:module:git:log:oneline' format '_git_log_oneline_format' \
+ || _git_log_oneline_format='%C(green)%h%C(reset) %s%C(red)%d%C(reset)%n'
+zstyle -s ':prezto:module:git:log:brief' format '_git_log_brief_format' \
+ || _git_log_brief_format='%C(green)%h%C(reset) %s%n%C(blue)(%ar by %an)%C(red)%d%C(reset)%n'
+
+# Status
+zstyle -s ':prezto:module:git:status:ignore' submodules '_git_status_ignore_submodules' \
+ || _git_status_ignore_submodules='none'
+
+#
+# Aliases
+#
+
# Git
alias g='git'
@@ -49,6 +70,14 @@ alias gfc='git clone'
alias gfm='git pull'
alias gfr='git pull --rebase'
+# Grep (g)
+alias gg='git grep'
+alias ggi='git grep --ignore-case'
+alias ggl='git grep --files-with-matches'
+alias ggL='git grep --files-without-matches'
+alias ggv='git grep --invert-match'
+alias ggw='git grep --word-regexp'
+
# Index (i)
alias gia='git add'
alias giA='git add --patch'
@@ -59,28 +88,23 @@ alias gir='git reset'
alias giR='git reset --keep'
alias gix='git rm -r --cached'
alias giX='git rm -rf --cached'
-alias gig='git grep --cached'
-# Konflict (k)
-alias gkl='git status | sed -n "s/^.*both [a-z]*ed: *//p"'
-alias gka='git add $(gkl)'
-alias gke='git mergetool $(gkl)'
-alias gko='git checkout --ours --'
-alias gkO='gko $(gkl)'
-alias gkt='git checkout --theirs --'
-alias gkT='gkt $(gkl)'
+# Conflict (C)
+alias gCl='git status | sed -n "s/^.*both [a-z]*ed: *//p"'
+alias gCa='git add $(gCl)'
+alias gCe='git mergetool $(gCl)'
+alias gCo='git checkout --ours --'
+alias gCO='gCo $(gCl)'
+alias gCt='git checkout --theirs --'
+alias gCT='gCt $(gCl)'
# Log (l)
-git_log_format_medium='--pretty=format:%C(bold)Commit:%C(reset) %C(green)%H%C(red)%d%n%C(bold)Author:%C(reset) %C(cyan)%an <%ae>%n%C(bold)Date:%C(reset) %C(blue)%ai (%ar)%C(reset)%n%+B'
-git_log_format_oneline='--pretty=format:%C(green)%h%C(reset) %s%C(red)%d%C(reset)%n'
-git_log_format_brief='--pretty=format:%C(green)%h%C(reset) %s%n%C(blue)(%ar by %an)%C(red)%d%C(reset)%n'
-
-alias gl='git log --topo-order ${git_log_format_medium}'
-alias gls='git log --topo-order --stat ${git_log_format_medium}'
-alias gld='git log --topo-order --stat --patch --full-diff ${git_log_format_medium}'
-alias glo='git log --topo-order ${git_log_format_oneline}'
-alias glg='git log --topo-order --all --graph ${git_log_format_oneline}'
-alias glb='git log --topo-order ${git_log_format_brief}'
+alias gl='git log --topo-order --pretty=format:${_git_log_medium_format}'
+alias gls='git log --topo-order --stat --pretty=format:${_git_log_medium_format}'
+alias gld='git log --topo-order --stat --patch --full-diff --pretty=format:${_git_log_medium_format}'
+alias glo='git log --topo-order --pretty=format:${_git_log_oneline_format}'
+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'
# Merge (m)
@@ -96,8 +120,8 @@ alias gpf='git push --force'
alias gpa='git push --all'
alias gpA='git push --all && git push --tags'
alias gpt='git push --tags'
-alias gpc='git push --set-upstream origin "$(git-branch-current)"'
-alias gpp='git pull origin "$(git-branch-current)" && git push origin "$(git-branch-current)"'
+alias gpc='git push --set-upstream origin "$(git-branch-current 2> /dev/null)"'
+alias gpp='git pull origin "$(git-branch-current 2> /dev/null)" && git push origin "$(git-branch-current 2> /dev/null)"'
# Rebase (r)
alias gr='git rebase'
@@ -115,13 +139,13 @@ alias gRm='git remote rename'
alias gRu='git remote update'
alias gRc='git remote prune'
alias gRs='git remote show'
-alias gRb='git-hub'
+alias gRb='git-hub-browse'
# Stash (s)
alias gs='git stash'
alias gsa='git stash apply'
-alias gsc='git-stash-clear-interactive'
alias gsx='git stash drop'
+alias gsX='git-stash-clear-interactive'
alias gsd='git-stash-dropped'
alias gsl='git stash list'
alias gsL='git stash show --patch --stat'
@@ -129,20 +153,23 @@ alias gsp='git stash pop'
alias gsr='git-stash-recover'
alias gss='git stash save --include-untracked'
alias gsS='git stash save --patch --no-keep-index'
+alias gsw='git stash save --include-untracked --keep-index'
# Submodule (S)
alias gS='git submodule'
alias gSa='git submodule add'
alias gSf='git submodule foreach'
alias gSi='git submodule init'
+alias gSI='git submodule update --init --recursive'
alias gSl='git submodule status'
+alias gSm='git-submodule-move'
alias gSs='git submodule sync'
-alias gSu='git submodule update --init --recursive'
-alias gSU='git submodule foreach git pull origin master'
+alias gSu='git submodule foreach git pull origin master'
+alias gSx='git-submodule-remove'
# Working Copy (w)
-alias gws='git status --short'
-alias gwS='git status'
+alias gws='git status --ignore-submodules=${_git_status_ignore_submodules} --short'
+alias gwS='git status --ignore-submodules=${_git_status_ignore_submodules}'
alias gwd='git diff --no-ext-diff'
alias gwD='git diff --no-ext-diff --word-diff'
alias gwr='git reset --soft'
@@ -151,5 +178,4 @@ alias gwc='git clean -n'
alias gwC='git clean -f'
alias gwx='git rm -r'
alias gwX='git rm -rf'
-alias gwg='git grep'
diff --git a/modules/git/functions/_git-hub b/modules/git/functions/_git-hub
deleted file mode 100644
index ac17fd27a2..0000000000
--- a/modules/git/functions/_git-hub
+++ /dev/null
@@ -1,44 +0,0 @@
-#compdef git-hub
-#autoload
-
-#
-# Completes git-hub.
-#
-# Authors:
-# Sorin Ionescu
-#
-
-local state remotes remote branches files ret=1
-
-_arguments -C -s -S \
- '1::args:->remote' \
- '2::args:->branch' \
- '3::args:->file' && ret=0
-
-case "$state" in
- (remote)
- remotes=($(
- git config -l \
- | grep 'remote\.[^.]*\.url' \
- | cut -d'.' -f2))
- _describe -t branch 'remotes' remotes && ret=0
- ;;
- (branch)
- remote="$words[(($CURRENT - 1))]"
- branches=($(
- git branch -r \
- | grep "${remote}/" \
- | sed \
- -e "/${remote}\/HEAD -> ${remote}/d" \
- -e "s/^[[:space:]]*${remote}\///g"
- ))
- _describe -t branch 'branches' branches && ret=0
- ;;
- (file)
- files=(${(0)"$(_call_program files git ls-files -z --exclude-standard 2>/dev/null)"})
- _wanted file expl 'file' _multi_parts - / files && ret=0
- ;;
-esac
-
-return $ret
-
diff --git a/modules/git/functions/_git-hub-browse b/modules/git/functions/_git-hub-browse
new file mode 100644
index 0000000000..0085c18886
--- /dev/null
+++ b/modules/git/functions/_git-hub-browse
@@ -0,0 +1,48 @@
+#compdef git-hub-browse
+#autoload
+
+#
+# Completes git-hub-browse.
+#
+# Authors:
+# Sorin Ionescu
+#
+
+if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
+ return 1
+fi
+
+local state expl remotes remote branches_or_tags branches tags files ret=1
+
+_arguments -C -s -S \
+ '1::args:->remote' \
+ '2::args:->branch-or-tag' \
+ '3::args:->file' && ret=0
+
+case "$state" in
+ (remote)
+ remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2))
+
+ _describe -t branch 'remotes' remotes && ret=0
+ ;;
+ (branch-or-tag)
+ remote="$words[(($CURRENT - 1))]"
+
+ branches_or_tags=($(
+ git ls-remote --heads --tags "$remote" 2>/dev/null | cut -f2
+ ))
+
+ branches=(HEAD ${${(M)branches_or_tags[@]##refs/heads/?##}##refs/heads/})
+ tags=(${${(M)branches_or_tags[@]##refs/tags/?##}##refs/tags/})
+
+ _describe -t branch 'branches' branches && ret=0
+ _describe -t tag 'tags' tags && ret=0
+ ;;
+ (file)
+ files=(${(0)"$(_call_program files git ls-files -z --exclude-standard 2>/dev/null)"})
+ _wanted file expl 'file' _multi_parts - / files && ret=0
+ ;;
+esac
+
+return $ret
+
diff --git a/modules/git/functions/_git-hub-short-url b/modules/git/functions/_git-hub-shorten-url
similarity index 63%
rename from modules/git/functions/_git-hub-short-url
rename to modules/git/functions/_git-hub-shorten-url
index b0f997f04b..32199cee7a 100644
--- a/modules/git/functions/_git-hub-short-url
+++ b/modules/git/functions/_git-hub-shorten-url
@@ -1,8 +1,8 @@
-#compdef git-hub-short-url
+#compdef git-hub-shorten-url
#autoload
#
-# Completes git-hub-short-url.
+# Completes git-hub-shorten-url.
#
# Authors:
# Sorin Ionescu
diff --git a/modules/git/functions/_git-info b/modules/git/functions/_git-info
index 0357c6d8f4..c1467e84bb 100644
--- a/modules/git/functions/_git-info
+++ b/modules/git/functions/_git-info
@@ -8,6 +8,10 @@
# Sorin Ionescu
#
+if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
+ return 1
+fi
+
_arguments "1:toggle:((
on\:'enable in-prompt information for the current repository'
off\:'disable in-prompt information for the current repository'
diff --git a/modules/git/functions/_git-submodule-move b/modules/git/functions/_git-submodule-move
new file mode 100644
index 0000000000..ab8cd1ba17
--- /dev/null
+++ b/modules/git/functions/_git-submodule-move
@@ -0,0 +1,41 @@
+#compdef git-submodule-move
+#autoload
+
+#
+# Completes git-submodule-move.
+#
+# Authors:
+# Sorin Ionescu
+#
+
+if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
+ return 1
+fi
+
+local state expl ret=1
+local -a submodules
+local submodule
+
+_arguments -C -s -S \
+ '1::args:->submodule' \
+ '2::args:->directory' && ret=0
+
+case "$state" in
+ (submodule)
+ while IFS=$'\n' read submodule; do
+ submodules+=("$submodule")
+ done < <(
+ git config --file "$(git-root)/.gitmodules" --list \
+ | grep '.path=' \
+ | cut -d= -f2-
+ )
+
+ _describe -t submodule 'submodules' submodules && ret=0
+ ;;
+ (directory)
+ _wanted directories expl 'directory' _path_files -/ || _message 'directory'
+ ;;
+esac
+
+return $ret
+
diff --git a/modules/git/functions/_git-submodule-remove b/modules/git/functions/_git-submodule-remove
new file mode 100644
index 0000000000..1460dd0ec4
--- /dev/null
+++ b/modules/git/functions/_git-submodule-remove
@@ -0,0 +1,27 @@
+#compdef git-submodule-remove
+#autoload
+
+#
+# Completes git-submodule-remove.
+#
+# Authors:
+# Sorin Ionescu
+#
+
+if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
+ return 1
+fi
+
+local -a submodules
+local submodule
+
+while IFS=$'\n' read submodule; do
+ submodules+=("$submodule")
+done < <(
+ git config --file "$(git-root)/.gitmodules" --list \
+ | grep '.path=' \
+ | cut -d= -f2-
+)
+
+_describe -t submodule 'submodules' submodules && return 0
+
diff --git a/modules/git/functions/git-branch-current b/modules/git/functions/git-branch-current
index 3078ad13b8..c731958d90 100644
--- a/modules/git/functions/git-branch-current
+++ b/modules/git/functions/git-branch-current
@@ -5,7 +5,13 @@
# Sorin Ionescu
#
+if ! 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)"
+
if [[ -n "$ref" ]]; then
print "${ref#refs/heads/}"
return 0
diff --git a/modules/git/functions/git-commit-lost b/modules/git/functions/git-commit-lost
index ed9b0766e1..e4075c9b75 100644
--- a/modules/git/functions/git-commit-lost
+++ b/modules/git/functions/git-commit-lost
@@ -5,6 +5,11 @@
# Sorin Ionescu
#
+if ! is-true "$(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 \
| grep "^dangling commit" \
| awk '{print $3}' \
@@ -12,5 +17,5 @@ git fsck 2> /dev/null \
--date-order \
--no-walk \
--stdin \
- ${git_log_format_oneline}
+ --pretty=format:${_git_log_oneline_format}
diff --git a/modules/git/functions/git-dir b/modules/git/functions/git-dir
index a52e6c2eef..2e40e9eace 100644
--- a/modules/git/functions/git-dir
+++ b/modules/git/functions/git-dir
@@ -1,5 +1,5 @@
#
-# Gets the path to the Git directory.
+# Displays the path to the Git directory.
#
# Authors:
# Sorin Ionescu
@@ -10,7 +10,8 @@ local git_dir="${$(git rev-parse --git-dir):A}"
if [[ -n "$git_dir" ]]; then
print "$git_dir"
return 0
+else
+ print "$0: not a repository: $PWD" >&2
+ return 1
fi
-return 1
-
diff --git a/modules/git/functions/git-hub b/modules/git/functions/git-hub
deleted file mode 100644
index 8d2e494769..0000000000
--- a/modules/git/functions/git-hub
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# Opens a GitHub repository in the default browser.
-#
-# Authors:
-# Sorin Ionescu
-#
-
-local remote branches branch current_branch file url
-
-remote="${1:-origin}"
-url=$(
- git config -l \
- | grep "remote.${remote}.url" \
- | sed -En "s/remote.${remote}.url=(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p"
-)
-branches=($(
- git branch -r | sed -e "/${remote}\/HEAD -> ${remote}/d" -e "s/^[[:space:]]*${remote}\///g"
-))
-current_branch="$(git-branch-current)"
-branch="${2:-master}"
-file="$3"
-
-if [[ -z "$2" ]]; then
- if (( $branches[(I)$current_branch] != 0 )); then
- branch="$current_branch"
- else
- branch='master'
- fi
-fi
-
-if [[ -n "$url" ]]; then
- url="${url}/tree/${branch}/${file}"
-
- if (( $+commands[$BROWSER] )); then
- "$BROWSER" "$url"
- return 0
- else
- print "$0: browser not set or set to a non-existent browser" >&2
- return 1
- fi
-else
- print "$0: not a Git repository or remote origin not set" >&2
- return 1
-fi
-
diff --git a/modules/git/functions/git-hub-browse b/modules/git/functions/git-hub-browse
new file mode 100644
index 0000000000..80fddca044
--- /dev/null
+++ b/modules/git/functions/git-hub-browse
@@ -0,0 +1,59 @@
+#
+# Opens a GitHub repository in the default browser.
+#
+# Authors:
+# Sorin Ionescu
+#
+
+if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
+ print "$0: not a repository work tree: $PWD" >&2
+ return 1
+fi
+
+local remotes remote references reference file url
+
+remote="${1:-origin}"
+remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2))
+
+if (( $remotes[(i)$remote] == $#remotes + 1 )); then
+ print "$0: remote not found: $remote" >&2
+ return 1
+fi
+
+url=$(
+ 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)/}
+)
+
+if (( $references[(i)$reference] == $#references + 1 )); then
+ print "$0: branch or tag not found: $reference" >&2
+ return 1
+fi
+
+if [[ "$reference" == 'HEAD' ]]; then
+ reference="$(git rev-parse HEAD 2>/dev/null)"
+fi
+
+file="$3"
+
+if [[ -n "$url" ]]; then
+ url="${url}/tree/${reference}/${file}"
+
+ if (( $+commands[$BROWSER] )); then
+ "$BROWSER" "$url"
+ return 0
+ else
+ print "$0: browser not set or set to a non-existent browser" >&2
+ return 1
+ fi
+else
+ print "$0: not a Git repository or remote not set" >&2
+ return 1
+fi
+
diff --git a/modules/git/functions/git-hub-short-url b/modules/git/functions/git-hub-shorten-url
similarity index 100%
rename from modules/git/functions/git-hub-short-url
rename to modules/git/functions/git-hub-shorten-url
diff --git a/modules/git/functions/git-info b/modules/git/functions/git-info
index 07ebf80325..2e52eab393 100644
--- a/modules/git/functions/git-info
+++ b/modules/git/functions/git-info
@@ -4,74 +4,20 @@
# Authors:
# Sorin Ionescu
#
-# Usage:
-# Define the following styles in a prompt theme setup function.
-#
-# # %s - Special action name (am, merge, rebase).
-# zstyle ':prezto:module:git' action 'action:%s'
-#
-# # %a - Indicator to notify of added files.
-# zstyle ':prezto:module:git' added 'added:%a'
-#
-# # %A - Indicator to notify of ahead branch.
-# zstyle ':prezto:module:git' ahead 'ahead:%A'
-#
-# # %B - Indicator to notify of behind branch.
-# zstyle ':prezto:module:git' behind 'behind:%B'
-#
-# # %b - Branch name.
-# zstyle ':prezto:module:git' branch 'branch:%b'
-#
-# # %C - Indicator to notify of a clean working directory.
-# zstyle ':prezto:module:git' clean 'clean'
-#
-# # %c - SHA-1 hash.
-# zstyle ':prezto:module:git' commit 'commit:%c'
-#
-# # %d - Indicator to notify of deleted files.
-# zstyle ':prezto:module:git' deleted 'deleted:%d'
-#
-# # %D - Indicator to notify of dirty files.
-# zstyle ':prezto:module:git' dirty 'dirty:%D'
-#
-# # %m - Indicator to notify of modified files.
-# zstyle ':prezto:module:git' modified 'modified:%m'
-#
-# # %p - HEAD position in relation to the nearest branch, remote, tag.
-# zstyle ':prezto:module:git' position 'position:%p'
-#
-# # %R - Remote name.
-# zstyle ':prezto:moduleit' remote 'remote:%R'
-#
-# # %r - Indicator to notify of renamed files.
-# zstyle ':prezto:module:git' renamed 'renamed:%r'
-#
-# # %S - Indicator to notify of stashed files.
-# zstyle ':prezto:module:git' stashed 'stashed:%S'
-#
-# # %U - Indicator to notify of unmerged files.
-# zstyle ':prezto:module:git' unmerged 'unmerged:%U'
-#
-# # %u - Indicator to notify of untracked files.
-# zstyle ':prezto:module:git' untracked 'untracked:%u'
-#
-# # Ignore submodule when it is 'dirty', 'untracked', 'all', or 'none'.
-# zstyle ':prezto:module:git:ignore' submodule ''
-#
-# # Prompts.
-# zstyle ':prezto:module:git' info \
-# 'prompt' ' git:(%b%C%D)' \
-# 'rprompt' ''
-#
-
-# Load dependencies.
-pmodload 'helper'
# Gets the Git special action (am, bisect, cherry, merge, rebase).
# Borrowed from vcs_info and edited.
function _git-action {
local action_dir
local git_dir="$(git-dir)"
+ local apply_formatted
+ local bisect_formatted
+ local cherry_pick_formatted
+ local cherry_pick_sequence_formatted
+ local merge_formatted
+ local rebase_formatted
+ local rebase_interactive_formatted
+ local rebase_merge_formatted
for action_dir in \
"${git_dir}/rebase-apply" \
@@ -79,12 +25,15 @@ function _git-action {
"${git_dir}/../.dotest"
do
if [[ -d "$action_dir" ]] ; then
+ zstyle -s ':prezto:module:git:info:action:apply' format 'apply_formatted' || apply_formatted='apply'
+ zstyle -s ':prezto:module:git:info:action:rebase' format 'rebase_formatted' || rebase_formatted='rebase'
+
if [[ -f "${action_dir}/rebasing" ]] ; then
- print 'rebase'
+ print "$rebase_formatted"
elif [[ -f "${action_dir}/applying" ]] ; then
- print 'am'
+ print "$apply_formatted"
else
- print 'am/rebase'
+ print "${rebase_formatted}/${apply_formatted}"
fi
return 0
@@ -96,7 +45,8 @@ function _git-action {
"${git_dir}/.dotest-merge/interactive"
do
if [[ -f "$action_dir" ]]; then
- print 'rebase-i'
+ zstyle -s ':prezto:module:git:info:action:rebase-interactive' format 'rebase_interactive_formatted' || rebase_interactive_formatted='rebase-interactive'
+ print "$rebase_interactive_formatted"
return 0
fi
done
@@ -106,28 +56,33 @@ function _git-action {
"${git_dir}/.dotest-merge"
do
if [[ -d "$action_dir" ]]; then
- print 'rebase-m'
+ zstyle -s ':prezto:module:git:info:action:rebase-merge' format 'rebase_merge_formatted' || rebase_merge_formatted='rebase-merge'
+ print "$rebase_merge_formatted"
return 0
fi
done
if [[ -f "${git_dir}/MERGE_HEAD" ]]; then
- print 'merge'
+ zstyle -s ':prezto:module:git:info:action:merge' format 'merge_formatted' || merge_formatted='merge'
+ print "$merge_formatted"
return 0
fi
if [[ -f "${git_dir}/CHERRY_PICK_HEAD" ]]; then
if [[ -d "${git_dir}/sequencer" ]] ; then
- print 'cherry-seq'
+ zstyle -s ':prezto:module:git:info:action:cherry-pick-sequence' format 'cherry_pick_sequence_formatted' || cherry_pick_sequence_formatted='cherry-pick-sequence'
+ print "$cherry_pick_sequence_formatted"
else
- print 'cherry'
+ zstyle -s ':prezto:module:git:info:action:cherry-pick' format 'cherry_pick_formatted' || cherry_pick_formatted='cherry-pick'
+ print "$cherry_pick_formatted"
fi
return 0
fi
if [[ -f "${git_dir}/BISECT_LOG" ]]; then
- print 'bisect'
+ zstyle -s ':prezto:module:git:info:action:bisect' format 'bisect_formatted' || bisect_formatted='bisect'
+ print "$bisect_formatted"
return 0
fi
@@ -195,7 +150,7 @@ function git-info {
local dirty=0
local dirty_format
local dirty_formatted
- local ignore_submodule
+ local ignore_submodules
local -A info_formats
local info_format
local line_number=0
@@ -261,29 +216,29 @@ function git-info {
ahead_and_behind_cmd='git rev-list --count --left-right HEAD...@{upstream}'
# Ignore submodule status.
- zstyle -s ':prezto:module:git:ignore' submodule 'ignore_submodule'
- if [[ -n "$ignore_submodule" ]]; then
- status_cmd+=" --ignore-submodules=${ignore_submodule}"
+ zstyle -s ':prezto:module:git:status:ignore' submodules 'ignore_submodules'
+ if [[ -n "$ignore_submodules" ]]; then
+ status_cmd+=" --ignore-submodules=${ignore_submodules}"
fi
# Format commit.
commit="$(git rev-parse HEAD 2> /dev/null)"
if [[ -n "$commit" ]]; then
- zstyle -s ':prezto:module:git' commit 'commit_format'
+ zstyle -s ':prezto:module:git:info:commit' format 'commit_format'
zformat -f commit_formatted "$commit_format" "c:$commit"
fi
# Format stashed.
if [[ -f "$(git-dir)/refs/stash" ]]; then
stashed="$(git stash list 2> /dev/null | wc -l | awk '{print $1}')"
- zstyle -s ':prezto:module:git' stashed 'stashed_format'
+ zstyle -s ':prezto:module:git:info:stashed' format 'stashed_format'
zformat -f stashed_formatted "$stashed_format" "S:$stashed"
fi
# Format action.
action="$(_git-action)"
if [[ -n "$action" ]]; then
- zstyle -s ':prezto:module:git' action 'action_format'
+ zstyle -s ':prezto:module:git:info:action' format 'action_format'
zformat -f action_formatted "$action_format" "s:$action"
fi
@@ -304,13 +259,13 @@ function git-info {
# Format branch.
branch="${$(git symbolic-ref -q HEAD)##refs/heads/}"
if [[ -n "$branch" ]]; then
- zstyle -s ':prezto:module:git' branch 'branch_format'
+ zstyle -s ':prezto:module:git:info:branch' format 'branch_format'
zformat -f branch_formatted "$branch_format" "b:$branch"
# Format remote.
remote="${$(${(z)remote_cmd} 2> /dev/null)##refs/remotes/}"
if [[ -n "$remote" ]]; then
- zstyle -s ':prezto:module:git' remote 'remote_format'
+ zstyle -s ':prezto:module:git:info:remote' format 'remote_format'
zformat -f remote_formatted "$remote_format" "R:$remote"
# Get ahead and behind counts.
@@ -319,14 +274,14 @@ function git-info {
# Format ahead.
ahead="$ahead_and_behind[(w)1]"
if (( $ahead > 0 )); then
- zstyle -s ':prezto:module:git' ahead 'ahead_format'
+ zstyle -s ':prezto:module:git:info:ahead' format 'ahead_format'
zformat -f ahead_formatted "$ahead_format" "A:$ahead"
fi
# Format behind.
behind="$ahead_and_behind[(w)2]"
if (( $behind > 0 )); then
- zstyle -s ':prezto:module:git' behind 'behind_format'
+ zstyle -s ':prezto:module:git:info:behind' format 'behind_format'
zformat -f behind_formatted "$behind_format" "B:$behind"
fi
fi
@@ -334,57 +289,57 @@ function git-info {
# Format position.
position="$(git describe --contains --all HEAD 2> /dev/null)"
if [[ -n "$position" ]]; then
- zstyle -s ':prezto:module:git' position 'position_format'
+ zstyle -s ':prezto:module:git:info:position' format 'position_format'
zformat -f position_formatted "$position_format" "p:$position"
fi
fi
# Format added.
if (( $added > 0 )); then
- zstyle -s ':prezto:module:git' added 'added_format'
+ zstyle -s ':prezto:module:git:info:added' format 'added_format'
zformat -f added_formatted "$added_format" "a:$added_format"
fi
# Format deleted.
if (( $deleted > 0 )); then
- zstyle -s ':prezto:module:git' deleted 'deleted_format'
+ zstyle -s ':prezto:module:git:info:deleted' format 'deleted_format'
zformat -f deleted_formatted "$deleted_format" "d:$deleted_format"
fi
# Format modified.
if (( $modified > 0 )); then
- zstyle -s ':prezto:module:git' modified 'modified_format'
+ zstyle -s ':prezto:module:git:info:modified' format 'modified_format'
zformat -f modified_formatted "$modified_format" "m:$modified"
fi
# Format renamed.
if (( $renamed > 0 )); then
- zstyle -s ':prezto:module:git' renamed 'renamed_format'
+ zstyle -s ':prezto:module:git:info:renamed' format 'renamed_format'
zformat -f renamed_formatted "$renamed_format" "r:$renamed"
fi
# Format unmerged.
if (( $unmerged > 0 )); then
- zstyle -s ':prezto:module:git' unmerged 'unmerged_format'
+ zstyle -s ':prezto:module:git:info:unmerged' format 'unmerged_format'
zformat -f unmerged_formatted "$unmerged_format" "U:$unmerged"
fi
# Format untracked.
if (( $untracked > 0 )); then
- zstyle -s ':prezto:module:git' untracked 'untracked_format'
+ zstyle -s ':prezto:module:git:info:untracked' format 'untracked_format'
zformat -f untracked_formatted "$untracked_format" "u:$untracked"
fi
# Format dirty and clean.
if (( $dirty > 0 )); then
- zstyle -s ':prezto:module:git' dirty 'dirty_format'
+ zstyle -s ':prezto:module:git:info:dirty' format 'dirty_format'
zformat -f dirty_formatted "$dirty_format" "D:$dirty"
else
- zstyle -s ':prezto:module:git' clean 'clean_formatted'
+ zstyle -s ':prezto:module:git:info:clean' format 'clean_formatted'
fi
# Format info.
- zstyle -a ':prezto:module:git' info 'info_formats'
+ zstyle -a ':prezto:module:git:info:keys' format 'info_formats'
for info_format in ${(k)info_formats}; do
zformat -f REPLY "$info_formats[$info_format]" \
"A:$ahead_formatted" \
diff --git a/modules/git/functions/git-root b/modules/git/functions/git-root
index c5aa48f0d2..82b74385e0 100644
--- a/modules/git/functions/git-root
+++ b/modules/git/functions/git-root
@@ -1,5 +1,5 @@
#
-# Displays the Git repository root.
+# Displays the path to the working tree root.
#
# Authors:
# Sorin Ionescu
@@ -11,6 +11,7 @@ if [[ -n "$root" ]]; then
print "$root"
return 0
else
+ print "$0: not a repository work tree: $PWD" >&2
return 1
fi
diff --git a/modules/git/functions/git-stash-clear-interactive b/modules/git/functions/git-stash-clear-interactive
index 82d055cafc..effd038f7f 100644
--- a/modules/git/functions/git-stash-clear-interactive
+++ b/modules/git/functions/git-stash-clear-interactive
@@ -5,6 +5,11 @@
# Sorin Ionescu
#
+if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
+ print "$0: not a repository work tree: $PWD" >&2
+ return 1
+fi
+
local stashed
if [[ -f "$(git-dir)/refs/stash" ]]; then
diff --git a/modules/git/functions/git-stash-dropped b/modules/git/functions/git-stash-dropped
index bdba23862f..26229263b4 100644
--- a/modules/git/functions/git-stash-dropped
+++ b/modules/git/functions/git-stash-dropped
@@ -5,11 +5,16 @@
# Sorin Ionescu
#
-git fsck --unreachable 2> /dev/null
+if ! is-true "$(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 \
| grep 'commit' \
| awk '{print $3}' \
| git log \
- ${git_log_format_oneline}
+ --pretty=format:${_git_log_oneline_format} \
--extended-regexp \
--grep="${1:-(WIP )?[Oo]n [^:]+:}" \
--merges \
diff --git a/modules/git/functions/git-stash-recover b/modules/git/functions/git-stash-recover
index dd50a1bcc7..0709440638 100644
--- a/modules/git/functions/git-stash-recover
+++ b/modules/git/functions/git-stash-recover
@@ -5,6 +5,11 @@
# Sorin Ionescu
#
+if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
+ print "$0: not a repository work tree: $PWD" >&2
+ return 1
+fi
+
local commit
for commit in "$@"; do
diff --git a/modules/git/functions/git-submodule-move b/modules/git/functions/git-submodule-move
new file mode 100644
index 0000000000..c3db972d02
--- /dev/null
+++ b/modules/git/functions/git-submodule-move
@@ -0,0 +1,33 @@
+#
+# Moves a Git submodule.
+#
+# Authors:
+# Sorin Ionescu
+#
+
+if ! is-true "$(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
+fi
+
+local src="$1"
+local dst="$2"
+local url
+
+url="$(git config --file "$(git-root)/.gitmodules" --get "submodule.${src}.url")"
+
+if [[ -z "$url" ]]; then
+ print "$0: submodule not found: $src" >&2
+ return 1
+fi
+
+mkdir -p "${dst:h}"
+
+git-submodule-remove "$src"
+git submodule add "$url" "$dst"
+
+return 0
+
diff --git a/modules/git/functions/git-submodule-remove b/modules/git/functions/git-submodule-remove
new file mode 100644
index 0000000000..3f72fb6d87
--- /dev/null
+++ b/modules/git/functions/git-submodule-remove
@@ -0,0 +1,28 @@
+#
+# Removes a Git submodule.
+#
+# Authors:
+# Sorin Ionescu
+#
+
+if ! is-true "$(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
+ 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
+
+git rm --cached -rf "${1}"
+rm -rf "${1}"
+rm -rf "$(git-dir)/modules/${1}"
+
+return 0
+
diff --git a/modules/git/init.zsh b/modules/git/init.zsh
index 81a7b737df..3a618f23fa 100644
--- a/modules/git/init.zsh
+++ b/modules/git/init.zsh
@@ -10,6 +10,9 @@ if (( ! $+commands[git] )); then
return 1
fi
+# Load dependencies.
+pmodload 'helper'
+
# Source module files.
source "${0:h}/alias.zsh"
diff --git a/modules/gpg-agent/README.md b/modules/gpg-agent/README.md
index e1fc158d44..1b222d46a8 100644
--- a/modules/gpg-agent/README.md
+++ b/modules/gpg-agent/README.md
@@ -3,6 +3,15 @@ GPG-Agent
Provides for an easier use of [gpg-agent][1].
+Settings
+--------
+
+### SSH-Agent Protocol Emulation
+
+To enable SSH-Agent protocol emulation, add the following line to *zpreztorc*:
+
+ zstyle ':prezto:module:gpg-agent' ssh-support 'yes'
+
Authors
-------
diff --git a/modules/gpg-agent/init.zsh b/modules/gpg-agent/init.zsh
index 902466da91..6d010d2813 100644
--- a/modules/gpg-agent/init.zsh
+++ b/modules/gpg-agent/init.zsh
@@ -14,7 +14,15 @@ fi
_gpg_env="$HOME/.gnupg/gpg-agent.env"
function _gpg-agent-start {
- gpg-agent --daemon --enable-ssh-support --write-env-file "${_gpg_env}" > /dev/null
+ local ssh_support
+
+ zstyle -b ':prezto:module:gpg-agent' ssh-support 'ssh_support' \
+ || ssh_support=''
+
+ gpg-agent \
+ --daemon ${ssh_support:+'--enable-ssh-support'}
+ --write-env-file "${_gpg_env}" > /dev/null
+
chmod 600 "${_gpg_env}"
source "${_gpg_env}" > /dev/null
}
diff --git a/modules/history-substring-search/init.zsh b/modules/history-substring-search/init.zsh
index 842ee1c545..ea20fffd26 100644
--- a/modules/history-substring-search/init.zsh
+++ b/modules/history-substring-search/init.zsh
@@ -28,17 +28,19 @@ fi
# Key Bindings
#
-# Emacs
-bindkey -M emacs "$key_info[Control]P" history-substring-search-up
-bindkey -M emacs "$key_info[Control]N" history-substring-search-down
-
-# Vi
-bindkey -M vicmd "k" history-substring-search-up
-bindkey -M vicmd "j" history-substring-search-down
-
-# Emacs and Vi
-for keymap in 'emacs' 'viins'; do
- bindkey -M "$keymap" "$key_info[Up]" history-substring-search-up
- bindkey -M "$keymap" "$key_info[Down]" history-substring-search-down
-done
+if [[ -n $key_info ]]; then
+ # Emacs
+ bindkey -M emacs "$key_info[Control]P" history-substring-search-up
+ bindkey -M emacs "$key_info[Control]N" history-substring-search-down
+
+ # Vi
+ bindkey -M vicmd "k" history-substring-search-up
+ bindkey -M vicmd "j" history-substring-search-down
+
+ # Emacs and Vi
+ for keymap in 'emacs' 'viins'; do
+ bindkey -M "$keymap" "$key_info[Up]" history-substring-search-up
+ bindkey -M "$keymap" "$key_info[Down]" history-substring-search-down
+ done
+fi
diff --git a/modules/prompt/functions/prompt_peepcode_setup b/modules/prompt/functions/prompt_peepcode_setup
index 0dd7e747ac..58f4f8b4dc 100644
--- a/modules/prompt/functions/prompt_peepcode_setup
+++ b/modules/prompt/functions/prompt_peepcode_setup
@@ -13,7 +13,7 @@
function +vi-git-status() {
# Check for untracked files or updated submodules since vcs_info does not.
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
- hook_com[unstaged]='%F{8}✗%f'
+ hook_com[unstaged]=' %F{8}✗%f'
fi
}
@@ -48,7 +48,7 @@ function prompt_peepcode_setup {
zstyle ':vcs_info:git*+set-message:*' hooks git-status
# Set ruby-info parameters.
- zstyle ':prezto:module:ruby' version ' %F{white}%v%f'
+ zstyle ':prezto:module:ruby:info:version' format ' %F{white}%v%f'
# Define prompts.
PROMPT="
diff --git a/modules/prompt/functions/prompt_sorin_setup b/modules/prompt/functions/prompt_sorin_setup
index dedd704f5b..3c2c55f5b3 100644
--- a/modules/prompt/functions/prompt_sorin_setup
+++ b/modules/prompt/functions/prompt_sorin_setup
@@ -5,16 +5,31 @@
# Sorin Ionescu
#
# Screenshots:
-# http://i.imgur.com/ij8Lv.png
+# http://i.imgur.com/nBEEZ.png
#
# Load dependencies.
pmodload 'helper'
+function prompt_sorin_pwd {
+ local pwd="${PWD/#$HOME/~}"
+
+ if [[ "$pwd" == (#m)[/~] ]]; then
+ _prompt_sorin_pwd="$MATCH"
+ unset MATCH
+ else
+ _prompt_sorin_pwd="${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}/${pwd:t}"
+ fi
+}
+
function prompt_sorin_precmd {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
+ # Format PWD.
+ prompt_sorin_pwd
+
+ # Get Git repository information.
if (( $+functions[git-info] )); then
git-info
fi
@@ -31,29 +46,29 @@ function prompt_sorin_setup {
# Add hook for calling git-info before each command.
add-zsh-hook precmd prompt_sorin_precmd
- zstyle ':prezto:module:editor' completing '%B%F{red}...%f%b'
- zstyle ':prezto:module:editor:keymap:primary' overwrite ' %F{red}♺%f'
- zstyle ':prezto:module:editor:keymap' primary ' %B%F{red}❯%F{yellow}❯%F{green}❯%f%b'
- zstyle ':prezto:module:editor:keymap' alternate ' %B%F{green}❮%F{yellow}❮%F{red}❮%f%b'
- zstyle ':prezto:module:git' action ':%%B%F{yellow}%s%f%%b'
- zstyle ':prezto:module:git' added ' %%B%F{green}✚%f%%b'
- zstyle ':prezto:module:git' ahead ' %%B%F{yellow}⬆%f%%b'
- zstyle ':prezto:module:git' behind ' %%B%F{yellow}⬇%f%%b'
- zstyle ':prezto:module:git' branch ':%F{green}%b%f'
- zstyle ':prezto:module:git' commit ':%F{green}%.7c%f'
- zstyle ':prezto:module:git' deleted ' %%B%F{red}✖%f%%b'
- zstyle ':prezto:module:git' modified ' %%B%F{blue}✱%f%%b'
- zstyle ':prezto:module:git' position ':%F{green}%p%f'
- zstyle ':prezto:module:git' renamed ' %%B%F{magenta}➜%f%%b'
- zstyle ':prezto:module:git' stashed ' %%B%F{cyan}✭%f%%b'
- zstyle ':prezto:module:git' unmerged ' %%B%F{yellow}═%f%%b'
- zstyle ':prezto:module:git' untracked ' %%B%F{white}◼%f%%b'
- zstyle ':prezto:module:git' info \
- 'prompt' ' %F{blue}git%f$(coalesce "%b" "%p" "%c")%s' \
+ zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b'
+ zstyle ':prezto:module:editor:info:keymap:primary' format ' %B%F{red}❯%F{yellow}❯%F{green}❯%f%b'
+ zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format ' %F{red}♺%f'
+ zstyle ':prezto:module:editor:info:keymap:alternate' format ' %B%F{green}❮%F{yellow}❮%F{red}❮%f%b'
+ zstyle ':prezto:module:git:info:action' format ':%%B%F{yellow}%s%f%%b'
+ zstyle ':prezto:module:git:info:added' format ' %%B%F{green}✚%f%%b'
+ zstyle ':prezto:module:git:info:ahead' format ' %%B%F{yellow}⬆%f%%b'
+ zstyle ':prezto:module:git:info:behind' format ' %%B%F{yellow}⬇%f%%b'
+ zstyle ':prezto:module:git:info:branch' format ':%F{green}%b%f'
+ zstyle ':prezto:module:git:info:commit' format ':%F{green}%.7c%f'
+ zstyle ':prezto:module:git:info:deleted' format ' %%B%F{red}✖%f%%b'
+ zstyle ':prezto:module:git:info:modified' format ' %%B%F{blue}✱%f%%b'
+ zstyle ':prezto:module:git:info:position' format ':%F{green}%p%f'
+ zstyle ':prezto:module:git:info:renamed' format ' %%B%F{magenta}➜%f%%b'
+ zstyle ':prezto:module:git:info:stashed' format ' %%B%F{cyan}✭%f%%b'
+ zstyle ':prezto:module:git:info:unmerged' format ' %%B%F{yellow}═%f%%b'
+ zstyle ':prezto:module:git:info:untracked' format ' %%B%F{white}◼%f%%b'
+ zstyle ':prezto:module:git:info:keys' format \
+ 'prompt' ' %F{blue}git%f$(coalesce "%b" "%p" "%c")%s' \
'rprompt' '%A%B%S%a%d%m%r%U%u'
# Define prompts.
- PROMPT='%F{cyan}%1~%f${git_info:+${(e)git_info[prompt]}}%(!. %B%F{red}#%f%b.)${editor_info[keymap]} '
+ PROMPT='%F{cyan}${_prompt_sorin_pwd}%f${git_info:+${(e)git_info[prompt]}}%(!. %B%F{red}#%f%b.)${editor_info[keymap]} '
RPROMPT='${editor_info[overwrite]}%(?:: %F{red}⏎%f)${VIM:+" %B%F{green}V%f%b"}${git_info[rprompt]}'
SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
}
diff --git a/modules/prompt/functions/prompt_steeef_setup b/modules/prompt/functions/prompt_steeef_setup
index 9b07326495..f64f47d276 100644
--- a/modules/prompt/functions/prompt_steeef_setup
+++ b/modules/prompt/functions/prompt_steeef_setup
@@ -82,7 +82,7 @@ function prompt_steeef_setup {
zstyle ':vcs_info:*:prompt:*' nvcsformats ""
# Set python-info parameters.
- zstyle ':prezto:module:python' virtualenv '(%v)'
+ zstyle ':prezto:module:python:info:virtualenv' format '(%v)'
# Define prompts.
PROMPT="
diff --git a/modules/python/README.md b/modules/python/README.md
index dd6b19a049..c48f4ea3e6 100644
--- a/modules/python/README.md
+++ b/modules/python/README.md
@@ -86,13 +86,13 @@ Theming
-------
To display the name of the current virtual enviroment in a prompt, define the
-following style in the `prompt_theme_setup` function.
+following style in the `prompt_name_setup` function.
# %v - virtualenv name.
- zstyle ':prezto:module:python' virtualenv 'virtualenv:%v'
+ zstyle ':prezto:module:python:info:virtualenv' format 'virtualenv:%v'
Then add `$python_info[virtualenv]` to `$PROMPT` or `$RPROMPT` and call
-`python-info` in the `prompt_theme_preexec` hook function.
+`python-info` in the `prompt_name_preexec` hook function.
Authors
-------
diff --git a/modules/python/functions/python-info b/modules/python/functions/python-info
index 40c5011a42..634d01d0e1 100644
--- a/modules/python/functions/python-info
+++ b/modules/python/functions/python-info
@@ -15,7 +15,7 @@ typeset -gA python_info
# Format virtualenv.
if [[ -n "$VIRTUAL_ENV" ]]; then
- zstyle -s ':prezto:module:python' virtualenv 'virtualenv_format'
+ zstyle -s ':prezto:module:python:info:virtualenv' format 'virtualenv_format'
zformat -f virtualenv_formatted "$virtualenv_format" "v:${VIRTUAL_ENV:t}"
python_info[virtualenv]="$virtualenv_formatted"
fi
diff --git a/modules/python/init.zsh b/modules/python/init.zsh
index 927dc9d952..11875612b7 100644
--- a/modules/python/init.zsh
+++ b/modules/python/init.zsh
@@ -6,8 +6,13 @@
# Sebastian Wiesner
#
+# Load pythonz into the shell session.
+if [[ -s $HOME/.pythonz/bin/pythonz ]]; then
+ path=($HOME/.pythonz/bin $path)
+fi
+
# Return if requirements are not found.
-if (( ! $+commands[python] )); then
+if (( ! $+commands[python] && ! $+commands[pythonz] )); then
return 1
fi
@@ -33,11 +38,6 @@ if (( $+commands[virtualenvwrapper_lazy.sh] )); then
source "$commands[virtualenvwrapper_lazy.sh]"
fi
-# Load pythonz into the shell session.
-if [[ -s $HOME/.pythonz/bin/pythonz ]]; then
- path=($HOME/.pythonz/bin $path)
-fi
-
#
# Aliases
#
diff --git a/modules/ruby/README.md b/modules/ruby/README.md
index a95bc36659..42e63be6d1 100644
--- a/modules/ruby/README.md
+++ b/modules/ruby/README.md
@@ -66,13 +66,13 @@ Theming
-------
To display the name of the current Ruby version in a prompt, define the
-following style in the `prompt_theme_setup` function.
+following style in the `prompt_name_setup` function.
# %v - ruby version.
- zstyle ':prezto:module:ruby' version 'version:%v'
+ zstyle ':prezto:module:ruby:info:version' format 'version:%v'
Then add `$ruby_info[version]` to `$PROMPT` or `$RPROMPT` and call
-`ruby-info` in the `prompt_theme_preexec` hook function.
+`ruby-info` in the `prompt_name_preexec` hook function.
Authors
-------
diff --git a/modules/ruby/functions/ruby-info b/modules/ruby/functions/ruby-info
index f2ce2ed61c..7bc8ead64c 100644
--- a/modules/ruby/functions/ruby-info
+++ b/modules/ruby/functions/ruby-info
@@ -22,7 +22,7 @@ fi
# Format version.
if [[ -n "$version" ]]; then
- zstyle -s ':prezto:module:ruby' version 'version_format'
+ zstyle -s ':prezto:module:ruby:info:version' format 'version_format'
zformat -f version_formatted "$version_format" "v:$version"
ruby_info[version]="$version_formatted"
fi
diff --git a/modules/ruby/init.zsh b/modules/ruby/init.zsh
index 7b19d7deec..b5ab77d0dd 100644
--- a/modules/ruby/init.zsh
+++ b/modules/ruby/init.zsh
@@ -5,11 +5,6 @@
# Authors: Sorin Ionescu
#
-# Return if requirements are not found.
-if (( ! $+commands[ruby] )); then
- return 1
-fi
-
# Load RVM into the shell session.
if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then
# Unset AUTO_NAME_DIRS since auto adding variable-stored paths to ~ list
@@ -36,6 +31,11 @@ else
fi
fi
+# Return if requirements are not found.
+if (( ! $+commands[ruby] && ! ( $+commands[rvm] || $+commands[rbenv] ) )); then
+ return 1
+fi
+
#
# Aliases
#
diff --git a/modules/ssh-agent/README.md b/modules/ssh-agent/README.md
index 17c5b734cb..392a8666fb 100644
--- a/modules/ssh-agent/README.md
+++ b/modules/ssh-agent/README.md
@@ -8,7 +8,7 @@ Settings
### Agent Forwarding
-To enable ssh-agent forwarding, add the following line to *zpreztorc*:
+To enable SSH-Agent forwarding, add the following line to *zpreztorc*:
zstyle ':prezto:module:ssh-agent' forwarding 'yes'
diff --git a/modules/ssh-agent/init.zsh b/modules/ssh-agent/init.zsh
index 43ca43909a..56215a4f74 100644
--- a/modules/ssh-agent/init.zsh
+++ b/modules/ssh-agent/init.zsh
@@ -11,14 +11,14 @@
# Sorin Ionescu
#
-# Load dependencies.
-pmodload 'helper'
-
# Return if requirements are not found.
if (( ! $+commands[ssh-agent] )); then
return 1
fi
+# Load dependencies.
+pmodload 'helper'
+
_ssh_agent_env="${HOME}/.ssh/environment-${HOST}"
_ssh_agent_forwarding=
diff --git a/modules/terminal/README.md b/modules/terminal/README.md
index d42645bac6..f1256c69e2 100644
--- a/modules/terminal/README.md
+++ b/modules/terminal/README.md
@@ -13,6 +13,16 @@ directory, add the following to *zpreztorc*:
zstyle ':prezto:module:terminal' auto-title 'yes'
+Functions
+---------
+
+- `set-screen-window-title` sets the screen title.
+- `set-terminal-tab-title` sets the terminal tab title.
+- `set-terminal-window-title` sets the terminal window title.
+- `set-titles-with-command` sets the screen and terminal titles with
+ a given command.
+- `set-titles-with-path` sets the screen and terminal titles with a given path.
+
Authors
-------
diff --git a/modules/terminal/init.zsh b/modules/terminal/init.zsh
index 5c03b28ead..dc78a3bec0 100644
--- a/modules/terminal/init.zsh
+++ b/modules/terminal/init.zsh
@@ -19,30 +19,36 @@ else
fi
# Sets the GNU Screen title.
-function set-screen-title {
+function set-screen-window-title {
if [[ "$TERM" == screen* ]]; then
printf "\ek%s\e\\" ${(V)argv}
fi
}
# Sets the terminal window title.
-function set-window-title {
+function set-terminal-window-title {
if [[ "$TERM" == ((x|a|ml|dt|E)term*|(u|)rxvt*) ]]; then
printf "\e]2;%s\a" ${(V)argv}
fi
}
# Sets the terminal tab title.
-function set-tab-title {
+function set-terminal-tab-title {
if [[ "$TERM" == ((x|a|ml|dt|E)term*|(u|)rxvt*) ]]; then
printf "\e]1;%s\a" ${(V)argv}
fi
}
-# Sets the tab and window titles with the command name.
-function set-title-by-command {
+# Sets the tab and window titles with a given command.
+function set-titles-with-command {
+ # Do not set the window and tab titles in Terminal.app because they are not
+ # reset upon command termination.
+ if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]]; then
+ return 1
+ fi
+
emulate -L zsh
- setopt LOCAL_OPTIONS EXTENDED_GLOB
+ setopt EXTENDED_GLOB
# Get the command name that is under job control.
if [[ "${1[(w)1]}" == (fg|%*)(\;|) ]]; then
@@ -56,20 +62,43 @@ function set-title-by-command {
jobs $job_name 2>/dev/null > >(
read index discarded
# The index is already surrounded by brackets: [1].
- set-title-by-command "${(e):-\$jobtexts_from_parent_shell$index}"
+ set-titles-with-command "${(e):-\$jobtexts_from_parent_shell$index}"
)
else
# Set the command name, or in the case of sudo or ssh, the next command.
- local cmd=${1[(wr)^(*=*|sudo|ssh|-*)]}
+ local cmd=${${1[(wr)^(*=*|sudo|ssh|-*)]}:t}
+ local truncated_cmd="${cmd/(#m)?(#c15,)/${MATCH[1,12]}...}"
+ unset MATCH
- # Right-truncate the command name to 15 characters.
- if (( $#cmd > 15 )); then
- cmd="${cmd[1,15]}..."
+ if [[ "$TERM" == screen* ]]; then
+ set-screen-window-title "$truncated_cmd"
+ else
+ set-terminal-window-title "$cmd"
+ set-terminal-tab-title "$truncated_cmd"
fi
+ fi
+}
+
+# Sets the tab and window titles with a given path.
+function set-titles-with-path {
+ emulate -L zsh
+ setopt EXTENDED_GLOB
+
+ local absolute_path="${${1:a}:-$PWD}"
- for kind in window tab screen; do
- set-${kind}-title "$cmd"
- done
+ if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]]; then
+ printf '\e]7;%s\a' "file://$HOST${absolute_path// /%20}"
+ else
+ local abbreviated_path="${absolute_path/#$HOME/~}"
+ local truncated_path="${abbreviated_path/(#m)?(#c15,)/...${MATCH[-12,-1]}}"
+ unset MATCH
+
+ if [[ "$TERM" == screen* ]]; then
+ set-screen-window-title "$truncated_path"
+ else
+ set-terminal-window-title "$abbreviated_path"
+ set-terminal-tab-title "$truncated_path"
+ fi
fi
}
@@ -77,29 +106,18 @@ function set-title-by-command {
autoload -Uz add-zsh-hook
# Sets the tab and window titles before the prompt is displayed.
-function set-title-precmd {
+function set-titles-precmd {
if zstyle -t ':prezto:module:terminal' auto-title; then
- if [[ "$TERM_PROGRAM" == 'Apple_Terminal' && "$TERM" != screen* ]]; then
- # Set the current working directory in Apple Terminal.
- printf '\e]7;%s\a' "file://$HOST${PWD// /%20}"
- else
- set-window-title "${(%):-%~}"
- for kind in tab screen; do
- # Left-truncate the current working directory to 15 characters.
- set-${kind}-title "${(%):-%15<...<%~%<<}"
- done
- fi
+ set-titles-with-path
fi
}
-add-zsh-hook precmd set-title-precmd
+add-zsh-hook precmd set-titles-precmd
# Sets the tab and window titles before command execution.
-function set-title-preexec {
+function set-titles-preexec {
if zstyle -t ':prezto:module:terminal' auto-title; then
- if [[ "$TERM_PROGRAM" != 'Apple_Terminal' || "$TERM" == screen* ]]; then
- set-title-by-command "$2"
- fi
+ set-titles-with-command "$2"
fi
}
-add-zsh-hook preexec set-title-preexec
+add-zsh-hook preexec set-titles-preexec
diff --git a/modules/utility/functions/_mkdcd b/modules/utility/functions/_mkdcd
index 81912375db..5b20ee2305 100644
--- a/modules/utility/functions/_mkdcd
+++ b/modules/utility/functions/_mkdcd
@@ -8,7 +8,7 @@
# Sorin Ionescu
#
-_wanted directories expl \
- 'parent directory (alternatively specify name of directory)' \
- _path_files -/ || _message 'name of directory'
+local expl
+
+_wanted directories expl 'directory' _path_files -/ || _message 'directory'
diff --git a/modules/z/README.md b/modules/z/README.md
deleted file mode 100644
index e17aa0ecd6..0000000000
--- a/modules/z/README.md
+++ /dev/null
@@ -1,21 +0,0 @@
-Z
-=
-
-Integrates [z][1] into Prezto, which maintains a frequently used directory
-list for fast directory changes.
-
-Aliases
--------
-
- - `j` changes the current working directory to the most *frecent* match.
-
-Authors
--------
-
-*The authors of this module should be contacted via the [issue tracker][2].*
-
- - [Sorin Ionescu](https://github.com/sorin-ionescu)
-
-[1]: https://github.com/rupa/z
-[2]: https://github.com/sorin-ionescu/prezto/issues
-
diff --git a/modules/z/external b/modules/z/external
deleted file mode 160000
index 9bf5feb86a..0000000000
--- a/modules/z/external
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 9bf5feb86ac05ad32cd8fbf46d459eb415eed749
diff --git a/modules/z/init.zsh b/modules/z/init.zsh
deleted file mode 100644
index df1e570960..0000000000
--- a/modules/z/init.zsh
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Maintains a frequently used directory list for fast directory changes.
-#
-# Authors:
-# Sorin Ionescu
-#
-
-# Set the directory changing command.
-_Z_CMD='j'
-
-# Prevent symbolic link resolution.
-_Z_NO_RESOLVE_SYMLINKS=1
-
-# Source module files.
-source "${0:h}/external/z.sh"
-
-# Cleanup.
-unset _Z_{CMD,NO_RESOLVE_SYMLINKS}
-
diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc
index 4240d51f36..1e8637c342 100644
--- a/runcoms/zpreztorc
+++ b/runcoms/zpreztorc
@@ -54,7 +54,7 @@ zstyle ':prezto:module:editor' dot-expansion 'yes'
#
# Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'.
-# zstyle ':prezto:module:git:ignore' submodule 'all'
+# zstyle ':prezto:module:git:status:ignore' submodules 'all'
#
# GNU Utility
@@ -86,6 +86,13 @@ zstyle ':prezto:module:prompt' theme 'steeef'
# Auto start a session when Zsh is launched.
# zstyle ':prezto:module:screen' auto-start 'yes'
+#
+# GPG-Agent
+#
+
+# Enable SSH-Agent protocol emulation.
+# zstyle ':prezto:module:gpg-agent' ssh-support 'yes'
+
#
# SSH-Agent
#