Browse files

load gitconfig aliases as top-level commands

  • Loading branch information...
1 parent b056482 commit 1dfc298051f4a1e03f40bcf02b56968e86f26dbe @rtomayko committed Mar 28, 2010
Showing with 18 additions and 0 deletions.
  1. +3 −0 git-sh-config.bash
  2. +15 −0 git-sh.bash
View
3 git-sh-config.bash
@@ -1,6 +1,9 @@
# CONFIG ==============================================================
+# load gitconfig [alias] section as top-level aliases.
+_git_import_aliases
+
# source the system-wide rc file
[ -r /etc/gitshrc ] && . /etc/gitshrc
View
15 git-sh.bash
@@ -158,6 +158,21 @@ for cfg in "${_git_cmd_cfg[@]}" ; do
done
done
+# Create aliases for everything defined in the gitconfig [alias] section.
+_git_import_aliases () {
+ eval "$(
+ git config --get-regexp 'alias\..*' |
+ sed 's/^alias\.//' |
+ while read key command
+ do
+ if expr -- "$command" : '!' >/dev/null
+ then echo "alias $key='${command#!}'"
+ else echo "gitalias $key='git $command'"
+ fi
+ done
+ )"
+}
+
# PROMPT =======================================================================
PS1='`_git_headname`!`_git_workdir``_git_dirty`> '

0 comments on commit 1dfc298

Please sign in to comment.