diff --git a/bash/bash_aliases.d/git.sh b/bash/bash_aliases.d/git.sh index cc95374..b1e921e 100644 --- a/bash/bash_aliases.d/git.sh +++ b/bash/bash_aliases.d/git.sh @@ -1,5 +1,6 @@ alias gs='git status' alias ga='git add' +alias gaa='git add --all' alias gu='git add -u' alias gc='git commit -v' alias gca='git commit -v -a' @@ -10,3 +11,4 @@ alias gb='git branch' alias gco='git checkout' alias gr='git remote' alias gd='git diff' +alias gph='git push heroku' diff --git a/git/gitconfig b/git/gitconfig new file mode 100644 index 0000000..f239446 --- /dev/null +++ b/git/gitconfig @@ -0,0 +1,32 @@ +[diff] +[color] + ui = auto +[alias] + st = status + ci = commit + co = checkout + di = diff + dc = diff --cached + amend = commit --amend + aa = add --all + ff = merge --ff-only + pullff = pull --ff-only + noff = merge --no-ff + div = divergence + gn = goodness + gnc = goodness --cached + fa = fetch --all + pom = push origin master + b = branch + ds = diff --stat=160,120 + dh1 = diff HEAD~1 + + head = !git l -1 + h = !git head + hp = "!source ~/.githelpers && show_git_head" + r = !git l -30 + ra = !git r --all + l = "!source ~/.githelpers && pretty_git_log" + la = !git l --all +[merge] + tool = vimdiff diff --git a/git/githelpers b/git/githelpers new file mode 100644 index 0000000..ec65944 --- /dev/null +++ b/git/githelpers @@ -0,0 +1,40 @@ +#!/bin/bash + +# Log output: +# +# * 51c333e (12 days) add vim-eunuch +# +# The time massaging regexes start with ^[^<]* because that ensures that they +# only operate before the first "<". That "<" will be the beginning of the +# author name, ensuring that we don't destroy anything in the commit message +# that looks like time. +# +# The log format uses } characters between each field, and `column` is later +# used to split on them. A } in the commit subject or any other field will +# break this. + +HASH="%C(yellow)%h%Creset" +RELATIVE_TIME="%Cgreen(%ar)%Creset" +AUTHOR="%C(bold blue)<%an>%Creset" +REFS="%C(red)%d%Creset" +SUBJECT="%s" + +FORMAT="$HASH}$RELATIVE_TIME}$AUTHOR}$REFS $SUBJECT" + +show_git_head() { + pretty_git_log -1 + git show -p --pretty="tformat:" +} + +pretty_git_log() { + git log --graph --pretty="tformat:${FORMAT}" $* | + # Replace (2 years ago) with (2 years) + sed -Ee 's/(^[^<]*) ago)/\1)/' | + # Replace (2 years, 5 months) with (2 years) + sed -Ee 's/(^[^<]*), [[:digit:]]+ .*months?)/\1)/' | + # Line columns up based on } delimiter + column -s '}' -t | + # Page only if we need to + less -FXRS +} + diff --git a/install.sh b/install.sh index 53c778b..10a7d7b 100755 --- a/install.sh +++ b/install.sh @@ -21,7 +21,7 @@ fi ROOT=`pwd` ### -# bash_magic +# bash ### #clone repo $GIT clone https://github.com/Knewton/bash_magic.git bash/bash_magic @@ -47,6 +47,17 @@ if [ ! -f "${HOME}"/.bashrc ]; then ln -s "${HOME}"/.bash_profile "${HOME}"/.bashrc fi +### +# git +### +echo -n "Enter your git name: " +read NAME +echo -n "Enter you git email: " +read EMAIL +echo -e "[user]\n\tname = ${NAME}\n\temail = ${EMAIL}" > "${HOME}"/.gitconfig +cat git/gitconfig >> "${HOME}"/.gitconfig +cp git/githelpers "${HOME}"/.githelpers + ### # vim ###