add sha, which-branch to gitconfig. add is_ssh.

This commit is contained in:
Ivan Malison 2014-04-13 22:47:40 -07:00
parent 56342141da
commit 322f862e76
4 changed files with 18 additions and 4 deletions

@ -1 +1 @@
Subproject commit a026244b86416f3ef7137b915cb1699ad1d977f0
Subproject commit d5cb80db68136a0b09000ba56210265abc163b58

View File

@ -15,9 +15,15 @@
reb = "!r() { git rebase -i HEAD~$1; }; r"
suir = submodule update --init --recursive
poh = push origin HEAD
pohm = push origin HEAD:master
# Diff a file or show it in git's pager if it is untracked
du = "!d() { git ls-files $1 --error-unmatch 2>/dev/null 1>/dev/null && git diff $1 || `git config --get core.pager` $1; }; d"
which-branch = symbolic-ref HEAD --short
sha = rev-parse HEAD
branch-or-sha = "!bs() { git which-branch 2> /dev/null || git sha 2> /dev/null ; }; bs"
amend = commit -a --amend -C HEAD
reset-origin = "r() {git reset --hard origin/$(git symbolic-ref HEAD); git suir}"
reset-origin = "!r() { git reset --hard origin/\"$(git parse-branch)\" && git suir; }; r"
[core]
# Use custom `.gitignore` and `.gitattributes`
@ -59,4 +65,4 @@
name = Ivan Malison
[merge]
conflictstyle = diff3
conflictstyle = diff3

View File

@ -85,3 +85,11 @@ function digga() {
function shell_stats() {
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
}
function is_ssh() {
p=${1:-$PPID}
read pid name ppid < <(ps -o pid= -o comm= -o ppid= -p $p)
[[ "$name" =~ sshd ]] && { echo "Is SSH : $pid $name"; return 0; }
[ "$ppid" -le 1 ] && { echo "Adam is $pid $name"; return 1; }
is_ssh $ppid
}

View File

@ -4,7 +4,7 @@ function current_directory() {
}
function git_prompt_info() {
if test -z $(parse_git_branch);
if test -z $(git branch-or-sha);
then
echo ""
else