Skip to content

Instantly share code, notes, and snippets.

@mattvagni
Last active June 5, 2017 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattvagni/980a765b3c0b3639dc5e9e6d32b11f6e to your computer and use it in GitHub Desktop.
Save mattvagni/980a765b3c0b3639dc5e9e6d32b11f6e to your computer and use it in GitHub Desktop.
ma bash_profile
#-------------------------------------------------------------------------------
# Make the default prompt with our custom colors
#-------------------------------------------------------------------------------
BLACK=$(tput setaf 0)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
MAGENTA=$(tput setaf 5)
CYAN=$(tput setaf 6)
WHITE=$(tput setaf 7)
BOLD=$(tput bold)
RESET=$(tput sgr0)
function git_info ()
{
local b="$(git symbolic-ref HEAD 2>/dev/null)";
local dirty=$(git diff --quiet --ignore-submodules HEAD &>/dev/null; [ $? -eq 1 ]&& echo -e "*")
if [ -n "$b" ]; then
printf "$RESET%s $YELLOW\e[3m%s$RED%s" "on" "${b##refs/heads/}" "${dirty}";
fi
}
PS1="\n\n\[\$BLUE\w\] \$(git_info)\n\[\$RESET\]$ \[\$RESET\]"
#-------------------------------------------------------------------------------
# Autocompletion
# https://github.com/bobthecow/git-flow-completion/wiki/Install-Bash-git-completion
#-------------------------------------------------------------------------------
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
#-------------------------------------------------------------------------------
# Open PR
#-------------------------------------------------------------------------------
# Open pull request
function currepo() {
git config --get remote.origin.url | sed 's/.*@\(.*\)/\1/' | sed 's/\(.*\):\(.*\)/\1\/\2/' | sed 's/\(.*\)\.git/\1/';
}
function curbranch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/';
}
#-------------------------------------------------------------------------------
# Make sure history show timestamps.
#-------------------------------------------------------------------------------
export HISTTIMEFORMAT="%d.%m.%y %T "
#-------------------------------------------------------------------------------
# Aliases
#-------------------------------------------------------------------------------
alias ls="ls -1Gha"
alias c="clear"
alias gg="git grep --full-name --break --heading --line-number"
alias clean-branches="git branch --merged | grep -v '^* master$' | grep -v '^ master$' | xargs git branch -d"
alias openpr="open https://\`currepo\`/pull/new/\`curbranch\`"
alias refresh="source ~/.bash_profile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment