-
Notifications
You must be signed in to change notification settings - Fork 0
/
Master.bash_profile
150 lines (130 loc) · 4.48 KB
/
Master.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#Creator: Yuri Costa
#Contributors:
#June.2017
#github.com/yuric/bash_profile,
#This code is released under the AGPLv3 license.
#Reach out if you have questions/comments.
echo "................... sourcing ~/.bash_profile as $USER at $(hostname)"
if [ -f ~/.profile ]
then
source ~/.profile
source /usr/local/bin/virtualenvwrapper.sh
else
echo "WARNING: Missing source files. Check .bash_profile."
fi
set completion-ignore-case on
set show-all-if-ambiguous on
TAB: menu-complete
#Currently on ruby and python virtual envs will be loaded
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
source "$rvm_path/contrib/ps1_functions"
export PATH="/usr/local/bin:$PATH"
PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.6/bin
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile"
# Load git completions
git_completion_script=/usr/local/etc/bash_completion.d/git-completion.bash
test -s $git_completion_script && source $git_completion_script
# A more colorful prompt
# \[\e[0m\] resets the color to default color
# \e[0;32m\ sets the color to green
# \e[0;31m\ sets the color to red
c_reset='\[\e[0m\]'
c_git_clean='\[\e[0;32m\]'
c_git_dirty='\[\e[0;31m\]'
RED="\033[0;31m"
YELLOW="\033[0;33m"
GREEN="\033[0;32m"
CYAN="\033[0;36m"
NO_COLOUR="\[\033[0m\]"
DIM="\e[2m"
#RESET_DIM="\e[22m"
# PS1 is the variable for the prompt you see everytime enter is hit
PROMPT_COMMAND='PS1="${NO_COLOUR}[\t]\w$(py_env_and_stash)$(rvm_env_set)$(git_prompt):$ "'
export PROMPT_COMMAND
# Force grep to always use the color option and show line numbers
export GREP_OPTIONS='--color=always'
export EDITOR="/usr/local/bin/mate -w"
#exposes python virtual virtual env name
python_env ()
{
venv="${VIRTUAL_ENV##*/}"
echo " ${DIM}${venv:0:1}${venv:3:1}-${venv: -3}"
}
#exposes python virtual virtual env name
rvm_env_set ()
{
rvm_env=`rvm-prompt i v p g`
#echo " ${DIM}${rvm_env:0:1}${rvm_env:3:1}-${rvm_env: -3}"
echo " ${DIM}${rvm_env}${c_reset}"
}
# Returns python virtual env and "|shashed:N" where N is the number of stashed states (if any).
py_env_and_stash ()
{
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
#determine "|shashed:N" where N is the number of stashed states (if any).
stash=`expr $(git stash list 2>/dev/null| wc -l)`
#determine Python vertual env if vailable
py_env=$(python_env)
if [ "$stash" != "0" ]
then
echo "$py_env|stashed:$stash${c_reset}"
else
echo "$py_env${c_reset}"
fi
}
# determines if the git branch is clean or dirty
git_prompt ()
{
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
# Grab working branch name
git_branch=$(Git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
#grab stashes if any
untracked_files=`expr $(git ls-files --others --exclude-standard 2>/dev/null| wc -l)`
# determines if the git branch has untracked files not on .gitignore
if [ "$untracked_files" != "0" ]
then
git_color=${RED}
uc="@untracked:$untracked_files"
fi
# Clean or dirty branch
if git diff --quiet 2>/dev/null >&2; then
git_color="${c_git_clean}"
else
git_color=${CYAN}
fi
echo "[$git_color$git_branch$uc${c_reset}]"
}
# search for LSCOLORS
export LSCOLORS=ExGxFxdxCxDxDxaccxaeex
# Force ls to use colors (G) and use humanized file sizes (h)
alias ls="ls -Gh -a -l -p"
alias run='python manage.py runserver_plus'
alias pcollect="python manage.py collectstatic"
alias pdb="python manage.py dbshell"
alias pmigrate="python manage.py migrate"
alias ptest="python manage.py test"
alias boot="source ~/.bash_profile"
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias envp="bash -c \"set -o posix; set | sed -e '/^_/,\\\$d';\""
alias lrs="cd Documents/Developer/ADL_LRS"
alias remove='rm -i'
alias move='mv -i'
#alias env="set -o posix ; set)
#du -cksh * |sort -rn |head -11
# Overwritting so the projects python environement is loaded when entering directory. Requires profile_settings.bash. Get it here => github.com/yuric/bash_profile. Feel free to PR
# improments. All here is a a sketch in my mind. Commented out because I am not deving in multiple python environments on the time of this writting.
# cd () { builtin cd "$@" && chpwd; }
# pushd () { builtin pushd "$@" && chpwd; }
# popd () { builtin popd "$@" && chpwd; }
#
# chpwd () {
# echo $PWD
# case $PWD in
# /Users/ycosta3987/Documents/Developer/ADL_LRS)
# . project_settings.bash;;
# esac
# }