Skip to content

Instantly share code, notes, and snippets.

@danramteke
Last active October 21, 2015 15:14
Show Gist options
  • Save danramteke/3658683 to your computer and use it in GitHub Desktop.
Save danramteke/3658683 to your computer and use it in GitHub Desktop.
useful bash configurations
RED="\033[0;31m"
YELLOW="\033[0;33m"
GREEN="\033[0;32m"
NO_COLOUR="\033[0m"
function parse_git_branch () {
git status -b --porcelain 2> /dev/null | head -1 | sed -e 's/## //' -e 's/\.\.\..*//'
}
function parse_git_color () {
if [ -n "`git status --porcelain 2>&1 | grep "fatal: Not a git repository"`" ]
then
echo -e "$NO_COLOUR"
elif [ -z "`git status --porcelain 2> /dev/null`" ]
then
echo -e "$GREEN"
elif [ -z "`git status --porcelain 2> /dev/null | grep -v -E "^[MARCD] .*$"`" ]
then
echo -e "$YELLOW"
else
echo -e "$RED"
fi
}
function parse_git_status () {
if [ -n "`git status --porcelain 2>&1 | grep "fatal: Not a git repository"`" ]
then
echo -e ""
elif [ -z "`git status --porcelain 2> /dev/null`" ]
then
echo -e "(`parse_git_branch`)"
elif [ -z "`git status --porcelain 2> /dev/null | grep -v -E "^[MARCD] .*$"`" ]
then
echo -e "{`parse_git_branch`}"
else
echo -e "<`parse_git_branch`>"
fi
}
export PS1="\[$GREEN\]\t\[$NO_COLOUR\]:\w \[\$(parse_git_color)\]\$(parse_git_status)\[$NO_COLOUR\]\$ "
[user]
email = [email protected]
name = Daniel R
[alias]
st = status
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
pr = pull --rebase
rso = remote show origin
[
{ "keys": ["super+shift+c"], "command": "copy_path" },
{ "keys": ["super+shift+1"], "command": "reveal_in_side_bar"},
{ "keys": ["super+alt+l"], "command": "reindent", "args": {"single_line": false}}
]
{
"color_scheme": "Packages/Color Scheme - Default/Monokai Bright.tmTheme",
"draw_white_space": "selection",
"trim_trailing_white_space_on_save": true,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"save_on_focus_lost": true,
"highlight_line": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment