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"
|
git commit -a -m "Initial Commit"
|
||||||
}
|
}
|
||||||
|
|
||||||
gst() {
|
# define a function that calls different versioning systems depending on
|
||||||
if [[ "${vcs_info_msg_0_[2,3]}" == 'hg' ]]; then
|
# detected vcs for current directory
|
||||||
hg status "$@"
|
# usage: defvcsfun <command name> <parameters for git> <parameters for hg> <parameters for svn>
|
||||||
else
|
# see below for examples
|
||||||
git status "$@"
|
defvcsfun() {
|
||||||
fi
|
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() {
|
#VCS command git hg svn
|
||||||
if [[ "${vcs_info_msg_0_[2,3]}" == 'hg' ]]; then
|
defvcsfun gst "status -s" "status" "status"
|
||||||
hg pull "$@"
|
defvcsfun gpl "pull" "pull" "update"
|
||||||
else
|
defvcsfun gcm "commit" "commit" "commit"
|
||||||
git pull "$@"
|
defvcsfun ga "add" "add" "add"
|
||||||
fi
|
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 gco="git checkout"
|
||||||
alias ga="git add"
|
alias gca="git commit -a"
|
||||||
alias gap="git add --patch"
|
alias gap="git add --patch"
|
||||||
alias gpu="git push"
|
|
||||||
|
|
||||||
|
|
||||||
gls() {
|
gls() {
|
||||||
|
|
Loading…
Reference in a new issue