mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-03-20 03:13:33 +01:00
Added new plugin git-auto-status to automatically run git status command after bunch of commands like git commit
This commit is contained in:
parent
140034605e
commit
aaadaff470
2 changed files with 55 additions and 0 deletions
26
plugins/git-auto-status/README.md
Normal file
26
plugins/git-auto-status/README.md
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Git auto status
|
||||||
|
|
||||||
|
If you found yourself constantly typing `git status` after bunch of commands like
|
||||||
|
`git commit` and you want to avoid that, than this plugin is for you.
|
||||||
|
|
||||||
|
### Tuning
|
||||||
|
|
||||||
|
The default list of command that git status is automatically running after is
|
||||||
|
next:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gitPreAutoStatusCommands=(
|
||||||
|
'add'
|
||||||
|
'rm'
|
||||||
|
'reset'
|
||||||
|
'commit'
|
||||||
|
'checkout'
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
You can adjust this list by setting this var in your **.zshrc** after
|
||||||
|
`plugins=(...)` initialization.
|
||||||
|
|
||||||
|
### Maintainers
|
||||||
|
|
||||||
|
[@oshybystyi](https://github.com/oshybystyi/)
|
||||||
29
plugins/git-auto-status/git-auto-status.plugin.zsh
Normal file
29
plugins/git-auto-status/git-auto-status.plugin.zsh
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#
|
||||||
|
# Run git status after specified set of command
|
||||||
|
#
|
||||||
|
# @author Oleksandr Shybystyi oleksandr.shybystyi@gmail.com
|
||||||
|
#
|
||||||
|
|
||||||
|
# default list of git commands `git status` is running after
|
||||||
|
gitPreAutoStatusCommands=(
|
||||||
|
'add'
|
||||||
|
'rm'
|
||||||
|
'reset'
|
||||||
|
'commit'
|
||||||
|
'checkout'
|
||||||
|
)
|
||||||
|
|
||||||
|
# taken from http://stackoverflow.com/a/8574392/4647743
|
||||||
|
function elementInArray() {
|
||||||
|
local e
|
||||||
|
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function git() {
|
||||||
|
command git $@
|
||||||
|
|
||||||
|
if (elementInArray $1 $gitPreAutoStatusCommands); then
|
||||||
|
command git status
|
||||||
|
fi
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue