diff --git a/bash_completion b/bash_completion index 77da286..67f9cdb 100644 --- a/bash_completion +++ b/bash_completion @@ -2,7 +2,19 @@ list_branches() { git for-each-ref refs/heads --format="%(refname:short)" } - +list_tracked() { + git ls-tree HEAD | grep blob | awk '{print $4}'; + git ls-tree HEAD | grep tree | awk '{print $4"/"}'; +} +list_untracked() { + git ls-files --exclude-standard --other --directory --no-empty-directory +} +list_modified() { + git ls-files --modified +} +list_staged() { + git diff --name-only --relative --cached +} _get_complete() { # Available variables: @@ -16,20 +28,35 @@ case ${COMP_CWORD} in COMPREPLY=( $(compgen -W "${commands}" "$2") ) ;; 2) + compopt -o nospace case "$3" in + # branch | rmbranch | fetch) - commands=$(list_branches) - COMPREPLY=( $(compgen -W "${commands}" "$2") ) + COMPREPLY=( $(compgen -W "$(list_branches)" "$2") ) ;; - stage | unstage | ignore | rm) + # + stage) + COMPREPLY=( $(compgen -W "$(list_modified)" "$2") ) + ;; + # + unstage) + COMPREPLY=( $(compgen -W "$(list_staged)" "$2") ) + ;; + rm | diff) + COMPREPLY=( $(compgen -W "$(list_tracked)" "$2") ) + ;; + # + add) compopt -o nospace - COMPREPLY=( $(compgen -o default -S "/" -d -X .git "$2") ) - ;; + COMPREPLY=( $(compgen -W "$(list_untracked)" -W "STAGE" -W "HEAD" "$2") ) + ;; + esac +;; +3) + case "${COMP_WORDS[COMP_CWORD-2]}" in diff) compopt -o nospace - commands="STAGE" - COMPREPLY=( $(compgen -W "${commands}" "$2") ) - COMPREPLY+=( $(compgen -o default -S "/" -d -X .git "$2") ) + COMPREPLY=( $(compgen -W "$(list_tracked)" "$2") ) ;; esac ;; diff --git a/bin/get b/bin/get index 83c3c1b..91a412d 100755 --- a/bin/get +++ b/bin/get @@ -29,7 +29,7 @@ if [ -z "$2" ]; then git add -u :/ else echo Staging "${@:2}" - git add "${@:2}" + git add --all "${@:2}" fi ;;