Refactor vcs aliases / functions
This commit is contained in:
parent
2282d01a7d
commit
d8e96bf4c6
43
aliases/git
43
aliases/git
|
@ -5,28 +5,37 @@ ginit() {
|
|||
git commit -a -m "Initial Commit"
|
||||
}
|
||||
|
||||
gst() {
|
||||
if [[ "${vcs_info_msg_0_[2,3]}" == 'hg' ]]; then
|
||||
hg status "$@"
|
||||
else
|
||||
git status "$@"
|
||||
fi
|
||||
# define a function that calls different versioning systems depending on
|
||||
# detected vcs for current directory
|
||||
# usage: defvcsfun <command name> <parameters for git> <parameters for hg> <parameters for svn>
|
||||
# see below for examples
|
||||
defvcsfun() {
|
||||
local name=$1; shift
|
||||
local args=($@)
|
||||
eval "$name() {
|
||||
case \$VCS_DETECTED in
|
||||
git)
|
||||
git ${=args[1]} \"\$@\";;
|
||||
hg)
|
||||
hg ${=args[2]} \"\$@\";;
|
||||
svn)
|
||||
svn ${=args[3]} \"\$@\";;
|
||||
*)
|
||||
echo \"unknown vcs: \$VCS_DETECTED\";;
|
||||
esac
|
||||
}"
|
||||
}
|
||||
|
||||
gpl() {
|
||||
if [[ "${vcs_info_msg_0_[2,3]}" == 'hg' ]]; then
|
||||
hg pull "$@"
|
||||
else
|
||||
git pull "$@"
|
||||
fi
|
||||
}
|
||||
#VCS command git hg svn
|
||||
defvcsfun gst "status -s" "status" "status"
|
||||
defvcsfun gpl "pull" "pull" "update"
|
||||
defvcsfun gcm "commit" "commit" "commit"
|
||||
defvcsfun ga "add" "add" "add"
|
||||
defvcsfun gpu "push" "push" "i_am_not_distributed_please_dont_push_me"
|
||||
|
||||
alias gca="git commit -a"
|
||||
alias gcm="git commit"
|
||||
alias gco="git checkout"
|
||||
alias ga="git add"
|
||||
alias gca="git commit -a"
|
||||
alias gap="git add --patch"
|
||||
alias gpu="git push"
|
||||
|
||||
|
||||
gls() {
|
||||
|
|
Loading…
Reference in a new issue