Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- profile
- export NVM_DIR="$HOME/.nvm"
- [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
- if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
- . `brew --prefix`/etc/bash_completion.d/git-completion.bash
- fi
- COLOR_RED="\033[0;31m"
- COLOR_YELLOW="\033[0;33m"
- COLOR_GREEN="\033[0;32m"
- COLOR_OCHRE="\033[38;5;95m"
- COLOR_BLUE="\033[0;34m"
- COLOR_WHITE="\033[0;37m"
- COLOR_RESET="\033[0m"
- function git_color {
- local git_status="$(git status 2> /dev/null)"
- if [[ ! $git_status =~ "working tree clean" ]]; then
- echo -e $COLOR_RED
- elif [[ $git_status =~ "Your branch is ahead of" ]]; then
- echo -e $COLOR_YELLOW
- elif [[ $git_status =~ "nothing to commit" ]]; then
- echo -e $COLOR_GREEN
- else
- echo -e $COLOR_OCHRE
- fi
- }
- function git_branch {
- local git_status="$(git status 2> /dev/null)"
- local on_branch="On branch ([^${IFS}]*)"
- local on_commit="HEAD detached at ([^${IFS}]*)"
- if [[ $git_status =~ $on_branch ]]; then
- local branch=${BASH_REMATCH[1]}
- echo "($branch) "
- elif [[ $git_status =~ $on_commit ]]; then
- local commit=${BASH_REMATCH[1]}
- echo "($commit) "
- fi
- }
- PS1="\[$COLOR_WHITE\]\u | \W " # basename of pwd
- PS1+="\[\$(git_color)\]" # colors git status
- PS1+="\$(git_branch)" # prints current branch
- PS1+="\[$COLOR_RESET\]$ " # '#' for root, else '$'
- export PS1
- mergepush() {
- currentb="$(git rev-parse --abbrev-ref HEAD)"
- echo "Merge and push $currentb -> $1? (enter to continue)"
- read -s -n 1 key # -s: do not echo input character. -n 1: read only 1 charac$
- if [[ $key = "" ]]; then
- git checkout $1 && git merge $currentb && git push && git checkout $currentb
- else
- [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell$
- fi
- }
- rc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement