-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.sh_common
199 lines (166 loc) · 5.91 KB
/
.sh_common
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
#!/bin/bash
# Disable automatic expansion of "!<cmd>" in interactive sessions
set +o histexpand
# Make some commands verbose
for cmd in cp mv rm chmod chown rename; do
alias $cmd="$cmd -v"
done
# Add default args to some commands
alias grep="grep -I --ignore-case --exclude-dir=.git --exclude-dir=.svn"
alias rgrep="grep --recursive"
alias tree="tree --charset=ascii"
alias nosetests='nosetests --no-byte-compile'
alias synergys="synergys -f --config ~/.synergyrc"
alias xclip="xclip -selection clipboard"
alias dc=docker-compose
export PYTHONBREAKPOINT=pudb.set_trace
alias bp=bpython
# Yeah...
alias vi=nvim
alias vim=nvim
alias vl='nvim -c "normal! '\''0"' # Re-open the most recently opened file
alias voim=nvim
alias viom=nvim
export EDITOR=nvim
alias mk=make
export FZF_DEFAULT_COMMAND='ag -l'
alias ag='ag --width=200'
export LESS="--RAW-CONTROL-CHARS --jump-target=10 --ignore-case"
# Context
alias h=hostname
alias parents='pstree --ascii --show-parents --show-pids --arguments --highlight-pid=$$ $$ | grep -e "" -e "${SHELL##*/}"'
alias path=$'echo $PATH | tr : "\n"'
function cd() { builtin cd $1 && ls; }
# Highlighting
# Pasting snippets from workflowy, sometimes I encounter spaces replaced with
# non-breaking spaces. This highlights them in files or from stdin.
alias nbsp="GREP_COLOR='44' grep -I $'\u00A0'"
# Highlight DOS newlines
alias crlf="GREP_COLOR='44' grep -IU $'\r\n'"
# Show layout of current tmux window in a teamocil-friendly format
alias layout="tmux list-windows -F '#{window_active} #{window_layout}' | awk '/^1 /{print \$2}'"
# If you ever share a program that has a cat statement in it, someone will
# invariably tell you that you can avoid invoking cat by piping your input file
# directly into the next part of the pipeline. However, cat can still be nice
# because it lets your data flow from left to right. useless_cat is just my way
# of saying, "I already know my cat is useless. I still love it."
alias useless_cat=cat
# Text processing / formatting
alias cuts="cut -d ' '"
# Git aliases
alias gst='git status -s; git stash list'
alias gd='git diff'
alias gdc='git diff --cached'
alias gs='git show'
alias gh='git log --oneline --graph --decorate -n25'
alias ga='git add'
alias gc='git commit -v'
alias gb='git branch -vv --sort=-committerdate'
alias gr='git remote -v'
alias b='git branch | sed s/..// | fzf'
alias gt='git tag'
alias gcm='git checkout main || git checkout master'
alias gco='git checkout'
alias gcp='git cherry-pick'
gr-() { git checkout "$1" && git rebase -i -; }
alias glf='git ls-files | fzf'
git-prune-branches() {
git fetch --all --prune && git branch -v | awk '/\[gone\]/{print $1}' | xargs git branch -D
}
alias diff='GIT_DIR=/ git diff'
alias pr='git push -u origin HEAD && command gh pr create --fill --base staging'
alias serve='echo http://localhost:5000 && python -m http.server 5000 -d .'
alias dig='grc dig'
alias ping='grc ping'
alias ps='grc ps'
alias lsof='grc lsof'
alias netstat='grc netstat'
# Miscellaneous binaries
[[ -d ~/bin ]] && PATH=$HOME/bin:$PATH
# Homebrew
_homebrew_root=/opt/homebrew
if [[ -d $_homebrew_root ]]; then
PATH=$_homebrew_root/bin:$PATH
PATH=$_homebrew_root/sbin:$PATH
PATH=$_homebrew_root/anaconda3/bin:$PATH
fi
# Python / pyenv
if command -v pyenv >/dev/null; then
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
# Condensed output of `pyenv init -`
export PATH=$HOME/.pyenv/shims:${PATH}
export PYENV_SHELL=zsh
local _pyenv_package_root=$(set -- $_homebrew_root/Cellar/pyenv/*; echo "$1")
source $_pyenv_package_root/completions/pyenv.zsh
command pyenv rehash 2>/dev/null
pyenv() {
local command
command="${1:-}"
if [ "$#" -gt 0 ]; then
shift
fi
case "$command" in
rehash|shell)
eval "$(pyenv "sh-$command" "$@")"
;;
*)
command pyenv "$command" "$@"
;;
esac
}
fi
# Node
export NVM_DIR="$HOME/.nvm"
_default_node_version=v20.11.0
_default_node_path="$NVM_DIR/versions/node/$_default_node_version"
if [ -d "$_default_node_path" ]; then
# Having a default node version significantly speeds up nvm.sh execution on
# shell start-up. Courtesy of
# https://www.ioannispoulakas.com/2020/02/22/how-to-speed-up-shell-load-while-using-nvm/
export PATH=$_default_node_path/bin:$PATH
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" --no-use # This loads nvm
else
echo "Node $_default_node_version not found; initializing nvm the slow way..."
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" # This loads nvm
fi
[ -s "$NVM_DIR/bash_completion" ] && source "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# Ruby
if [[ -d /Library/Ruby/Gems/2.6.0 ]]; then
export GEM_HOME="$HOME/.gem/ruby/2.6.0"
PATH="$GEM_HOME/bin:$PATH"
fi
# RVM
if [[ -d "$HOME/.rvm" ]]; then
# Add RVM to PATH for scripting
PATH=$PATH:$HOME/.rvm/bin
# Configure env as if `rvm use default_rvm_ruby@default_rvm_gemset` was executed:
default_rvm_ruby=ruby-1.9.3-p448
default_rvm_gemset=
global_gem_home=$HOME/.rvm/gems/$default_rvm_ruby@global
if [[ -d $HOME/.rvm/gems/$default_rvm_ruby ]]; then
export GEM_HOME=$HOME/.rvm/gems/$default_rvm_ruby
export GEM_PATH=$GEM_HOME:$global_gem_home
PATH=\
$GEM_HOME/bin:\
$global_gem_home/bin:\
$HOME/.rvm/rubies/$default_rvm_ruby/bin:\
$PATH
[[ -z $default_rvm_gemset ]] || PATH=$HOME/.rvm/gems/$default_rvm_ruby$default_rvm_gemset/bin:$PATH
fi
# If the session is interactive, load RVM into a shell session *as a function*
[[ $- == *i* ]] && source "$HOME/.rvm/scripts/rvm"
fi
# Go
_default_go_env=$HOME/.goenv/default
if [[ -d "$_default_go_env" ]]; then
export GOPATH=$_default_go_env
PATH=$GOPATH/bin:$PATH
fi
# Android
export ANDROID_HOME=$HOME/Library/Android/sdk
export JAVA_HOME=/opt/homebrew/opt/openjdk
[[ -d $JAVA_HOME ]] && PATH=$JAVA_HOME/bin:$PATH
# Google Cloud SDK
CLOUDSDK=$HOME/google-cloud-sdk
[[ -d $CLOUDSDK ]] && PATH=$CLOUDSDK/bin:$PATH