Repository navigation
Expand file tree
/
Copy pathzshrc
More file actions
295 lines (258 loc) · 7.36 KB
/
Copy pathzshrc
File metadata and controls
295 lines (258 loc) · 7.36 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
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# exports {{{
bindkey -e # LITERALLY MAGIC NO CLUE WHY PUTTING THIS AT THE BOTTOM FUCKS SHIT UP
export HISTFILE=$HOME/.zsh_history
export SAVEHIST=2048
export HISTSIZE=2048
export EDITOR="nvim"
export VISUAL="nvim"
export TERM="xterm-256color"
export LANG=en_US.UTF-8
export PYTHONSTARTUP=$HOME/dotfiles/pythonstartup.py
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/smlnj/bin:/opt/android-sdk/tools:/Users/wmak/Library/Python/3.11/bin
# Python
export WORKON_HOME=$HOME/.virtualenvs
# Aliases {{{
if [ -x /usr/bin/dircolors ]; then
alias ls="ls -h --color=auto"
alias dir="dir -h --color=auto"
alias grep='grep --color=auto'
fi
alias reload-zsh=". $HOME/.zshrc; comeback"
alias murder="kill -9"
alias die="kill -15"
alias g="git"
alias G="g g"
alias vi="nvim"
alias vim="nvim"
alias vif="vi \$(fzf)"
alias ':q'="exit"
alias psgrep="ps aux | grep"
alias pyclean="find . -name '*.pyc' -delete"
alias wotests="cd $HOME/development/getsentry/; getsentry devservices down && getsentry devservices up --project test; cd $HOME/development/sentry"
alias cdgetsentry="cd $HOME/development/getsentry"
alias sentryservices="cdgetsentry && getsentry devservices"
alias woserver="cd $HOME/development/getsentry/; getsentry devservices down --project test && getsentry devservices up && sleep 60 && done-result && getsentry devserver --workers"
alias done-result="echo 'done' > ~/.result"
alias comeback="cd ..; cd -"
alias smokeqb="pytest -m querybuilder tests/snuba tests/sentry/search"
print_info () {
printf "\e[1;33m$1\n\e[1;0m"
}
print_error() {
printf "\e[1;31m$1\n\e[1;0m"
}
function notify() {
osascript -e 'display notification "Your cli task is done!" with title "Task Complete!" sound name "Sonar"'
}
function ptw() {
eval $1
watchmedo shell-command --patterns="*.py" --drop --ignore-directories --recursive . -c "$1; osascript -e 'display notification \"Your cli task is done!\" with title \"Task Complete!\" sound name \"Sonar\"'"
}
function wo() {
current=`cat $HOME/.sentry-mode`
if [ "$1" = "server" ]; then
if [ "$current" = "test" ]; then
print_info "Switching out of $current"
sentryservices down --project test
sentryservices up
echo "server" > $HOME/.sentry-mode
fi
print_info "Starting server"
cdgetsentry && getsentry devserver --workers --pretty
elif [ "$1" = "tests" ]; then
print_info "Switching to tests"
if [ "$current" = "server" ]; then
docker exec -it sentry_redis redis-cli flushall
print_info "Switching out of $current"
sentryservices down
sentryservices up --project test
echo "test" > $HOME/.sentry-mode
fi
cd $HOME/development/sentry
fi
}
function ltest(){
# Usage on improper input
if [ $# -lt 2 ]; then
print_error "usage: ltest <file> <command>\n"
print_error "An example use of ltest would be:"
print_error "\tltest ./go-raptor go run\n"
print_error "ltest will work on either a file or an entire folder for example:"
print_error "\tltest ./ go run"
print_error "will run whenever there's a change in the current directory"
return 1
fi
# Store the name of the file and shift variables
file=$1
shift
# Check that the file being checked actually exists
if [ -f $file ]; then
print_info "Starting ltest on the file: "$file
elif [ -d $file ]; then
print_info "Starting ltest on the folder: "$file
else
print_error $file" is is not a file or folder"
return 1
fi
# Store the intial timestamp for the file
if [ -x /opt/homebrew/bin/gdate ]; then
# On macosx `brew install coreutils` so this works
alias timecmd=gdate
else
alias timecmd=date
fi
timestamp=`timecmd +%s -r $file`
# Main execution loop, detect if file has changed within the last 2 seconds.
while :
do
if [ $(expr `timecmd +%s -r $file` - $timestamp) -gt 0 ]; then
timestamp=`timecmd +%s -r $file`
# Check that the file isn't being modified
if [ -f $file ] || [ -d $file ]; then
clear && print_info "Starting... " && $* && print_info "Finished."
fi
fi
sleep 2
done
}
function lptest() {
ltest $1 pytest $1
}
function workon(){
if [ -f $HOME/.workon/$@ ]; then
printf "You're now working on %b\n" $@
source $HOME/.workon/$@
else
source /usr/local/bin/virtualenvwrapper.sh
workon $@
fi
}
# }}}
# autoloads {{{
autoload -U colors && colors
autoload -U compinit && compinit -i
# }}}
# Keybinding {{{
typeset -A key
up-line-or-local-history() {
zle set-local-history 1
zle up-line-or-history
zle set-local-history 0
}
zle -N up-line-or-local-history
down-line-or-local-history() {
zle set-local-history 1
zle down-line-or-history
zle set-local-history 0
}
zle -N down-line-or-local-history
key[Home]=[1~
key[End]=[4~
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
bindkey "${key[Delete]}" delete-char
# Options {{{
# Completion {{{
setopt ALWAYS_TO_END
unsetopt LIST_BEEP
unsetopt FLOW_CONTROL
setopt AUTO_PUSHD
setopt PUSHD_IGNORE_DUPS
unsetopt AUTO_CD
# }}}
# History{{{
setopt EXTENDED_HISTORY
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_REDUCE_BLANKS
setopt SHARE_HISTORY
# }}}
# Input {{{
setopt CORRECT
setopt INTERACTIVE_COMMENTS
setopt IGNORE_EOF
# }}}
# Other {{{
setopt COMPLETE_IN_WORD
# }}}
# }}}
# Prompt {{{
function git_prompt_info() {
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [ $? -eq 0 ];
then
diff=$(git diff --no-ext-diff --quiet --exit-code)
[[ $? -eq 1 ]] \
&& echo -n "%{$fg[red]%}" \
|| echo -n "%{$fg[blue]%}"
echo "("${branch}")%{$reset_color%}"
else
echo "()"
fi
}
ord=`printf '%d' "'$HOST"`
host_name=$HOST
if [ $HOST = "Rhea" ]; then
ord=199
elif [ $HOST = "Sentry-io-MacBook-Pro-MD7WYYFJ9L" ]; then
host_name='WorkMac'
ord=63
fi
function virtualenv_info() {
[[ -n $VIRTUAL_ENV ]] &&
echo -n "%{"%F{$ord}"%}(%{$fg[green]%}%B"`basename $VIRTUAL_ENV`"%{"%F{$ord}"%})"
}
function devservices() {
colima status
if [ $? -eq 1 ];
then
colima start
fi
$HOME/development/sentry/.venv/bin/devservices $@
}
precmd() {
PROMPT=%F{$ord}"("
PROMPT+="%{$fg[blue]%}%3d"
PROMPT+=%F{$ord}")("
PROMPT+="%{$fg[green]%}${USER}"
PROMPT+="%{$fg[grey]%}%B@%b"
PROMPT+="%{$fg[yellow]%}${host_name}"
PROMPT+=%F{$ord}")("
PROMPT+="%{$fg[cyan]%}%T"
PROMPT+=%F{$ord}")("
PROMPT+=%F{$ord}"%?"
PROMPT+=%F{$ord}")"
PROMPT+=$(virtualenv_info)
PROMPT+=$'\n'""
PROMPT+="%{$reset_color%}%b"
PROMPT+=$(git_prompt_info)
PROMPT+=%F{$ord}" "
PROMPT+=%F{255}%b
}
#}}}
eval "$(/opt/homebrew/bin/brew shellenv)"
# eval "$(pyenv init --path)"
# Plugins {{{
source $HOME/dotfiles/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
export NVM_DIR="$HOME/.nvm"
#}}}
# dircolors config. {{{
if whence dircolors >/dev/null; then # non-osx
eval `dircolors -b $HOME/dotfiles/dircolors.conf`
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
else
export CLICOLOR=1
fi
#}}}
# Setup ssh agent
ssh-agent -s > /dev/null
ssh-add 2> /dev/null
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export FZF_COMPLETION_TRIGGER='~~'
source <(fzf --zsh)
# direnv
export VOLTA_HOME="$HOME/.volta"
export PATH="$VOLTA_HOME/bin:$PATH"
export PATH="/Users/wmak/.local/share/sentry-devenv/bin:$PATH"
eval "$(direnv hook zsh)"