-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc.patch
152 lines (128 loc) · 4.09 KB
/
.bashrc.patch
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
151
152
#### ADDED BY /home/vagrant/dotfiles/install.sh ####
# Terminal colors
RESETCOLOR='\033[0m'
RED='\033[00;31m'
GREEN='\033[00;32m'
YELLOW='\033[00;33m'
BLUE='\033[00;34m'
PURPLE='\033[00;35m'
CYAN='\033[00;36m'
LGRAY='\033[00;37m'
LRED='\033[01;31m'
LGREEN='\033[01;32m'
LYELLOW='\033[01;33m'
LBLUE='\033[01;34m'
LPURPLE='\033[01;35m'
LCYAN='\033[01;36m'
WHITE='\033[01;37m'
# pyenv
if [ -d "$HOME/.pyenv" ]
then
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH"
eval "$($PYENV_ROOT/bin/pyenv init -)"
fi
# cargo
if [ -d "$HOME/.cargo" ]
then
export PATH="$HOME/.cargo/bin:$PATH"
fi
# User specific aliases and functions
# package history, useful for tracking customizations in Vagrant
alias apt-history="grep -i \"commandline\" /var/log/apt/history.log"
# Elegant definitions file
export RPN_DEFNS="$DOTFILES_DIR/elegant_defns.rpn"
# Show PEP 20, the Zen of Python
alias zen='python3 -m this'
# For working with zestyping's Python lib `q`
alias q='rm -f /tmp/q && tail -F /tmp/q'
# Run the specified command and beep when it's done
function beep {
"$@"
for i in {1..3}; do echo -e "\a"; sleep 0.25; done
}
bind 'set bell-style none' # disable the bell when using tab completion
# For quickly grabbing the newest or oldest files with `ls`
function newest {
ls "$@" --sort=time | head -1
}
function oldest {
ls "$@" --sort=time | tac | head -1
}
function irclog() {
usage="irclog -- helper function to search IRC logs. Passes all flags to ag. Use -G mask to search against a glob"
if [ -z "$1" ]
then
echo $usage;
return;
fi
local OPTIND opt a
while getopts ":h" opt; do
case $opt in
h)
echo "$usage"
return
;;
esac
done
ag -i "$@" ~/irclogs;
}
# Run OPAL but save the output to a timestamped logfile. Display all
# warnings/errors at the end of the run to save the user some scrolling
function run_opal() {
if hash opal 2>/dev/null; then
LOGFILE="opal$(date -I).log"
$(which opal) "$@" 2>&1 | tee $LOGFILE;
echo
echo checking $LOGFILE for warnings or errors now...
echo
grep -iE -A3 "warning|error" $LOGFILE;
else
echo -en $RED
echo 'cannot find OPAL, did you source opal.sh?'
echo -en $RESETCOLOR
fi
}
alias opal='run_opal'
# shortcut for searching running processes
function psg() {
ps aux | grep -i $*
}
# Git-aware prompt (if available)
if command -v git >/dev/null 2>&1; then
# A git-aware prompt
export GIT_PS1_SHOWCOLORHINTS=true
export GIT_PS1_SHOWDIRTYSTATE=true
CWD="$YELLOW\w$RESETCOLOR"
export PROMPT_COMMAND='__git_ps1 "\A [\u@\h $CWD" "]\n\$ "'
else
export PS1='\A [\u \W]\$ '
fi
# evaluate direnv hook, if present
if command -v direnv >/dev/null 2>&1; then
eval "$(direnv hook bash)"
fi
# don't ever open a GUI to ask for SSH credentials
unset SSH_ASKPASS
# Courtesy of StackOverflow user Pablo R. https://unix.stackexchange.com/a/1292
# Avoid duplicates
export HISTCONTROL=ignoredups:erasedups
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend
# After each command, append to the history file and reread it
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"
# for checking COMSOL on harrison
export COMSOLDIR=/apps/comsol/4.3a/COMSOL43a/
function whoisusingcomsol() {
$COMSOLDIR/license/glnxa64/lmstat -c $COMSOLDIR/license/license.dat -f
}
# Try to fetch updates if it's been longer than a day since the last attempt
dotfiles_update_dt=$((($(date +%s) - $(stat -c %Y $DOTFILES_DIR/.git/FETCH_HEAD)) / 60 / 60 / 24))
if [ $dotfiles_update_dt -gt 1 ]; then
printf $YELLOW
echo "$dotfiles_update_dt days since dotfiles update was fetched, pulling..."
printf $RESETCOLOR
[ -d "$DOTFILES_DIR/.git" ] && git --work-tree="$DOTFILES_DIR" --git-dir="$DOTFILES_DIR/.git" pull origin master
fi
source "$DOTFILES_DIR/git-prompt.sh"
#export PYTHONPATH="$PYTHONPATH:$DOTFILES_DIR/recipes"