-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path.bashrc
265 lines (232 loc) · 6.7 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/usr/bin/env bash
export PROMPT_COMMAND="history -a;history -c;history -r;$PROMPT_COMMAND"
SOURCE="${BASH_SOURCE[0]}"
while [[ -h "$SOURCE" ]]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
export dotfiles="${DIR%/bash*}"
export PATH=".git/safe/../../bin"
export PATH=".git/safe/../../script"
export PATH=".git/safe/../../scripts"
export PATH="$PATH:$HOME/.bin"
export PATH="$PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
# Go
export GOPATH=$HOME/Code/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN
# Heroku
export PATH="$PATH:/usr/local/heroku/bin"
# Rust
export PATH="$PATH:$HOME/.cargo/bin"
# Source ~/.localrc if it exists
# shellcheck source=/dev/null
[[ -e "$HOME"/.localrc ]] && . "$HOME"/.localrc
# Base16 Shell (doesn't work in Terminal.app)
if [[ "$TERM" =~ "256" ]] || [[ "$TERM" =~ "kitty" ]] || [[ "$TERM" =~ "screen" ]]; then
BASE16_SHELL="$HOME/.config/base16-shell/"
[ -n "$PS1" ] && [ -s "$BASE16_SHELL/profile_helper.sh" ] && source "$BASE16_SHELL/profile_helper.sh"
fi
# Anybar
anybar() {
if [[ "$1" = 'open' ]]; then
open /Applications/AnyBar.app
fi
printf "%s" "${1:-white}" | nc -4u -w0 localhost "${2:-1738}"
}
# asdf
# For brew version:
# [[ -f "/usr/local/opt/asdf/asdf.sh" ]] && . /usr/local/opt/asdf/asdf.sh
# [[ -f "/usr/local/etc/bash_completion.d/asdf.bash" ]] && . /usr/local/etc/bash_completion.d/asdf.bash
# For manual install
# shellcheck source=/dev/null
[[ -f "$HOME/.asdf/asdf.sh" ]] && . "$HOME/.asdf/asdf.sh"
# shellcheck source=/dev/null
[[ -f "$HOME/.asdf/completions/asdf.bash" ]] && . "$HOME/.asdf/completions/asdf.bash"
# Node path
if [[ -f "$(command -v npm)" ]]; then
export NODE_PATH=$(npm root --quiet -g)
fi
# AWS
if [[ -s "$HOME"/.awsam/bash.rc ]]; then
export AWS_DEFAULT_USER=ubuntu
# shellcheck source=/dev/null
. "$HOME"/.awsam/bash.rc
fi
#ec2-find() {
# aws ec2 describe-instances --filters Name=tag-value,Values=*$1* | grep "$1\|InstanceId" | uniq | sed -e 's/^[ \t\]*//' -e 's/,//g' | paste - -
#}
# Bash Sensible
# shellcheck source=./bash-sensible.bash
[[ -f "$HOME/.config/bash/bash-sensible.bash" ]] && . "$HOME/.config/bash/bash-sensible.bash"
# Browser
export BROWSER=open
alias chrome="/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome"
# Colors
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
MAGENTA="$(tput setaf 5)"
CYAN="$(tput setaf 6)"
WHITE="$(tput setaf 7)"
GRAY="$(tput setaf 8)"
BOLD="$(tput bold)"
UNDERLINE="$(tput sgr 0 1)"
INVERT="$(tput sgr 1 0)"
NOCOLOR="$(tput sgr0)"
export RED
export GREEN
export YELLOW
export BLUE
export MAGENTA
export CYAN
export WHITE
export GRAY
export BOLD
export UNDERLINE
export INVERT
export NOCOLOR
# Completions
# shellcheck source=/dev/null
[[ -f /usr/local/share/bash-completion/bash_completion ]] && . /usr/local/share/bash-completion/bash_completion
# shellcheck source=/dev/null
[[ -f /etc/bash_completion ]] && . /etc/bash_completion
# cowsay
export COWPATH="$dotfiles/system/cows/:/usr/local/Cellar/cowsay/3.04/share/cows/"
alias bunny="cowsay -W 15 -f signbunny"
# ctop
alias ctop="TERM=xterm256-color ctop"
# Editor
if [[ -f "$(command -v nvim)" ]]; then
export EDITOR='nvim'
elif [[ -f "$(command -v vim)" ]]; then
export EDITOR='vim'
else
export EDITOR='vi'
fi
alias e="\$EDITOR"
# FZF
export FZF_DEFAULT_COMMAND='ag -g "" --hidden'
# shellcheck source=/dev/null
[[ -f "$HOME/.fzf.bash" ]] && . "$HOME/.fzf.bash"
# Git
alias g=git
[[ -f "$(command -v hub)" ]] && eval "$(hub alias -s)" && alias g=hub
complete -o default -o nospace -F _git g
alias d='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
# GnuPG
GPG_TTY="$(tty)"
export GPG_TTY
# GPGTools
# export GPG_TTY=$(tty)
# export PINENTRY_USER_DATA="USE_CURSES=1"
# if [[ -n "$SSH_CONNECTION" ]]; then
# export PINENTRY_USER_DATA="USE_CURSES=1"
# fi
# Go
# gotop
alias gotop="TERM=xterm256-color gotop"
# Heroku
alias h='heroku'
# Homebrew
export HOMEBREW_CASK_OPTS="--appdir=/Applications"
if [[ "$(uname -s)" == "Linux" ]]; then
if [[ -d ~/.linuxbrew ]]; then
eval $(~/.linuxbrew/bin/brew shellenv)
elif [[ -d /home/linuxbrew/.linuxbrew ]]; then
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
fi
fi
# Ruby
alias b='bundle'
alias be='bundle exec'
alias bi='bundle install'
alias bu='bundle update'
alias f='foreman'
alias fb='foreman run bundle exec'
alias fr='foreman run'
alias fs='foreman start'
alias r='rake'
# Rust
# System
colours() {
for i in {0..255}; do
printf "%s" "\\x1b[38;5;${i}m${i} "
done
unset i
}
fixaudio() {
sudo killall coreaudiod
}
fixbluetooth() {
sudo killall bluetoothd
}
fixcamera() {
sudo killall VDCAssistant
}
proxy() {
if [[ "$1" ]]; then
# For socks5
# networksetup -setsocksfirewallproxystate Wi-Fi "$1"
networksetup -setsecurewebproxystate Wi-Fi "$1"
networksetup -setwebproxystate Wi-Fi "$1"
fi
local status="$(networksetup -getsecurewebproxy Wi-Fi | grep ^Enabled | cut -f 2 -d ' ')"
if [[ "$status" =~ 'no' ]]; then
anybar black
else
anybar white
fi
echo "$status"
}
publicip() {
curl https://api.ipify.org
}
alias c='caffeinate -d'
alias cta='caffeinate -d tmux at'
alias fliptable='echo (╯°□°)╯︵ ┻━┻'
alias lc='launchctl'
alias ll='ls -al'
alias lock='/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend'
alias reload='. $HOME/.bashrc'
alias sound='afplay /System/Library/Sounds/Glass.aiff'
alias ssh_up='systemsetup -setremotelogin on'
alias ssh_down='systemsetup -setremotelogin off'
source_invision() {
# shellcheck source=/dev/null
. ~/Code/InVision_Docker/scripts-native/invision.sh
}
# Tmux
alias tmux='tmux -2'
if [[ -n "$TMUX" ]]; then
refresh() {
export "$(tmux show-environment | grep '^SSH_AUTH_SOCK')"
}
else
refresh() { exit 1; }
fi
# Vagrant
alias v='vagrant'
# Yarn
alias y='yarn'
# shellcheck source=./prompt.bash
. "$HOME/.config/bash/prompt.bash"
for f in "$HOME/.config/bash/completions/"*; do
# shellcheck source=/dev/null
. "$f"
done
if [ -d /usr/local/etc/bash_completion.d ]; then
for f in "/usr/local/etc/bash_completion.d/"*; do
# shellcheck source=/dev/null
. "$f"
done
fi
# export NVM_DIR="$HOME/.nvm"
# # shellcheck source=/dev/null
# [[ -s "$NVM_DIR/nvm.sh" ]] && . "$NVM_DIR/nvm.sh" # This loads nvm
# # shellcheck source=/dev/null
# [[ -s "$NVM_DIR/bash_completion" ]] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[ -f ~/.fzf.bash ] && source ~/.fzf.bash