Skip to content

Instantly share code, notes, and snippets.

@smathy
Forked from marioBonales/gh.sh
Created October 7, 2011 00:47
Show Gist options
  • Save smathy/1269148 to your computer and use it in GitHub Desktop.
Save smathy/1269148 to your computer and use it in GitHub Desktop.
#!/bin/sh
current_git_branch() {
git_exists=`git branch 2>/dev/null | sed -ne'/^\* /s///p'`
if [[ "$git_exists" != "" ]]; then
if [[ "$git_exists" == "(no branch)" ]]; then
git_exists="\e[31m\]$git_exists\e[0m\]"
fi
echo "$git_exists "
fi
unset git_exists
}
extra="$1"
if [[ "$extra" == "" ]]; then
extra=$(current_git_branch)
else
extra=$(git rev-parse $1)
fi
extra="/commits/$extra"
open `git config -l | sed -En 's/remote.origin.url=git(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\3\/\4/p'`$extra
@smathy
Copy link
Author

smathy commented Oct 7, 2011

Added the current_git_branch code inline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment