-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
232 lines (187 loc) · 5.36 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
# completion
if type brew &>/dev/null
then
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
autoload -Uz compinit
compinit
fi
if [[ "$(uname -s)" == "Darwin" ]]; then
# prefer gnu stuff on mac
alias ls='gls --human-readable --color'
alias find='gfind'
alias wc='gwc'
alias sed='gsed'
alias readlink='greadlink'
alias pi='(cd ios && pod install)'
# vs code
test -d "/Applications/Visual Studio Code.app" && export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
# brew
export PATH="/usr/local/bin:$PATH"
# TODO: don't hardcode version here (how?)
export PATH="/opt/homebrew/Cellar/git/2.39.2/share/git-core/contrib/git-jump:$PATH"
# fix for gpg
GPG_TTY=$(tty)
export GPG_TTY
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
fi
# shortcuts
alias v=vim
alias vi=vim
alias g=git
alias h=heroku
alias f=flyctl
alias tree='tree -I "node_modules|tmp|dist|build"'
alias rg='rg --smart-case'
# alias ls='exa'
alias ll='exa -la'
alias b='bundle exec'
alias c=cargo
alias gs="echo 'did you mean g s?'"
alias curl="curl --no-progress-meter"
alias td="tracker-description"
alias s="stories"
alias st="stories"
alias rgg="rg --no-heading -n"
alias j=just
command -v batcat &> /dev/null && alias bat=batcat
eval "$(starship init zsh)"
# makes color constants available
autoload -U colors
colors
export TIME_STYLE=long-iso
# vscode seems to want to set my history to ~/.zsh_history which is annoying!!!
if [[ "$(uname -s)" == "Darwin" ]]; then
test -f "$HOME/.zsh_history" && rm "$HOME/.zsh_history"
fi
# history
export HISTSIZE=1000000
export HISTFILE="$HOME/.history"
export SAVEHIST=$HISTSIZE
setopt SHARE_HISTORY
export EDITOR=vim
# 2 width tab indentation
tabs -2
export LESS="--tabs=2 -R"
export MORE="--tabs=2 -R"
# makes ctrl-a, ctrl-e work as expected in tmux, vscode terminal, elsewhere?
bindkey -e
# allows `rake my:task[an_argument]` to work
unsetopt nomatch
# PATH
# ~/bin
# note! .profile maybe has this? need to put it in here
export PATH="$HOME/bin:$PATH"
# go
command -v go &> /dev/null && export PATH=$PATH:$(go env GOPATH)/bin
# prefer homebrew's unzip
export PATH="/opt/homebrew/opt/unzip/bin:$PATH"
# chruby
if test -f $HOMEBREW_PREFIX/opt/chruby/share/chruby/chruby.sh; then
source $HOMEBREW_PREFIX/opt/chruby/share/chruby/chruby.sh
source $HOMEBREW_PREFIX/opt/chruby/share/chruby/auto.sh
chruby ruby-3.1.0
fi
export FZF_DEFAULT_COMMAND='rg --files --no-ignore-vcs --hidden'
# https://superuser.com/q/313650
# Set Apple Terminal.app resume directory
if [[ $TERM_PROGRAM == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]] {
function chpwd {
local SEARCH=' '
local REPLACE='%20'
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
printf '\e]7;%s\a' "$PWD_URL"
}
chpwd
}
# install node with n – https://github.com/tj/n
# android tools, e.g. adb
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/tools
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
# jump to project in ~/code
function co {
cd ~/code/$(find ~/code -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | fzf)
}
###-begin-npm-completion-###
#
# npm command completion script
#
# Installation: npm completion >> ~/.bashrc (or ~/.zshrc)
# Or, maybe: npm completion > /usr/local/etc/bash_completion.d/npm
#
if type complete &>/dev/null; then
_npm_completion () {
local words cword
if type _get_comp_words_by_ref &>/dev/null; then
_get_comp_words_by_ref -n = -n @ -n : -w words -i cword
else
cword="$COMP_CWORD"
words=("${COMP_WORDS[@]}")
fi
local si="$IFS"
if ! IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
npm completion -- "${words[@]}" \
2>/dev/null)); then
local ret=$?
IFS="$si"
return $ret
fi
IFS="$si"
if type __ltrim_colon_completions &>/dev/null; then
__ltrim_colon_completions "${words[cword]}"
fi
}
complete -o default -F _npm_completion npm
elif type compdef &>/dev/null; then
_npm_completion() {
local si=$IFS
compadd -- $(COMP_CWORD=$((CURRENT-1)) \
COMP_LINE=$BUFFER \
COMP_POINT=0 \
npm completion -- "${words[@]}" \
2>/dev/null)
IFS=$si
}
compdef _npm_completion npm
elif type compctl &>/dev/null; then
_npm_completion () {
local cword line point words si
read -Ac words
read -cn cword
let cword-=1
read -l line
read -ln point
si="$IFS"
if ! IFS=$'\n' reply=($(COMP_CWORD="$cword" \
COMP_LINE="$line" \
COMP_POINT="$point" \
npm completion -- "${words[@]}" \
2>/dev/null)); then
local ret=$?
IFS="$si"
return $ret
fi
IFS="$si"
}
compctl -K _npm_completion npm
fi
###-end-npm-completion-###
if type fnm &>/dev/null
then
eval "$(fnm env --use-on-cd)"
fi
# ??
export PATH="/opt/homebrew/opt/curl/bin:$PATH"
function minimal-ps1 {
export PS1=$(printf "\n$ ")
}
# python
export PATH=$(pyenv root)/shims:$PATH
eval "$(github-copilot-cli alias -- "$0")"
# fnm
export PATH="/Users/schpet/Library/Application Support/fnm:$PATH"
eval "`fnm env`"