-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdot_bashrc
More file actions
177 lines (145 loc) · 6.42 KB
/
dot_bashrc
File metadata and controls
177 lines (145 loc) · 6.42 KB
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
#!/bin/bash
# /etc/skel/.bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen !
# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi
# enable vi mode in bash
set -o vi
# fix issue with ctrl-l not clearing screen in bash vi mode
bind -m vi-insert "\C-l":clear-screen
# If above doesn't work, try
# bind -m vi-command 'Control-l: clear-screen'
# bind -m vi-insert 'Control-l: clear-screen'
HISTCONTROL=ignoreboth:erasedups
export MAKEOPTS="--jobs 2 --load-average 5"
export GOSUMDB="sum.golang.org"
export GOROOT=/usr/lib/go
export GOPATH=~/go
PATH="$HOME/.local/bin:$HOME/.cargo/bin:$GOPATH/bin:$PATH"
PROMPT_DIRTRIM=2
export EDITOR=/usr/bin/vim
GPG_TTY=$(tty)
export GPG_TTY
# https://is.gd/suPdzP
shopt -s histappend
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
# Put your fun stuff here.
# Fix long line wrapping issues: https://askubuntu.com/questions/111840/ps1-problem-messing-up-cli
# https://askubuntu.com/questions/251154/long-lines-overlap-in-bash-ps1-customized-prompt
txtcyn=$'\e[36m' #cyan
txtgrn=$'\e[32m' #green
txtylw=$'\e[33m' #yellow
txtred=$'\e[31m' #red
Iblu=$'\e[94m' #High Intensity Blu
Icyn=$'\e[96m' #High Intensity Cyan
txtdarkgrey=$'\e[90m'
reset=$'\e[m'
# . ~/.vim/bundle/powerline/powerline/bindings/bash/powerline.sh
# export POWERLINE_CONFIG_COMMAND=$HOME/.vim/bundle/powerline/scripts/powerline-config
if [[ -f /usr/bin/virtualenvwrapper.sh ]]; then
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/development/python
# shellcheck disable=SC1094,SC1091
source /usr/bin/virtualenvwrapper.sh
fi
if [[ -f /usr/bin/bat ]]; then
alias cat="/usr/bin/bat --theme 'Solarized (dark)'"
fi
gitPrompt() {
BASENAME=$(basename "$(pwd)")
if [[ $BASENAME != '.git' ]]; then
gitrepo=$(git rev-parse --is-inside-work-tree 2>/dev/null)
fi
if [ "$gitrepo" ]; then
branch="$(git branch -a | awk '/\*/ {print $2 }')"
stats_ut="$(git status --porcelain 2>/dev/null | grep -c "^??" )"
stats_fc="$(git diff --stat HEAD 2>/dev/null | tail -n-1 | sed -r 's/[[:alpha:] ()]+//g'| cut -d ',' -f1)"
stats_fc="${stats_fc:-0}"
stats_la="$(git diff --stat HEAD 2>/dev/null | tail -n-1 | grep -ioP '(\d+) insertion*' | cut -d ' ' -f1)"
stats_la="${stats_la:-0}"
stats_lr="$(git diff --stat HEAD 2>/dev/null | tail -n-1 | grep -ioP '(\d+) deletion*' | cut -d ' ' -f1)"
stats_lr="${stats_lr:-0}"
if [[ "${GIT_PROMPT_EMAIL}" != "disable" ]]; then
domain="$(git config --get user.email)"
fi
# shellcheck disable=SC2059
# If I follow the suggestion of the above SC, it will break PS1 and cause weird wrap arround
# issues when going up and down in the bash history
if (( $(tput -T "$TERM" colors) >= 8 )); then
if [ "$(git status | grep -ic 'clean$')" = 1 ]; then
printf "\001${reset}\002($branch \001${txtgrn}\002✔\001${reset}\002) \001${txtdarkgrey}\002$domain\001${reset}\002"
else
if [ "$(git status | grep -ic 'unstage')" = 1 ]; then
printf "\001${reset}\002(${stats_ut}:\001${txtylw}\002$stats_fc\001${reset}\002:\001${txtgrn}\002$stats_la\001${reset}\002:\001${txtred}\002$stats_lr\001${reset}\002 $branch \001${txtylw}\002⬖\001${reset}\002) \001${reset}\002\001${txtdarkgrey}\002$domain\001${reset}\002"
else
printf "\001${reset}\002(${stats_ut}:\001${txtylw}\002$stats_fc\001${reset}\002:\001${txtgrn}\002$stats_la\001${reset}\002:\001${txtred}\002$stats_lr\001${reset}\002 $branch \001${txtred}\002✗\001${reset}\002) \001${reset}\002\001${txtdarkgrey}\002$domain\001${reset}\002"
fi
fi
else
if [ "$(git status | grep -ic 'clean$')" = 1 ]; then
echo -en "$domain ($branch)"
else
if [ "$(git status | grep -ic 'unstage')" = 1 ]; then
echo -en "($stats_ut:$stats_fc:$stats_la:$stats_lr $branch !)"
else
echo -en "($stats_ut:$stats_fc:$stats_la:$stats_lr $branch X)"
fi
fi
fi
fi
}
if (( $(tput -T "$TERM" colors) >= 8 )); then
export PS1="⮦\[${Iblu}\][\[${txtcyn}\]\u\[${Iblu}\]@\[${txtgrn}\]\h\[${Icyn}\] \w\[${Iblu}\]]\[${reset}\]\\n⮡\$(gitPrompt)\[${Iblu}\] \\$ \[${reset}\]"
else
export PS1="[\u@\h \w ]\$(gitPrompt) \\$ "
fi
if [[ $(grep '^ID=' /etc/os-release | cut -d'=' -f2 | tr -d "'") = 'gentoo' ]]; then
alias nudav="sudo emerge -NuDav @world"
alias nudavr="sudo emerge -NuDav @world || until sudo emerge --skipfirst; do :; done"
alias nudv="sudo emerge -NuDv @world || until sudo emerge --resume --skipfirst; do :; done"
fi
alias gitbbd='for branch in `git branch -r | grep -iv head`; do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r'
alias ls='ls --color=auto'
alias l='eza -la --group-directories-first --icons --git --color-scale=size'
alias k='kubecolor'
complete -o default -F __start_kubectl k
alias kgp='k get pods -A'
alias kgn='k get nodes -A'
alias kgd='k get deployments -A'
alias kgs='k get svc -A'
alias kgr='k get rs -A'
alias kge='k get ev -A'
alias sudo='sudo -E '
alias vim='nvim'
alias mandom="man \`find /usr/share/man -type f | shuf | head -1\`"
alias mount="mount | column -t"
alias ctop="docker run --rm -ti \
--name=ctop \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
quay.io/vektorlab/ctop:latest"
KERNEL=$(uname -a)
if [[ "$KERNEL" =~ "Microsoft" ]]; then
export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
if [[ "$PATH" =~ "VirtualBox" ]]; then
:
else
export PATH="$PATH:/mnt/c/Program Files/Oracle/VirtualBox"
fi
fi
if [[ -f $HOME/.workrelated ]]; then
#shellcheck disable=SC1091
source "$HOME/.workrelated"
fi
eval "$(direnv hook bash)"
export NVM_DIR="$HOME/.config/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