mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 15:36:21 -04:00
Avoid incorrect usage probably because of the missing quotes, like "git alias cm checkout master"
17 lines
489 B
Bash
Executable file
17 lines
489 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
usage() {
|
|
cat <<HERE
|
|
usage: git alias # list all aliases
|
|
or: git alias <search-pattern> # show aliases matching pattern
|
|
or: git alias <alias-name> <command> # alias a command
|
|
HERE
|
|
}
|
|
|
|
case $# in
|
|
0) git config --get-regexp 'alias.*' | sed 's/^alias\.//' | sed 's/[ ]/ = /' | sort ;;
|
|
1) git alias | grep -e "$1" ;;
|
|
2) git config --global alias."$1" "$2" ;;
|
|
*) >&2 echo "error: too many arguments." && usage && exit 1 ;;
|
|
esac
|