Added some single command aliases (+-!#@^) and working 'add' command

This commit is contained in:
William Hilton 2015-11-03 01:46:28 -05:00
parent 5f2a90a749
commit f9ab6e296c
2 changed files with 21 additions and 16 deletions

View file

@ -24,29 +24,30 @@ _get_complete()
# $3 : the word preceding the word being completed
case ${COMP_CWORD} in
1)
commands="branch commit diff fetch ignore reset rmbranch review stage status unstage"
commands="branch commit diff fetch ignore reset rm rmbranch review stage unstage"
COMPREPLY=( $(compgen -W "${commands}" "$2") )
;;
2)
compopt -o nospace
case "$3" in
#case "$3" in
case "${COMP_WORDS[1]}" in
# <branch>
branch | rmbranch | fetch)
'@' | branch | rmbranch | fetch)
COMPREPLY=( $(compgen -W "$(list_branches)" "$2") )
;;
# <modified path>
stage)
'=' | stage | reset)
COMPREPLY=( $(compgen -W "$(list_modified)" "$2") )
;;
# <tracked path>
unstage)
COMPREPLY=( $(compgen -W "$(list_staged)" "$2") )
;;
rm | diff)
'-' | rm | diff)
COMPREPLY=( $(compgen -W "$(list_tracked)" "$2") )
;;
# <untracked path>
add)
'+' | add)
compopt -o nospace
COMPREPLY=( $(compgen -W "$(list_untracked)" -W "STAGE" -W "HEAD" "$2") )
;;

24
bin/get
View file

@ -10,7 +10,7 @@ list_remote_branches() {
}
case "$1" in
"" | status)
'?' | status)
# TODO: Display help if not inside a repo
# TODO: figure out how to git config --global color.status always automatically.
git status \
@ -23,7 +23,7 @@ git status \
| grep -v 'nothing added to commit but untracked files present (use "git add" to track)'
;;
stage)
= | stage)
if [ -z "$2" ]; then
echo Staging all modified files
git add -u :/
@ -43,7 +43,7 @@ else
fi
;;
tag)
'#' | tag)
echo Tagging
git tag "$2"
;;
@ -76,11 +76,15 @@ then
fi
;;
add)
# TODO: make add only add untracked files (useful when auto-completing)
'+' | add)
# The only real difference between add and stage is
# add will tab-complete with untracked files, while
# stage tab-completes with tracked files
echo Staging "${@:2}"
git add --all "${@:2}"
;;
rm)
'-' | rm)
echo Removing tracked files
git rm -r "$2"
# Check to see if there are still remaining files
@ -110,7 +114,7 @@ else
fi
;;
commit)
'!' | commit)
echo "Parent commit: $(git log --abbrev-commit -1 --pretty=format:'%C(bold blue)%s%Creset %Cgreen(%cr)%Creset')"
if [ -z "$2" ]; then
read -ep 'Message: ' msg
@ -129,7 +133,7 @@ undo)
esac
;;
branch)
'@' | branch)
echo 'Switching to branch'
if [ -z "$2" ]; then
echo '! Specify branch name'
@ -213,7 +217,7 @@ echo 'Compare stage with HEAD'
git diff --cached --ignore-space-change HEAD
;;
push)
^ | push)
echo 'Pushing'
# Check to see if upstream is set.
if git rev-parse --abbrev-ref @{upstream} >/dev/null ; then
@ -289,7 +293,7 @@ else
fi
;;
lg)
log)
git log --color \
--graph \
--pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' \