-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
149 lines (125 loc) · 3.39 KB
/
.zshrc
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
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Theme
ZSH_THEME="david"
# Path
export PATH=$HOME/bin:/usr/local/opt/python/libexec/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin
# zsh
source $ZSH/oh-my-zsh.sh
export EDITOR=vim
export PROJ=~/Projects
export BROWSER="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
# Aliases
alias g=git
alias v=vim
alias reload="source ~/.zshrc"
alias sed="sed -E"
alias ports="lsof -iTCP -sTCP:LISTEN -n -P"
alias jpp="jq '.'"
alias sp="cd $PROJ/SmartProcure"
alias cat="bat"
alias branches="git for-each-ref --count=10 --sort=-committerdate refs/heads/ --format='%(refname:short)' | fzf | xargs git checkout"
alias start="DEBUG=spark:* DEBUG_DEPTH=100 npm start"
alias tableau="/Applications/Tableau\ Desktop\ 2021.2.app/Contents/MacOS/Tableau -DDisableVerifyConnectorPluginSignature=true"
# Paging via Vim
export MANPAGER="/bin/sh -c \"col -b | vim --not-a-term -c 'set ft=man ts=8 nomod nolist noma' -\""
# FZF
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_COMMAND='rg --no-ignore-vcs --hidden --files'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
# NVM
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
export NODE_PATH=`npm root -g`
# z (nice autocompletion of frequently used directories)
source ~/Projects/z/z.sh
join() { local IFS="$1"; shift; echo "$*"; }
# Print what's running on one or more ports
port() {
if [ -z "$@" ]; then
echo "Usage: port [port # ...]"
else
lsof -iTCP:$(join , "$@") -sTCP:LISTEN -n -P
fi
}
# Kill one or more ports
port-kill() {
if [ -z "$@" ]; then
echo "Usage: port-kill [port # ...]"
else
port "$@" | awk 'NR!=1 {print $2}' | xargs kill
fi
}
# Change projects
proj() {
cd $PROJ/$1
}
# Change to root directory of current git repo
gr() {
cd "$(git rev-parse --show-cdup)"
}
# Open the current repo in github
gh() {
open "$(git config remote.origin.url | sed 's/\.git$//')"
}
# Directory history
dh() {
local dir
dir=$(z | sed 's/^[0-9.]*[[:space:]]*//' | fzf --tac --no-sort)
cd "$dir"
}
# Edit an rc file
rc(){
case $1 in
zsh) v ~/.zshrc ;;
vim) v ~/.vimrc ;;
emacs) e ~/.emacs.d/init.el ;;
clojure) v ~/.lein/profiles.clj ;;
esac
}
docker-clean-images() {
docker rmi "$(docker images -a --filter=dangling=true -q)"
}
docker-clean-ps() {
docker rm "$(docker ps --filter=status=exited --filter=status=created -q)"
}
findContainerId() {
docker ps --filter ancestor=$1 | awk 'NR!=1 {print $1}'
}
# Print the absolute path of the given files
path() { for f in "$@"; do echo ${f}(:A); done }
myip() { ifconfig | grep inet }
current-branch() {
git rev-parse --abbrev-ref HEAD
}
gup() {
git push -u origin "$(current-branch)"
}
contains-branch() {
local branch=$1
git log --oneline | grep $(git show-branch --sha1-name $branch | sed 's/\[(.*)\].*/\1/')
}
show-tabs() {
grep $'\t' $1
}
reverse() {
echo $1 | rev
}
# Search with rip grep
s() {
rg -M 125 -p -S --no-ignore-vcs --hidden "$@" | less -XFR
}
rm-swp() {
find . -type f -name "*.sw[klmnop]" -delete
}
py() {
case $1 in
2) ln -s /usr/bin/python $HOME/bin/python ;;
3) rm $HOME/bin/python ;;
esac
}
# Arguments: host, pattern
redis-del-bulk() {
redis-cli -h "$1" --raw keys "$2" | xargs redis-cli -h "$1" del
}