-
Notifications
You must be signed in to change notification settings - Fork 4
/
bashrc
124 lines (112 loc) · 3.92 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
#!/bin/bash
### Setting variables
export EDITOR="nvim"
export LC_ALL="en_US.UTF-8"
export LANGUAGE="en_US.UTF-8"
export LANG="en_US.UTF-8"
export TERM="xterm-256color"
export HISTCONTROL="ignorespace"
export CLICOLOR="1"
export LSCOLORS="gxBxhxDxfxhxhxhxhxcxcx"
# Set bash prompt
blue='\[\e[1;34m\]'
red='\[\e[1;31m\]'
yellow='\[\e[1;33m\]'
magentabackground='\[\e[1;45m\]'
reset='\[\e[0m\]'
if [[ "$(hostname)" == *"personal"* ]] || [[ "$(uname)" == "Darwin" ]] || [[ "$(hostname)" == *"desktop"* ]]; then
PS1="${blue}\u${red}@${yellow}\h${red} \w \$ ${reset}"
else
PS1="${blue}\u${red}@${yellow}${magentabackground}\h${reset}${red} \w \$ ${reset}"
fi
### Assorted aliases
function path() { echo "$PATH" | tr ':' '\n'; }
alias grep='grep --color=auto'
oports() { echo 'User: Command: Port:'; echo '----------------------------' ; lsof -i 4 -P -n | grep -i 'listen' | awk '{print $3, $1, $9}' | sed 's/ [a-z0-9\.\*]*:/ /' | sort -k 3 -n |xargs printf '%-10s %-10s %-10s\n' | uniq; }
alias mem="printf '\033[?7l' && ps aux | sed -n 1p && ps aux | tail -n +2 | sort -brnk 4 | head -n 20 && printf '\033[?7h'"
alias cpu="printf '\033[?7l' && ps aux | sed -n 1p && ps aux | tail -n +2 | sort -brnk 3 | head -n 20 && printf '\033[?7h'"
alias sudo='sudo '
alias fucking='sudo'
alias scp="rsync"
alias rsync='rsync -vazhP'
alias alert='echo -e "\a"'
alias diff='icdiff'
alias tree='tree -C'
alias du='du -h'
alias mkdir='mkdir -p'
alias myip='myipv4'
alias myipv4='curl --silent http://ip4only.me/api/ | cut -d',' -f2'
alias myipv6='curl --silent http://ip6only.me/api/ | cut -d',' -f2'
function geoip { curl "https://ipinfo.io/$1"; }
export -f geoip
if [[ $(uname) == Linux ]]; then
alias ls='ls --color=always'
fi
alias serve="python3 -m http.server"
alias gosymlink='cd "$(realpath "$(pwd)")"'
alias portgrep="sudo ngrep -d any port"
alias apt-get="apt"
alias req-update="~/.dotfiles/scripts/git/req-update/req_update/req_update.py"
if [[ $(uname) == Linux ]]; then
alias portlist="sudo netstat -lntup"
elif [[ $(uname) == Darwin ]]; then
alias portlist="sudo lsof -i -P | grep -i 'listen'"
if [ -f /usr/local/bin/vim ]; then
alias vi=/usr/local/bin/vim
fi
fi
if command -v nvim > /dev/null; then
alias vi=nvim
fi
### Adjusting the PATH
export PATH="$PATH:$HOME/.dotfiles/bin"
# Python
if [[ $(uname) == Darwin ]]; then
# Read brew python
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
fi
source "$HOME/.dotfiles/files/completion/django-completion.sh"
# Go
if command -v go > /dev/null; then
export GOPATH=$HOME/gocode
export PATH="$PATH:/usr/local/go/bin"
export PATH="$PATH:$GOPATH/bin"
fi
# Node
if [ -s "$HOME/.nvm/nvm.sh" ]; then
export NVM_DIR="$HOME/.nvm"
source "$NVM_DIR/nvm.sh"
fi
if command -v npm > /dev/null; then
export PATH="$PATH:node_modules/.bin"
export NODE_OPTIONS=--max_old_space_size=4096
source <(npm completion)
source "$HOME/.dotfiles/files/completion/npx-completion.sh"
fi
# Ruby
# Not using ruby for anything right now
# export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
# [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
# if command -v rbenv > /dev/null; then eval "$(rbenv init -)"; fi
# alias rspec='xvfb-run -a bundle exec rspec'
# CUDA
if [ -d "/usr/local/cuda-11.2/bin/" ]; then
export PATH=/usr/local/cuda-11.2/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
fi
# Terraform
if [ -s "/usr/bin/terraform" ]; then
complete -C /usr/bin/terraform terraform
fi
# Direnv
if command -v direnv > /dev/null; then
eval "$(direnv hook bash)"
show_virtual_env() {
if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then
echo "($(basename "$VIRTUAL_ENV")) "
fi
}
export -f show_virtual_env
PS1='$(show_virtual_env)'$PS1
fi
[[ -r $HOME/.bashrc_local ]] && . ~/.bashrc_local