-
Notifications
You must be signed in to change notification settings - Fork 7
/
.bashrc
192 lines (155 loc) · 4.74 KB
/
.bashrc
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# .bashrc is sourced for an interactive shell.
#echo .bashrc
# For some reason, openssh invokes bash as an interactive shell even if we
# are only using scp. Therefore check that we have a terminal before processing
# this file
if test -n "$SSH_CONNECTION"; then
tty -s || return
fi
shopt -s cdspell
shopt -s histverify
shopt -s no_empty_cmd_completion
alias grep="/usr/bin/grep $GREP_OPTIONS"
unset GREP_OPTIONS
export EDITOR=vim
if test -n "$DISPLAY"
then
BROWSER=gnome-open
else
BROWSER=w3m
fi
export BROWSER
export PAGER=less
command -v lesspipe &>/dev/null && eval "$(lesspipe)"
# see termcap(5) for an explanation of these codes
export LESS_TERMCAP_mb='\033[01;31m' # start blink
export LESS_TERMCAP_md=$'\E[0;31m' # start bold
export LESS_TERMCAP_me=$'\E[0m' # back to normal
export LESS_TERMCAP_so=$'\E[0;44;33m' # start standout (status line)
export LESS_TERMCAP_se=$'\E[0m' # end standout
export LESS_TERMCAP_us=$'\E[0;32m' # start underline
export LESS_TERMCAP_ue=$'\E[0m' # end underline
command -v dircolors >/dev/null && eval "$(dircolors -b)"
if test -f /etc/bash_completion.d/git; then
source /etc/bash_completion.d/git
elif test -f ~/.git-completion.bash; then
source ~/.git-completion.bash
elif test -f /opt/local/share/doc/git-core/contrib/completion/git-completion.bash; then
source /opt/local/share/doc/git-core/contrib/completion/git-completion.bash
elif test -f /usr/local/git/contrib/completion/git-completion.bash; then
# Darwin only?
source /usr/local/git/contrib/completion/git-completion.bash
source /usr/local/git/contrib/completion/git-prompt.sh
fi
source ~/.git-prompt.sh
if test -f $HOME/.bash_completion; then
source $HOME/.bash_completion
fi
# best prompt ever!
#
function smile {
if test $? = 0; then
printf "${csi_green}:)"
else
printf "${csi_red}:("
fi
}
function user_colour {
if test "$UID" = 0; then
printf "${csi_red}"
else
printf "${csi_green}"
fi
}
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
csi='\033['
csi_default=${csi}0m
csi_cyan=${csi}36m
csi_green=${csi}32m
csi_red=${csi}31m
csi_gold=${csi}33m
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWUPSTREAM=verbose
PS1="\n\$(smile) ${csi_cyan}\A $(user_colour)\u@\h ${csi_gold}\w${csi_default} \$(type -t __git_ps1 >/dev/null && __git_ps1 '(%s)')\n\\$ "
HISTCONTROL=ignoreboth
HISTSIZE=5000
# xterm/screen title
#
case "$TERM" in
xterm*|rxvt*|screen)
# http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
PROMPT_COMMAND='printf "\033]0;${HOSTNAME%%.*}:${PWD/#$HOME/~}\a"'
;;
esac
function gvimcpp {
gvim $1.cpp "+new $1.h"
}
function envof {
file=/proc/${1:?Usage: $0 pid}/environ
cmd="cat $file"
test -r $file || cmd="sudo $cmd"
$cmd | tr '\0' '\n' | cat -v
}
function physize {
echo $(( $(stat -c '%B * %b' "$1") / 1024 )) "$1"
}
function block {
sudo iptables -I OUTPUT -d "$1" -j DROP
}
function app_release {
git fetch origin master
git checkout -B release origin/master
poetry update && poetry export -f requirements.txt --without-hashes -o requirements.txt
git add poetry.lock requirements.txt && git commit -m"fix: update lock and requirements files"
VERSION=$(cz bump --changelog --annotated-tag)
git push -o merge_request.create -o merge_request.remove_source_branch --force --follow-tags --set-upstream origin release
echo "New $VERSION"
}
function dotfiles_release {
git fetch origin master
git checkout -B release origin/master
VERSION=$(cz bump --changelog --annotated-tag)
git push -o merge_request.create -o merge_request.remove_source_branch --force --follow-tags --set-upstream origin release
echo "New $VERSION"
}
if [ -f "$HOME/.bash_aliases" ]; then
source ~/.bash_aliases
fi
if [ -f "$HOME/.machine_aliases" ]; then
source "$HOME/.machine_aliases"
fi
command -v gvfs-open &>/dev/null && alias open=gvfs-open
if test -z "$CLICOLOR"; then
alias cgrep='grep --color --context=9999999'
alias ls='ls --color=auto'
fi
# stuff to tell the user....
export PATH=~/bin:$PATH
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm use
export PATH=$PATH:$HOME/.local/bin
export PATH=/usr/local/bin:$PATH
export PATH=$HOME/.node/bin:$PATH
export PATH=~/.npm-global/bin:$PATH
# kick ssh-agent and load key
# from https://unix.stackexchange.com/a/217223
if [ ! -S ~/.ssh/ssh_auth_sock ]; then
eval `ssh-agent`
ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
fi
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
ssh-add -l > /dev/null || ssh-add
# say hello Riff!
fortune
# last thing, run machine specific config
if [ -f "$HOME/.machinerc" ]; then
source "$HOME/.machinerc"
fi
. "$HOME/.cargo/env"