-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc
376 lines (271 loc) · 10.5 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
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
ZSH_DISABLE_COMPFIX="true"
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="robbyrussell"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# Caution: this setting can cause issues with multiline prompts (zsh 5.7.1 and newer seem to work)
# See https://github.com/ohmyzsh/ohmyzsh/issues/5765
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git vi-mode)
source $ZSH/oh-my-zsh.sh
# ENV secrets
export DOGFOOD_WRITEKEY=""
source ~/secrets.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
export PATH="/usr/local/sbin:$PATH"
export PATH="$HOME/.bin:$PATH"
export EDITOR='nvim'
export GIT_EDITOR='nvim'
# jump jump!
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
# ----- ALIAS -----
# to ignore the alias and run actual vim '\vim'
alias vim="nvim"
alias edit="nvim"
alias now="vercel"
alias editzsh="vim ~/.zshrc && source ~/.zshrc"
alias catzsh="cat ~/.zshrc"
alias :qall="exit"
alias xit="exit"
alias at="tmux at"
# copy last command run
alias copy_cmd="fc -ln -1 | pbcopy"
# --- git helpers ----
alias prune="git branch | grep -v 'main' | xargs git branch -D"
alias amendit="git commit --amend --no-edit"
alias gpof="git push origin head --force-with-lease"
alias rewind="git reset HEAD~1"
alias list_branches="git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format='%(refname:short) %(committerdate:relative)'"
alias list_branches_all="git for-each-ref --count=200 --sort=-committerdate refs/heads/ --format='%(refname:short) %(committerdate:relative)'"
#
alias saveaudio="youtube-dl -o '~/Desktop/music/%(title)s-%(id)s.%(ext)s' --restrict-filenames --add-metadata -x --audio-format m4a"
alias savevideo="youtube-dl -o '~/Desktop/videos/%(title)s-%(id)s.%(ext)s' --restrict-filenames --add-metadata --write-sub"
alias cat="bat"
# so sudo vim actually runs sudo nvim
# https://unix.stackexchange.com/questions/710187/how-do-i-make-an-alias-for-a-command-with-sudo
alias sudo="sudo "
# ----------------------
# Note taking assists
# ----------------------
alias notes="t notes"
# TODO: add optional project/tag
# use template depending on project/tag?
# could also do some checking to see if a file exists w/in same week, and use
# that instead of whipping up a new one
function note() {
if [ -z "$1" ]; then
vim ~/notes/$(date -v -Mon "+%Y-%m-%d").md -c w
else
vim ~/notes/$(date "+%Y-%m-%d")-$1.md -c w
fi
}
alias w_date="$(print date -v -Mon "+%Y-%m-%d")"
function qn() {
if [ -z "$1" ]; then
vim ./$(date -v -Mon "+%Y-%m-%d").md -c w
else
vim ./$(date "+%Y-%m-%d")-$1.md -c w
fi
}
function todo {
vim ~/notes/todo/$(date -v -Mon "+%Y-%m-%d").md -c w
}
function git-todo {
project=$(basename $PWD)
branch=$(eval git rev-parse --abbrev-ref HEAD)
vim ~/notes/todo/$(date -v -Mon "+%Y-%m-%d")-$project-$branch.md -c w
}
#TODO add PR when it is opened?
function branch-notes() {
project=$(basename $PWD)
branch_file=$(eval git rev-parse --abbrev-ref HEAD).md
mkdir -p ~/notes/repos/$project
cd ~/notes/repos/$project
existing_note=$(ls | grep $branch_file)
if [ ! -z "$existing_note" ]; then
echo -e "\n\n$(date "+%Y-%m-%d")" >> $existing_note
vim $existing_note
else
vim $(date "+%Y-%m-%d")-${branch_file}
fi
cd $OLDPWD
}
# ----------------------
# Tmuxinator helpers
# ----------------------
function t() {
if [ -z "$1" ]; then
project=$(basename $PWD)
# if [ project = "doximity-client-vue" ]; then
# project="vue"
# fi
launch_tmux_project "$project"
else
launch_tmux_project "$1"
fi
}
function launch_tmux_project() {
# if there is a tmuxinator project file that matches
# the directory name, use it. otherwise launch w/ scaffolding
if tmuxinator list | grep "$1"; then
tmuxinator start "$1" && exit
else
tmuxinator start scaffold -n "$1" workspace=$PWD && exit
fi
}
# ----------------------
# Honeycomb specific things
# TODO move to own file; export in
# ----------------------
# alias to sparse-checkout of hound. only the docs. so can
# keep drafts as i work without attaching to specific branch
# later, should hook up w/ markdown preview and launch from there
# perhaps
alias "go-docs"=cd "$HOME/workbench/poodle-docs/cmd/poodle/docs"
export VOLTA_HOME="$HOME/.volta"
export PATH="$VOLTA_HOME/bin:$PATH"
export BASENJI_ROOT="$HOME/workbench/basenji/"
alias tilt="cd ~/workbench/hound && tilt"
alias besttilt="tilt args -- --webpack-dev-server"
unalias gsts # ohmyzsh has a git alias that smashes gsts cli tool
# gsts/aws fun
export AWS_PROFILE=sts
export GOOGLE_SP_ID=456279060050
export GOOGLE_IDP_ID=C01jgaetc
export HNYUSER="ashleyrobinson"
alias prodaccess="gsts --aws-role-arn arn:aws:iam::702835727665:role/product --username=$HNYUSER@honeycomb.io"
alias pdocs="cd ~/workbench/poodle-docs/cmd/poodle/docs/"
# strip off :line-number from the end of vim ,C output and start running yarn watch
function watch() {
file=$1
cd ~/workbench/hound/cmd/poodle/ && yarn jest --detectOpenHandles --logHeapUsage --runInBand --no-compilation-cache --watch ${file/:*/}
}
#—-------------------------------
#
# Poodle Local Dev Aliases & Things
#
#—-—----------------—---------------
# satellite team
export DEV_WRITEKEY=$DOGFOOD_WRITEKEY
export SATELLITE_URL="https://api-dogfood.honeycomb.io"
# "normal" team
export FREE_API="aECV7VDfGHVCKieQZeKKxC"
export FREE_API_URL=http://localhost:8081
# Some of the code uses a lot of connections
# comment this out if you don't want things to be slow
# export LIBHONEY_URL=$FREE_API_URL
# export LIBHONEY_WRITE_KEY=$FREE_API
# export LIBHONEY_URL=$BASENJI_URL
# export LIBHONEY_WRITE_KEY=$BASENJI_KEY
ulimit -n 8192
# generate a ton of data:
# :qall
#
#prelint
prelint () {
LIST=`git diff-index --diff-filter=d --name-only HEAD | grep "\.[tj]s[x]\{0,1\}$" | perl -pe 's/cmd\/poodle\///g'`;
if [ "$LIST" ]; then cd cmd/poodle; npx eslint --quiet $LIST; fi
}
eval "$(direnv hook zsh)"
. /usr/local/opt/asdf/libexec/asdf.sh
# ----------------------
#
# Markdown Preview Helpers
#
# ----------------------
MARKDOWN_PREVIEW_DIR="~/workbench/markdown-preview"
# `sync_markdown`: copies `*.md` files from the current working directory over
# to markdown-preview and watches for changes, updating the copied files
# anytime they're modified
#
# Symlinks unfortunately won't play nicely w/ webpack's hot reloading, and
# I failed to figure out a good way to watch files in another directory
# direcly, so we copy.
alias sync_markdown="node $MARKDOWN_PREVIEW_DIR/utils/sync -w $PWD"
# `preview_markdown`: starts up the next.js app from anywhere our heart desires
alias preview_markdown="yarn --cwd "$MARKDOWN_PREVIEW_DIR" dev"
# `sync_and_preview`: start syncing & launch the web server in one fell swoop
function sync_and_preview() {
preview_markdown & sync_markdown
}
# `add_toc`: update toc for file
alias add_toc="yarn --cwd $MARKDOWN_PREVIEW_DIR markdown-toc -i $PWD/"
# `print_toc`: print to console the toc for file
alias print_toc="yarn --cwd $MARKDOWN_PREVIEW_DIR markdown-toc $PWD/"
#
# Kubectl
klogs () {
kubectl logs $@ -f $(kubectl get pods $@ | tail -n +2 | fzf | cut -d' ' -f1)
}
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# git aliases
alias currentBranch="git rev-parse --abbrev-ref HEAD | pbcopy"
alias localBranches="git log --branches --not --remotes --no-walk --decorate"
alias weather="curl 'wttr.in/jersey+city?u'"