-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.bash_profile
71 lines (60 loc) · 1.87 KB
/
.bash_profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Navigation
alias ll="ls -l"
alias lla="ls -la"
alias ..="cd .."
alias ...="cd ../.."
# Git
alias g="git"
alias gs="git status "
alias ga="git add "
alias gb="git branch "
alias gc="git commit "
alias gd="git diff "
alias go="git checkout "
# Bundler
alias b="bundle"
alias be="bundle exec "
# allows local installations of node packages without using symlinks
function install-local {
npm install $(npm pack $1 | tail -1)
}
# Bash prompt
function parse_git_branch {
git rev-parse --git-dir &> /dev/null
git_status="$(git status 2> /dev/null)"
branch_pattern="^On branch ([^${IFS}]*)"
ahead_pattern="Your branch is ahead of"
behind_pattern="Your branch is behind"
staged_pattern="Changes to be committed"
unstaged_pattern="Changes not staged for commit"
untracked_pattern="Untracked files"
diverge_pattern="Your branch and (.*) have diverged"
if [[ ${git_status}} =~ ${staged_pattern} ]]; then state+="${YELLOW}*"; fi
if [[ ${git_status}} =~ ${unstaged_pattern} ]]; then state+="${GREEN}*"; fi
if [[ ${git_status}} =~ ${untracked_pattern} ]]; then state+="${CYAN}*"; fi
if [[ ${git_status} =~ ${ahead_pattern} ]]; then remote="${CYAN}↑"
elif [[ ${git_status} =~ ${behind_pattern} ]]; then remote="${CYAN}↓"
elif [[ ${git_status} =~ ${diverge_pattern} ]]; then remote="${RED}↕"; fi
if [[ ${git_status} =~ ${branch_pattern} ]]; then
branch=${BASH_REMATCH[1]}
echo "$YELLOW:$branch$remote$state"
fi
}
function prompt_func() {
PS1="$RED\$(date +%H:%M) \w$(parse_git_branch)$YELLOW\$ $NO_COLOUR"
}
PROMPT_COMMAND=prompt_func
# Colours
CYAN="\[\033[0;36m\]"
PURPLE="\[\033[0;35m\]"
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
BLUE="\[\033[0;34m\]"
GREEN="\[\033[0;32m\]"
NO_COLOUR="\[\033[0m\]"
# 256 Colour Stuff for Vim/Tmux
export TERM='screen-256color'
#Editor set to vim
export EDITOR=vim
# turn on garbage collection
export DGC=true