feat(revamp): add zsh and neovim configs, add an install script and a dependencies list
This commit is contained in:
@@ -0,0 +1,473 @@
|
||||
# Git
|
||||
|
||||
Enhances the [Git][1] distributed version control system by providing aliases,
|
||||
functions and by exposing repository status information to prompts.
|
||||
|
||||
This module must be loaded _before_ the [_`completion`_][13] module so that the
|
||||
provided completion definitions are loaded automatically by _`completion`_
|
||||
module.
|
||||
|
||||
**Note:** Git **2.11** is the minimum required version for better
|
||||
[git-rev-list][7] and [git-submodule][14] support.
|
||||
|
||||
## Settings
|
||||
|
||||
### Log
|
||||
|
||||
To configure the format of the [git-log][8] output, add the following to
|
||||
_`${ZDOTDIR:-$HOME}/.zpreztorc`_, and replace `'<context>'` with `'brief'`,
|
||||
`'oneline'`, and `'medium'`. This will be passed to the `--pretty=format:`
|
||||
switch.
|
||||
|
||||
```sh
|
||||
zstyle ':prezto:module:git:log:context' format '<context>'
|
||||
```
|
||||
|
||||
### Status
|
||||
|
||||
Retrieving the status of a repository with [git-submodule][9] can take a long
|
||||
time. To configure the submodules to ignore, add the following to
|
||||
_`${ZDOTDIR:-$HOME}/.zpreztorc`_, and replace `'<state>'` with `'dirty'`,
|
||||
`'untracked'`, `'all'`, or `'none'`.
|
||||
|
||||
```sh
|
||||
zstyle ':prezto:module:git:status:ignore' submodules '<state>'
|
||||
```
|
||||
|
||||
This setting affects all aliases and functions that call `git-status`.
|
||||
|
||||
## Aliases
|
||||
|
||||
Aliases are enabled by default. To disable them, add the following to
|
||||
_`${ZDOTDIR:-$HOME}/.zpreztorc`_.
|
||||
|
||||
```sh
|
||||
zstyle ':prezto:module:git:alias' skip 'yes'
|
||||
```
|
||||
|
||||
### Git
|
||||
|
||||
- `g` is short for `git`.
|
||||
|
||||
### Branch (b)
|
||||
|
||||
- `gb` lists, creates, renames, and deletes branches.
|
||||
- `gbc` creates a new branch.
|
||||
- `gbl` lists branches and their commits. (also `gbv`)
|
||||
- `gbL` lists all local and remote branches and their commits.
|
||||
- `gbr` renames a branch. (also `gbm`)
|
||||
- `gbR` renames a branch even if the new branch name already exists. (also
|
||||
`gbM`)
|
||||
- `gbs` lists branches and their commits with ancestry graphs.
|
||||
- `gbS` lists local and remote branches and their commits with ancestry graphs.
|
||||
- `gbV` lists branches with more verbose information about their commits.
|
||||
- `gbx` deletes a branch. (also `gbd`)
|
||||
- `gbX` deletes a branch irrespective of its merged status. (also `gbD`)
|
||||
|
||||
### Commit (c)
|
||||
|
||||
- `gc` records changes to the repository.
|
||||
- `gcS` records changes to the repository. (Signed)
|
||||
- `gca` stages all modified and deleted files.
|
||||
- `gcaS` stages all modified and deleted files. (Signed)
|
||||
- `gcm` records changes to the repository with the given message.
|
||||
- `gcmS` records changes to the repository with the given message. (Signed)
|
||||
- `gcam` stages all modified and deleted files, and records changes to the
|
||||
repository with the given message.
|
||||
- `gco` checks out a branch or paths to work tree.
|
||||
- `gcO` checks out hunks from the index or the tree interactively.
|
||||
- `gcf` amends the tip of the current branch using the same log message as
|
||||
_HEAD_.
|
||||
- `gcfS` amends the tip of the current branch using the same log message as
|
||||
_HEAD_. (Signed)
|
||||
- `gcF` amends the tip of the current branch.
|
||||
- `gcFS` amends the tip of the current branch. (Signed)
|
||||
- `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 commits with various objects.
|
||||
- `gcsS` displays commits with GPG signature.
|
||||
- `gcl` lists lost commits.
|
||||
- `gcy` displays commits yet to be applied to upstream in the short format.
|
||||
- `gcY` displays commits yet to be applied to upstream.
|
||||
|
||||
### Conflict (C)
|
||||
|
||||
- `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.
|
||||
|
||||
### Data (d)
|
||||
|
||||
- `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 (f)
|
||||
|
||||
- `gf` downloads objects and references from another repository.
|
||||
- `gfa` downloads objects and references from all remote repositories.
|
||||
- `gfc` clones a repository into a new directory.
|
||||
- `gfcr` clones a repository into a new directory including all submodules.
|
||||
- `gfm` fetches from and merges with another repository or local branch.
|
||||
- `gfr` fetches from and rebases on another repository or local branch.
|
||||
|
||||
### Flow (F)
|
||||
|
||||
- `gFi` is short for `git flow init`
|
||||
|
||||
#### Feature (Ff)
|
||||
|
||||
- `gFf` is short for `git flow feature`
|
||||
- `gFfl` is short for `git flow feature list`
|
||||
- `gFfs` is short for `git flow feature start`
|
||||
- `gFff` is short for `git flow feature finish`
|
||||
- `gFfp` is short for `git flow feature publish`
|
||||
- `gFft` is short for `git flow feature track`
|
||||
- `gFfd` is short for `git flow feature diff`
|
||||
- `gFfr` is short for `git flow feature rebase`
|
||||
- `gFfc` is short for `git flow feature checkout`
|
||||
- `gFfm` is short for `git flow feature pull`
|
||||
- `gFfx` is short for `git flow feature delete`
|
||||
|
||||
#### Bugfix (Fb)
|
||||
|
||||
- `gFb` is short for `git flow bugfix`
|
||||
- `gFbl` is short for `git flow bugfix list`
|
||||
- `gFbs` is short for `git flow bugfix start`
|
||||
- `gFbf` is short for `git flow bugfix finish`
|
||||
- `gFbp` is short for `git flow bugfix publish`
|
||||
- `gFbt` is short for `git flow bugfix track`
|
||||
- `gFbd` is short for `git flow bugfix diff`
|
||||
- `gFbr` is short for `git flow bugfix rebase`
|
||||
- `gFbc` is short for `git flow bugfix checkout`
|
||||
- `gFbm` is short for `git flow bugfix pull`
|
||||
- `gFbx` is short for `git flow bugfix delete`
|
||||
|
||||
#### Release (Fl)
|
||||
|
||||
- `gFl` is short for `git flow release`
|
||||
- `gFll` is short for `git flow release list`
|
||||
- `gFls` is short for `git flow release start`
|
||||
- `gFlf` is short for `git flow release finish`
|
||||
- `gFlp` is short for `git flow release publish`
|
||||
- `gFlt` is short for `git flow release track`
|
||||
- `gFld` is short for `git flow release diff`
|
||||
- `gFlr` is short for `git flow release rebase`
|
||||
- `gFlc` is short for `git flow release checkout`
|
||||
- `gFlm` is short for `git flow release pull`
|
||||
- `gFlx` is short for `git flow release delete`
|
||||
|
||||
#### Hotfix (Fh)
|
||||
|
||||
- `gFh` is short for `git flow hotfix`
|
||||
- `gFhl` is short for `git flow hotfix list`
|
||||
- `gFhs` is short for `git flow hotfix start`
|
||||
- `gFhf` is short for `git flow hotfix finish`
|
||||
- `gFhp` is short for `git flow hotfix publish`
|
||||
- `gFht` is short for `git flow hotfix track`
|
||||
- `gFhd` is short for `git flow hotfix diff`
|
||||
- `gFhr` is short for `git flow hotfix rebase`
|
||||
- `gFhc` is short for `git flow hotfix checkout`
|
||||
- `gFhm` is short for `git flow hotfix pull`
|
||||
- `gFhx` is short for `git flow hotfix delete`
|
||||
|
||||
#### Support (Fs)
|
||||
|
||||
- `gFs` is short for `git flow support`
|
||||
- `gFsl` is short for `git flow support list`
|
||||
- `gFss` is short for `git flow support start`
|
||||
- `gFsf` is short for `git flow support finish`
|
||||
- `gFsp` is short for `git flow support publish`
|
||||
- `gFst` is short for `git flow support track`
|
||||
- `gFsd` is short for `git flow support diff`
|
||||
- `gFsr` is short for `git flow support rebase`
|
||||
- `gFsc` is short for `git flow support checkout`
|
||||
- `gFsm` is short for `git flow support pull`
|
||||
- `gFsx` is short for `git flow support delete`
|
||||
|
||||
### Grep (g)
|
||||
|
||||
- `gg` displays lines matching a pattern.
|
||||
- `ggi` displays lines matching a pattern ignoring case.
|
||||
- `ggl` lists files matching a pattern.
|
||||
- `ggL` lists files that are not matching a pattern.
|
||||
- `ggv` displays lines not matching a pattern.
|
||||
- `ggw` displays lines matching a pattern at word boundary.
|
||||
|
||||
### Index (i)
|
||||
|
||||
- `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).
|
||||
- `gii` temporarily ignore differences in a given file.
|
||||
- `giI` unignore differences in a given file.
|
||||
- `gir` resets the current HEAD to the specified state.
|
||||
- `giR` resets the current index interactively.
|
||||
- `gix` removes files/directories from the index (recursively).
|
||||
- `giX` removes files/directories from the index (recursively and forced).
|
||||
|
||||
### Log (l)
|
||||
|
||||
- `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.
|
||||
- `glS` displays the log and checks the validity of signed commits.
|
||||
|
||||
### Merge (m)
|
||||
|
||||
- `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 (p)
|
||||
|
||||
- `gp` updates remote refs along with associated objects.
|
||||
- `gpf` forcefully updates remote refs along with associated objects using the
|
||||
safer `--force-with-lease` option.
|
||||
- `gpF` forcefully updates remote refs along with associated objects using the
|
||||
riskier `--force` option.
|
||||
- `gpa` updates remote branches along with associated objects.
|
||||
- `gpA` updates remote branches and tags along with associated objects.
|
||||
- `gpt` updates remote tags along with associated objects.
|
||||
- `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 (r)
|
||||
|
||||
- `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 (R)
|
||||
|
||||
- `gR` manages tracked repositories.
|
||||
- `gRl` lists remote names and their URLs.
|
||||
- `gRa` adds a new remote.
|
||||
- `gRx` removes a remote.
|
||||
- `gRm` renames a remote.
|
||||
- `gRu` fetches remotes updates.
|
||||
- `gRp` prunes all stale remote tracking branches.
|
||||
- `gRs` displays information about a given remote.
|
||||
- `gRb` opens a remote on [GitHub][3] in the default browser.
|
||||
|
||||
### Stash (s)
|
||||
|
||||
- `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.
|
||||
- `gsl` lists stashed states.
|
||||
- `gsL` lists dropped stashed states.
|
||||
- `gsd` displays changes between the stash 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 (S)
|
||||
|
||||
- `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.
|
||||
|
||||
### Tag (t)
|
||||
|
||||
- `gt` lists tags or creates tag.
|
||||
- `gtl` lists tags matching pattern.
|
||||
- `gts` creates a signed tag.
|
||||
- `gtv` validate a signed tag.
|
||||
|
||||
### Working directory (w)
|
||||
|
||||
- `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 and directories 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.
|
||||
|
||||
### Working tree (W)
|
||||
|
||||
- `gWa` adds a new working tree.
|
||||
- `gWl` lists all working trees.
|
||||
- `gWx` removes a working tree.
|
||||
- `gWX` removes a working tree forcefully.
|
||||
- `gWm` moves a working tree to a new location.
|
||||
- `gWc` prunes stale worktrees and their administrative data.
|
||||
|
||||
### Shadows
|
||||
|
||||
The following aliases may shadow system commands:
|
||||
|
||||
- `gb` shadows the [GB][10].
|
||||
- `gm` shadows the [GraphicsMagick image processor][11].
|
||||
- `gpt` shadows the [GUID partition table maintenance utility][4].
|
||||
- `gs` shadows the [Ghostscript interpreter and previewer][5].
|
||||
|
||||
If you frequently use the above commands, you may wish to remove said aliases
|
||||
from this module or to disable them at the bottom of the zshrc with `unalias`.
|
||||
|
||||
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][12].
|
||||
- `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.
|
||||
|
||||
```sh
|
||||
zstyle ':prezto:module:git:info:context:subcontext' format 'string'
|
||||
```
|
||||
|
||||
### Main Contexts
|
||||
|
||||
| Name | Format Code | Description |
|
||||
| -------- | :---------: | ---------------------------------- |
|
||||
| action | %s | Special action name |
|
||||
| ahead | %A | Commits ahead of remote count |
|
||||
| behind | %B | Commits behind of remote count |
|
||||
| branch | %b | Branch name |
|
||||
| commit | %c | Commit hash |
|
||||
| position | %p | Commits from the nearest tag count |
|
||||
| remote | %R | Remote name |
|
||||
| stashed | %S | Stashed states count |
|
||||
|
||||
### Concise Contexts
|
||||
|
||||
| Name | Format Code | Description |
|
||||
| --------- | :---------: | --------------------- |
|
||||
| clean | %C | Clean state |
|
||||
| dirty | %D | Dirty files count |
|
||||
| indexed | %i | Indexed files count |
|
||||
| unindexed | %I | Unindexed files count |
|
||||
| untracked | %u | Untracked files count |
|
||||
|
||||
The following contexts must be enabled with the following zstyle:
|
||||
|
||||
```sh
|
||||
zstyle ':prezto:module:git:info' verbose 'yes'
|
||||
```
|
||||
|
||||
### Verbose Contexts
|
||||
|
||||
| Name | Format Code | Description |
|
||||
| --------- | :---------: | --------------------- |
|
||||
| added | %a | Added files count |
|
||||
| clean | %C | Clean state |
|
||||
| deleted | %d | Deleted files count |
|
||||
| dirty | %D | Dirty files count |
|
||||
| modified | %m | Modified files count |
|
||||
| renamed | %r | Renamed files 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 |
|
||||
| revert | value | Reverting |
|
||||
| revert-sequence | value | Reverting sequence |
|
||||
|
||||
First, format the repository state attributes. For example, to format the branch
|
||||
and remote names, define the following styles.
|
||||
|
||||
```sh
|
||||
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.
|
||||
|
||||
```sh
|
||||
zstyle ':prezto:module:git:info:keys' format \
|
||||
'prompt' ' git(%b)' \
|
||||
'rprompt' '[%R]'
|
||||
```
|
||||
|
||||
Last, add `$git_info[prompt]` to `$PROMPT` and `$git_info[rprompt]` 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]: https://www.git-scm.com
|
||||
[2]: https://hub.github.com
|
||||
[3]: https://www.github.com
|
||||
[4]: https://www.manpagez.com/man/8/gpt/
|
||||
[5]: https://www.manpagez.com/man/1/gs/
|
||||
[6]: https://github.com/sorin-ionescu/prezto/issues
|
||||
[7]: https://github.com/sorin-ionescu/prezto/issues/219
|
||||
[8]: https://git-scm.com/docs/git-log
|
||||
[9]: https://git-scm.com/docs/git-submodule
|
||||
[10]: https://getgb.io/
|
||||
[11]: https://www.manpagez.com/man/1/gm/
|
||||
[12]: https://github.blog/2011-11-10-git-io-github-url-shortener
|
||||
[13]: ../completion#readme
|
||||
[14]: https://github.com/sorin-ionescu/prezto/pull/1929
|
||||
@@ -0,0 +1,283 @@
|
||||
#
|
||||
# Defines Git aliases.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
if ! zstyle -t ':prezto:module:git:alias' skip; then
|
||||
# Git
|
||||
alias g='git'
|
||||
|
||||
# Branch (b)
|
||||
alias gb='git branch'
|
||||
alias gba='git branch --all --verbose'
|
||||
alias gbc='git checkout -b'
|
||||
alias gbd='git branch --delete'
|
||||
alias gbD='git branch --delete --force'
|
||||
alias gbl='git branch --verbose'
|
||||
alias gbL='git branch --all --verbose'
|
||||
alias gbm='git branch --move'
|
||||
alias gbM='git branch --move --force'
|
||||
alias gbr='git branch --move'
|
||||
alias gbR='git branch --move --force'
|
||||
alias gbs='git show-branch'
|
||||
alias gbS='git show-branch --all'
|
||||
alias gbv='git branch --verbose'
|
||||
alias gbV='git branch --verbose --verbose'
|
||||
alias gbx='git branch --delete'
|
||||
alias gbX='git branch --delete --force'
|
||||
|
||||
# Commit (c)
|
||||
alias gc='git commit --verbose'
|
||||
alias gcS='git commit --verbose --gpg-sign'
|
||||
alias gca='git commit --verbose --all'
|
||||
alias gcaS='git commit --verbose --all --gpg-sign'
|
||||
alias gcm='git commit --message'
|
||||
alias gcmS='git commit --message --gpg-sign'
|
||||
alias gcam='git commit --all --message'
|
||||
alias gco='git checkout'
|
||||
alias gcO='git checkout --patch'
|
||||
alias gcf='git commit --amend --reuse-message HEAD'
|
||||
alias gcfS='git commit --amend --reuse-message HEAD --gpg-sign'
|
||||
alias gcF='git commit --verbose --amend'
|
||||
alias gcFS='git commit --verbose --amend --gpg-sign'
|
||||
alias gcp='git cherry-pick --ff'
|
||||
alias gcP='git cherry-pick --no-commit'
|
||||
alias gcr='git revert'
|
||||
alias gcR='git reset "HEAD^"'
|
||||
alias gcs='git show'
|
||||
alias gcsS='git show --pretty=short --show-signature'
|
||||
alias gcl='git-commit-lost'
|
||||
alias gcy='git cherry --verbose --abbrev'
|
||||
alias gcY='git cherry --verbose'
|
||||
|
||||
# Conflict (C)
|
||||
alias gCl='git --no-pager diff --name-only --diff-filter=U'
|
||||
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)'
|
||||
|
||||
# Data (d)
|
||||
alias gd='git ls-files'
|
||||
alias gdc='git ls-files --cached'
|
||||
alias gdx='git ls-files --deleted'
|
||||
alias gdm='git ls-files --modified'
|
||||
alias gdu='git ls-files --other --exclude-standard'
|
||||
alias gdk='git ls-files --killed'
|
||||
alias gdi='git status --porcelain --short --ignored | sed -n "s/^!! //p"'
|
||||
|
||||
# Fetch (f)
|
||||
alias gf='git fetch'
|
||||
alias gfa='git fetch --all'
|
||||
alias gfc='git clone'
|
||||
alias gfcr='git clone --recurse-submodules'
|
||||
alias gfm='git pull'
|
||||
alias gfma='git pull --autostash'
|
||||
alias gfr='git pull --rebase'
|
||||
alias gfra='git pull --rebase --autostash'
|
||||
|
||||
# Flow (F)
|
||||
alias gFi='git flow init'
|
||||
alias gFf='git flow feature'
|
||||
alias gFb='git flow bugfix'
|
||||
alias gFl='git flow release'
|
||||
alias gFh='git flow hotfix'
|
||||
alias gFs='git flow support'
|
||||
|
||||
alias gFfl='git flow feature list'
|
||||
alias gFfs='git flow feature start'
|
||||
alias gFff='git flow feature finish'
|
||||
alias gFfp='git flow feature publish'
|
||||
alias gFft='git flow feature track'
|
||||
alias gFfd='git flow feature diff'
|
||||
alias gFfr='git flow feature rebase'
|
||||
alias gFfc='git flow feature checkout'
|
||||
alias gFfm='git flow feature pull'
|
||||
alias gFfx='git flow feature delete'
|
||||
|
||||
alias gFbl='git flow bugfix list'
|
||||
alias gFbs='git flow bugfix start'
|
||||
alias gFbf='git flow bugfix finish'
|
||||
alias gFbp='git flow bugfix publish'
|
||||
alias gFbt='git flow bugfix track'
|
||||
alias gFbd='git flow bugfix diff'
|
||||
alias gFbr='git flow bugfix rebase'
|
||||
alias gFbc='git flow bugfix checkout'
|
||||
alias gFbm='git flow bugfix pull'
|
||||
alias gFbx='git flow bugfix delete'
|
||||
|
||||
alias gFll='git flow release list'
|
||||
alias gFls='git flow release start'
|
||||
alias gFlf='git flow release finish'
|
||||
alias gFlp='git flow release publish'
|
||||
alias gFlt='git flow release track'
|
||||
alias gFld='git flow release diff'
|
||||
alias gFlr='git flow release rebase'
|
||||
alias gFlc='git flow release checkout'
|
||||
alias gFlm='git flow release pull'
|
||||
alias gFlx='git flow release delete'
|
||||
|
||||
alias gFhl='git flow hotfix list'
|
||||
alias gFhs='git flow hotfix start'
|
||||
alias gFhf='git flow hotfix finish'
|
||||
alias gFhp='git flow hotfix publish'
|
||||
alias gFht='git flow hotfix track'
|
||||
alias gFhd='git flow hotfix diff'
|
||||
alias gFhr='git flow hotfix rebase'
|
||||
alias gFhc='git flow hotfix checkout'
|
||||
alias gFhm='git flow hotfix pull'
|
||||
alias gFhx='git flow hotfix delete'
|
||||
|
||||
alias gFsl='git flow support list'
|
||||
alias gFss='git flow support start'
|
||||
alias gFsf='git flow support finish'
|
||||
alias gFsp='git flow support publish'
|
||||
alias gFst='git flow support track'
|
||||
alias gFsd='git flow support diff'
|
||||
alias gFsr='git flow support rebase'
|
||||
alias gFsc='git flow support checkout'
|
||||
alias gFsm='git flow support pull'
|
||||
alias gFsx='git flow support delete'
|
||||
|
||||
# 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'
|
||||
alias giu='git add --update'
|
||||
alias gid='git diff --no-ext-diff --cached'
|
||||
alias giD='git diff --no-ext-diff --cached --word-diff'
|
||||
alias gii='git update-index --assume-unchanged'
|
||||
alias giI='git update-index --no-assume-unchanged'
|
||||
alias gir='git reset'
|
||||
alias giR='git reset --patch'
|
||||
alias gix='git rm -r --cached'
|
||||
alias giX='git rm -r --force --cached'
|
||||
|
||||
# Log (l)
|
||||
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 --graph --pretty=format:"$_git_log_oneline_format"'
|
||||
alias glb='git log --topo-order --pretty=format:"$_git_log_brief_format"'
|
||||
alias glc='git shortlog --summary --numbered'
|
||||
alias glS='git log --topo-order --show-signature --pretty=format:"${_git_log_medium_format}"'
|
||||
|
||||
# Merge (m)
|
||||
alias gm='git merge'
|
||||
alias gmC='git merge --no-commit'
|
||||
alias gmF='git merge --no-ff'
|
||||
alias gma='git merge --abort'
|
||||
alias gmt='git mergetool'
|
||||
|
||||
# Push (p)
|
||||
alias gp='git push'
|
||||
alias gpf='git push --force-with-lease'
|
||||
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 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'
|
||||
alias gra='git rebase --abort'
|
||||
alias grc='git rebase --continue'
|
||||
alias gri='git rebase --interactive'
|
||||
alias grs='git rebase --skip'
|
||||
|
||||
# Remote (R)
|
||||
alias gR='git remote'
|
||||
alias gRl='git remote --verbose'
|
||||
alias gRa='git remote add'
|
||||
alias gRx='git remote rm'
|
||||
alias gRm='git remote rename'
|
||||
alias gRu='git remote update'
|
||||
alias gRp='git remote prune'
|
||||
alias gRs='git remote show'
|
||||
alias gRb='git-hub-browse'
|
||||
|
||||
# Stash (s)
|
||||
alias gs='git stash'
|
||||
alias gsa='git stash apply'
|
||||
alias gsx='git stash drop'
|
||||
alias gsX='git-stash-clear-interactive'
|
||||
alias gsl='git stash list'
|
||||
alias gsL='git-stash-dropped'
|
||||
alias gsd='git stash show --patch --stat'
|
||||
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 --remote --recursive'
|
||||
alias gSx='git-submodule-remove'
|
||||
|
||||
# Tag (t)
|
||||
alias gt='git tag'
|
||||
alias gtl='git tag --list'
|
||||
alias gts='git tag --sign'
|
||||
alias gtv='git verify-tag'
|
||||
|
||||
# Working Copy (w)
|
||||
alias gws='git status --ignore-submodules=$_git_status_ignore_submodules --short'
|
||||
alias gwS='git status --ignore-submodules=$_git_status_ignore_submodules'
|
||||
alias gwd='git diff --no-ext-diff'
|
||||
alias gwD='git diff --no-ext-diff --word-diff'
|
||||
alias gwr='git reset --soft'
|
||||
alias gwR='git reset --hard'
|
||||
alias gwc='git clean --dry-run'
|
||||
alias gwC='git clean -d --force'
|
||||
alias gwx='git rm -r'
|
||||
alias gwX='git rm -r --force'
|
||||
|
||||
# Worktree management (W)
|
||||
alias gWa='git worktree add'
|
||||
alias gWl='git worktree list'
|
||||
alias gWx='git worktree remove'
|
||||
alias gWX='git worktree remove --force'
|
||||
alias gWm='git worktree move'
|
||||
alias gWc='git worktree prune'
|
||||
fi
|
||||
@@ -0,0 +1,47 @@
|
||||
#compdef git-hub-browse
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes git-hub-browse.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
if ! is-true "$(command 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=($(command 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=($(
|
||||
command 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 command git ls-files -z --exclude-standard 2> /dev/null)"})
|
||||
_wanted file expl 'file' _multi_parts - / files && ret=0
|
||||
;;
|
||||
esac
|
||||
|
||||
return $ret
|
||||
@@ -0,0 +1,16 @@
|
||||
#compdef git-hub-shorten-url
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes git-hub-shorten-url.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
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
|
||||
@@ -0,0 +1,18 @@
|
||||
#compdef git-info
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes git-info.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
if ! is-true "$(command 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'
|
||||
))" && return 0
|
||||
@@ -0,0 +1,40 @@
|
||||
#compdef git-submodule-move
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes git-submodule-move.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
if ! is-true "$(command 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 < <(
|
||||
command 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
|
||||
@@ -0,0 +1,26 @@
|
||||
#compdef git-submodule-remove
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes git-submodule-remove.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
if ! is-true "$(command 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 < <(
|
||||
command git config --file "$(git-root)/.gitmodules" --list \
|
||||
| grep '.path=' \
|
||||
| cut -d= -f2-
|
||||
)
|
||||
|
||||
_describe -t submodule 'submodules' submodules && return 0
|
||||
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Displays the current Git branch.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function git-branch-current {
|
||||
|
||||
if ! command git rev-parse 2> /dev/null; then
|
||||
print "$0: not a repository: $PWD" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local ref="$(command git symbolic-ref HEAD 2> /dev/null)"
|
||||
|
||||
if [[ -n "$ref" ]]; then
|
||||
print "${ref#refs/heads/}"
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Lists lost Git commits.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function git-commit-lost {
|
||||
|
||||
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
||||
print "$0: not a repository work tree: $PWD" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
command git fsck 2> /dev/null \
|
||||
| grep "^dangling commit" \
|
||||
| awk '{print $3}' \
|
||||
| command git log \
|
||||
--date-order \
|
||||
--no-walk \
|
||||
--stdin \
|
||||
--pretty=format:${_git_log_oneline_format}
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# Displays the path to the Git directory.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function git-dir {
|
||||
|
||||
local git_dir="${$(command 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
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,62 @@
|
||||
#
|
||||
# Opens a GitHub repository in the default browser.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function git-hub-browse {
|
||||
|
||||
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
||||
print "$0: not a repository work tree: $PWD" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local remotes remote references reference file url
|
||||
|
||||
remote="${1:-origin}"
|
||||
remotes=($(command git remote show))
|
||||
|
||||
if (( $remotes[(i)$remote] == $#remotes + 1 )); then
|
||||
print "$0: remote not found: $remote" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
url=$(
|
||||
command git remote get-url "$remote" \
|
||||
| sed -En "s#(git@|https?://)(github.com)(:|/)(.+)/(.+)\.git#https://\2/\4/\5#p"
|
||||
)
|
||||
|
||||
reference="${${2:-$(git-branch-current)}:-HEAD}"
|
||||
references=(
|
||||
HEAD
|
||||
${${(f)"$(command git ls-remote --heads --tags "$remote")"}##*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="$(command git rev-parse HEAD 2> /dev/null)"
|
||||
fi
|
||||
|
||||
file="$3"
|
||||
|
||||
if [[ -n "$url" ]]; then
|
||||
url="$url/tree/$reference/$file"
|
||||
|
||||
if [[ -n "$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
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# Shortens GitHub URLs.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function git-hub-shorten-url {
|
||||
|
||||
local url="$1" code="$2"
|
||||
|
||||
if [[ "$url" == '-' ]]; then
|
||||
read url <&0
|
||||
fi
|
||||
|
||||
if [[ -z "$url" || ! "$url" =~ ^https?:\/\/.*github.com\/ ]]; then
|
||||
print "usage: $0 [ url | - ] [code] ; url must be a github.com URL" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if (( $+commands[curl] )); then
|
||||
print "${${(@M)${(f)"$(curl -s -i 'https://git.io' -F "url=$url" ${(z)code:+ -F "code=$code"})"}:#Location: *}#Location: }"
|
||||
else
|
||||
print "$0: command not found: curl" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,459 @@
|
||||
#
|
||||
# Exposes Git repository information via the $git_info associative array.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Gets the Git special action (am, bisect, cherry, merge, rebase, revert).
|
||||
# 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
|
||||
local revert_formatted
|
||||
local revert_sequence_formatted
|
||||
|
||||
for action_dir in \
|
||||
"$git_dir/rebase-apply" \
|
||||
"$git_dir/rebase" \
|
||||
"$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_formatted"
|
||||
elif [[ -f "$action_dir/applying" ]] ; then
|
||||
print "$apply_formatted"
|
||||
else
|
||||
print "$rebase_formatted/$apply_formatted"
|
||||
fi
|
||||
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
for action_dir in \
|
||||
"$git_dir/rebase-merge/interactive" \
|
||||
"$git_dir/.dotest-merge/interactive"
|
||||
do
|
||||
if [[ -f "$action_dir" ]]; then
|
||||
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
|
||||
|
||||
for action_dir in \
|
||||
"$git_dir/rebase-merge" \
|
||||
"$git_dir/.dotest-merge"
|
||||
do
|
||||
if [[ -d "$action_dir" ]]; then
|
||||
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
|
||||
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
|
||||
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
|
||||
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/REVERT_HEAD" ]]; then
|
||||
if [[ -d "$git_dir/sequencer" ]] ; then
|
||||
zstyle -s ':prezto:module:git:info:action:revert-sequence' format 'revert_sequence_formatted' \
|
||||
|| revert_sequence_formatted='revert-sequence'
|
||||
print "$revert_sequence_formatted"
|
||||
else
|
||||
zstyle -s ':prezto:module:git:info:action:revert' format 'revert_formatted' \
|
||||
|| revert_formatted='revert'
|
||||
print "$revert_formatted"
|
||||
fi
|
||||
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "$git_dir/BISECT_LOG" ]]; then
|
||||
zstyle -s ':prezto:module:git:info:action:bisect' format 'bisect_formatted' \
|
||||
|| bisect_formatted='bisect'
|
||||
print "$bisect_formatted"
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Gets the Git status information.
|
||||
function git-info {
|
||||
# Extended globbing is needed to parse repository status.
|
||||
setopt LOCAL_OPTIONS
|
||||
setopt EXTENDED_GLOB
|
||||
|
||||
local action
|
||||
local action_format
|
||||
local action_formatted
|
||||
local added=0
|
||||
local added_format
|
||||
local added_formatted
|
||||
local ahead=0
|
||||
local ahead_and_behind
|
||||
local ahead_and_behind_cmd
|
||||
local ahead_format
|
||||
local ahead_formatted
|
||||
local ahead_or_behind
|
||||
local behind=0
|
||||
local behind_format
|
||||
local behind_formatted
|
||||
local branch
|
||||
local branch_format
|
||||
local branch_formatted
|
||||
local branch_info
|
||||
local clean
|
||||
local clean_formatted
|
||||
local commit
|
||||
local commit_format
|
||||
local commit_formatted
|
||||
local deleted=0
|
||||
local deleted_format
|
||||
local deleted_formatted
|
||||
local dirty=0
|
||||
local dirty_format
|
||||
local dirty_formatted
|
||||
local ignore_submodules
|
||||
local indexed=0
|
||||
local indexed_format
|
||||
local indexed_formatted
|
||||
local -A info_formats
|
||||
local info_format
|
||||
local modified=0
|
||||
local modified_format
|
||||
local modified_formatted
|
||||
local position
|
||||
local position_format
|
||||
local position_formatted
|
||||
local remote
|
||||
local remote_cmd
|
||||
local remote_format
|
||||
local remote_formatted
|
||||
local renamed=0
|
||||
local renamed_format
|
||||
local renamed_formatted
|
||||
local stashed=0
|
||||
local stashed_format
|
||||
local stashed_formatted
|
||||
local status_cmd
|
||||
local status_mode
|
||||
local unindexed=0
|
||||
local unindexed_format
|
||||
local unindexed_formatted
|
||||
local unmerged=0
|
||||
local unmerged_format
|
||||
local unmerged_formatted
|
||||
local untracked=0
|
||||
local untracked_format
|
||||
local untracked_formatted
|
||||
|
||||
# Clean up previous $git_info.
|
||||
unset git_info
|
||||
typeset -gA git_info
|
||||
|
||||
# Return if not inside a Git repository work tree.
|
||||
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if (( $# > 0 )); then
|
||||
if [[ "$1" == [Oo][Nn] ]]; then
|
||||
command git config --bool prompt.showinfo true
|
||||
elif [[ "$1" == [Oo][Ff][Ff] ]]; then
|
||||
command git config --bool prompt.showinfo false
|
||||
else
|
||||
print "usage: $0 [ on | off ]" >&2
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Return if git-info is disabled.
|
||||
if ! is-true "${$(command git config --bool prompt.showinfo):-true}"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Ignore submodule status.
|
||||
zstyle -s ':prezto:module:git:status:ignore' submodules 'ignore_submodules'
|
||||
|
||||
# Format commit.
|
||||
zstyle -s ':prezto:module:git:info:commit' format 'commit_format'
|
||||
if [[ -n "$commit_format" ]]; then
|
||||
commit="$(command git rev-parse HEAD 2> /dev/null)"
|
||||
if [[ -n "$commit" ]]; then
|
||||
zformat -f commit_formatted "$commit_format" "c:$commit"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format stashed.
|
||||
zstyle -s ':prezto:module:git:info:stashed' format 'stashed_format'
|
||||
if [[ -n "$stashed_format" ]]; then
|
||||
commondir=""
|
||||
if [[ -f "$(git-dir)/commondir" ]]; then
|
||||
commondir="$(<$(git-dir)/commondir)"
|
||||
[[ "$commondir" =~ ^/ ]] || commondir="$(git-dir)/$commondir"
|
||||
fi
|
||||
if [[ -f "$(git-dir)/refs/stash" || ( -n "$commondir" && -f "$commondir/refs/stash" ) ]]; then
|
||||
stashed=${#${(f)"$(command git stash list 2> /dev/null)"}}
|
||||
if (( $stashed > 0 )); then
|
||||
zformat -f stashed_formatted "$stashed_format" "S:$stashed"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format action.
|
||||
zstyle -s ':prezto:module:git:info:action' format 'action_format'
|
||||
if [[ -n "$action_format" ]]; then
|
||||
action="$(_git-action)"
|
||||
if [[ -n "$action" ]]; then
|
||||
zformat -f action_formatted "$action_format" "s:$action"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Get the branch.
|
||||
branch="$(escape-eval "${$(command git symbolic-ref HEAD 2> /dev/null)#refs/heads/}")"
|
||||
|
||||
# Format branch.
|
||||
zstyle -s ':prezto:module:git:info:branch' format 'branch_format'
|
||||
if [[ -n "$branch" && -n "$branch_format" ]]; then
|
||||
zformat -f branch_formatted "$branch_format" "b:$branch"
|
||||
fi
|
||||
|
||||
# Format position.
|
||||
zstyle -s ':prezto:module:git:info:position' format 'position_format'
|
||||
if [[ -z "$branch" && -n "$position_format" ]]; then
|
||||
position="$(escape-eval "$(command git describe --contains --all HEAD 2> /dev/null)")"
|
||||
if [[ -n "$position" ]]; then
|
||||
zformat -f position_formatted "$position_format" "p:$position"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format remote.
|
||||
zstyle -s ':prezto:module:git:info:remote' format 'remote_format'
|
||||
if [[ -n "$branch" && -n "$remote_format" ]]; then
|
||||
# Gets the remote name.
|
||||
remote_cmd='command git rev-parse --symbolic-full-name --verify HEAD@{upstream}'
|
||||
remote="$(escape-eval "${$(${(z)remote_cmd} 2> /dev/null)##refs/remotes/}")"
|
||||
if [[ -n "$remote" ]]; then
|
||||
zformat -f remote_formatted "$remote_format" "R:$remote"
|
||||
fi
|
||||
fi
|
||||
|
||||
zstyle -s ':prezto:module:git:info:ahead' format 'ahead_format'
|
||||
zstyle -s ':prezto:module:git:info:behind' format 'behind_format'
|
||||
if [[ -n "$branch" && ( -n "$ahead_format" || -n "$behind_format" ) ]]; then
|
||||
# Gets the commit difference counts between local and remote.
|
||||
ahead_and_behind_cmd='command git rev-list --count --left-right HEAD...@{upstream}'
|
||||
|
||||
# Get ahead and behind counts.
|
||||
ahead_and_behind="$(${(z)ahead_and_behind_cmd} 2> /dev/null)"
|
||||
|
||||
# Format ahead.
|
||||
if [[ -n "$ahead_format" ]]; then
|
||||
ahead="$ahead_and_behind[(pws:\t:)1]"
|
||||
if (( ahead > 0 )); then
|
||||
zformat -f ahead_formatted "$ahead_format" "A:$ahead"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format behind.
|
||||
if [[ -n "$behind_format" ]]; then
|
||||
behind="$ahead_and_behind[(pws:\t:)2]"
|
||||
if (( behind > 0 )); then
|
||||
zformat -f behind_formatted "$behind_format" "B:$behind"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Get status type.
|
||||
if ! zstyle -t ':prezto:module:git:info' verbose; then
|
||||
# Format indexed.
|
||||
zstyle -s ':prezto:module:git:info:indexed' format 'indexed_format'
|
||||
if [[ -n "$indexed_format" ]]; then
|
||||
((
|
||||
indexed+=$(
|
||||
command git diff-index \
|
||||
--no-ext-diff \
|
||||
--name-only \
|
||||
--cached \
|
||||
--ignore-submodules=${ignore_submodules:-none} \
|
||||
HEAD \
|
||||
2> /dev/null \
|
||||
| wc -l
|
||||
)
|
||||
))
|
||||
if (( indexed > 0 )); then
|
||||
zformat -f indexed_formatted "$indexed_format" "i:$indexed"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format unindexed.
|
||||
zstyle -s ':prezto:module:git:info:unindexed' format 'unindexed_format'
|
||||
if [[ -n "$unindexed_format" ]]; then
|
||||
((
|
||||
unindexed+=$(
|
||||
command git diff-files \
|
||||
--no-ext-diff \
|
||||
--name-only \
|
||||
--ignore-submodules=${ignore_submodules:-none} \
|
||||
2> /dev/null \
|
||||
| wc -l
|
||||
)
|
||||
))
|
||||
if (( unindexed > 0 )); then
|
||||
zformat -f unindexed_formatted "$unindexed_format" "I:$unindexed"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format untracked.
|
||||
zstyle -s ':prezto:module:git:info:untracked' format 'untracked_format'
|
||||
if [[ -n "$untracked_format" ]]; then
|
||||
((
|
||||
untracked+=$(
|
||||
command git ls-files \
|
||||
--other \
|
||||
--exclude-standard \
|
||||
2> /dev/null \
|
||||
| wc -l
|
||||
)
|
||||
))
|
||||
if (( untracked > 0 )); then
|
||||
zformat -f untracked_formatted "$untracked_format" "u:$untracked"
|
||||
fi
|
||||
fi
|
||||
|
||||
(( dirty = indexed + unindexed + untracked ))
|
||||
else
|
||||
# Use porcelain status for easy parsing.
|
||||
status_cmd="command git status --porcelain --ignore-submodules=${ignore_submodules:-none}"
|
||||
|
||||
# Get current status.
|
||||
while IFS=$'\n' read line; do
|
||||
# Count added, deleted, modified, renamed, unmerged, untracked, dirty.
|
||||
# T (type change) is undocumented, see http://git.io/FnpMGw.
|
||||
# For a table of scenarii, see http://i.imgur.com/2YLu1.png.
|
||||
[[ "$line" == ([ACDMT][\ MT]|[ACMT]D)\ * ]] && (( added++ ))
|
||||
[[ "$line" == [\ ACMRT]D\ * ]] && (( deleted++ ))
|
||||
[[ "$line" == ?[MT]\ * ]] && (( modified++ ))
|
||||
[[ "$line" == R?\ * ]] && (( renamed++ ))
|
||||
[[ "$line" == (AA|DD|U?|?U)\ * ]] && (( unmerged++ ))
|
||||
[[ "$line" == \?\?\ * ]] && (( untracked++ ))
|
||||
(( dirty++ ))
|
||||
done < <(${(z)status_cmd} 2> /dev/null)
|
||||
|
||||
# Format added.
|
||||
if (( added > 0 )); then
|
||||
zstyle -s ':prezto:module:git:info:added' format 'added_format'
|
||||
zformat -f added_formatted "$added_format" "a:$added"
|
||||
fi
|
||||
|
||||
# Format deleted.
|
||||
if (( deleted > 0 )); then
|
||||
zstyle -s ':prezto:module:git:info:deleted' format 'deleted_format'
|
||||
zformat -f deleted_formatted "$deleted_format" "d:$deleted"
|
||||
fi
|
||||
|
||||
# Format modified.
|
||||
if (( modified > 0 )); then
|
||||
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: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: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:info:untracked' format 'untracked_format'
|
||||
zformat -f untracked_formatted "$untracked_format" "u:$untracked"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format dirty and clean.
|
||||
if (( dirty > 0 )); then
|
||||
zstyle -s ':prezto:module:git:info:dirty' format 'dirty_format'
|
||||
zformat -f dirty_formatted "$dirty_format" "D:$dirty"
|
||||
# Overwrite branch format to use dirty-branch format
|
||||
zstyle -s ':prezto:module:git:info:dirty-branch' format 'branch_format'
|
||||
if [[ -n "$branch" && -n "$branch_format" ]]; then
|
||||
zformat -f branch_formatted "$branch_format" "b:$branch"
|
||||
fi
|
||||
else
|
||||
zstyle -s ':prezto:module:git:info:clean' format 'clean_formatted'
|
||||
fi
|
||||
|
||||
# Format info.
|
||||
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:$added_formatted" \
|
||||
"A:$ahead_formatted" \
|
||||
"B:$behind_formatted" \
|
||||
"b:$branch_formatted" \
|
||||
"C:$clean_formatted" \
|
||||
"c:$commit_formatted" \
|
||||
"d:$deleted_formatted" \
|
||||
"D:$dirty_formatted" \
|
||||
"i:$indexed_formatted" \
|
||||
"I:$unindexed_formatted" \
|
||||
"m:$modified_formatted" \
|
||||
"p:$position_formatted" \
|
||||
"R:$remote_formatted" \
|
||||
"r:$renamed_formatted" \
|
||||
"s:$action_formatted" \
|
||||
"S:$stashed_formatted" \
|
||||
"U:$unmerged_formatted" \
|
||||
"u:$untracked_formatted"
|
||||
git_info[$info_format]="$REPLY"
|
||||
done
|
||||
|
||||
unset REPLY
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
git-info "$@"
|
||||
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# Displays the path to the working tree root.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function git-root {
|
||||
|
||||
local root="$(command git rev-parse --show-toplevel 2> /dev/null)"
|
||||
|
||||
if [[ -n "$root" ]]; then
|
||||
print "$root"
|
||||
return 0
|
||||
else
|
||||
print "$0: not a repository work tree: $PWD" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Asks for confirmation before clearing the Git stash.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function git-stash-clear-interactive {
|
||||
|
||||
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
||||
print "$0: not a repository work tree: $PWD" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local stashed
|
||||
|
||||
if [[ -f "$(git-dir)/refs/stash" ]]; then
|
||||
stashed=${#${(f)"$(command git stash list 2> /dev/null)"}}
|
||||
if (( $stashed > 0 )); then
|
||||
if read -q "?Clear $stashed stashed state(s) [y/N]? "; then
|
||||
command git stash clear
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Lists dropped Git stashed states.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function git-stash-dropped {
|
||||
|
||||
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
||||
print "$0: not a repository work tree: $PWD" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
command git fsck --unreachable 2> /dev/null \
|
||||
| grep 'commit' \
|
||||
| awk '{print $3}' \
|
||||
| command git log \
|
||||
--pretty=format:$_git_log_oneline_format \
|
||||
--extended-regexp \
|
||||
--grep="${1:-(WIP )?[Oo]n [^:]+:}" \
|
||||
--merges \
|
||||
--no-walk \
|
||||
--stdin
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Recovers dropped Git stashed states.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function git-stash-recover {
|
||||
|
||||
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
||||
print "$0: not a repository work tree: $PWD" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local commit
|
||||
|
||||
for commit in "$@"; do
|
||||
command git update-ref \
|
||||
-m "$(command git log -1 --pretty="format:%s" "$commit")" refs/stash "$commit"
|
||||
done
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,36 @@
|
||||
#
|
||||
# Moves a Git submodule.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function git-submodule-move {
|
||||
|
||||
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
||||
print "$0: not a repository work tree: $PWD" >&2
|
||||
return 1
|
||||
elif [[ "$PWD" != "$(git-root)" ]]; then
|
||||
print "$0: must be run from the root of the work tree" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local src="$1"
|
||||
local dst="$2"
|
||||
local url
|
||||
|
||||
url="$(command 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"
|
||||
command git submodule add "$url" "$dst"
|
||||
|
||||
return 0
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# Removes a Git submodule.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function git-submodule-remove {
|
||||
|
||||
if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
||||
print "$0: not a repository work tree: $PWD" >&2
|
||||
return 1
|
||||
elif [[ "$PWD" != "$(git-root)" ]]; then
|
||||
print "$0: must be run from the root of the work tree" >&2
|
||||
return 1
|
||||
elif ! command git config --file .gitmodules --get "submodule.${1}.path" &> /dev/null; then
|
||||
print "$0: submodule not found: $1" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
command git config --file "$(git-dir)/config" --remove-section "submodule.${1}" &> /dev/null
|
||||
command git config --file "$(git-root)/.gitmodules" --remove-section "submodule.${1}" &> /dev/null
|
||||
command git add .gitmodules
|
||||
|
||||
command git rm --cached -rf "$1"
|
||||
rm -rf "$1"
|
||||
rm -rf "$(git-dir)/modules/$1"
|
||||
|
||||
return 0
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# Provides Git aliases and functions.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Return if requirements are not found.
|
||||
if (( ! $+commands[git] )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Load dependencies.
|
||||
pmodload 'helper'
|
||||
|
||||
# Load 'run-help' function.
|
||||
autoload -Uz run-help-git
|
||||
|
||||
# Source module files.
|
||||
source "${0:h}/alias.zsh"
|
||||
Reference in New Issue
Block a user