-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
344 lines (257 loc) · 5.95 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
#
# zsh Environment
#
setopt AUTO_CD
# Completion styling
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
# Shell History
# See https://zsh.sourceforge.io/Doc/Release/Options.html#History
export HISTFILE="$HOME/.zsh_history"
export HISTFILESIZE=7000000
export HISTSIZE=7000
export HISTTIMEFORMAT="%F %T "
export SAVEHIST=70000000
setopt append_history
setopt extended_history
setopt hist_find_no_dups
setopt hist_ignore_all_dups
setopt hist_ignore_dups
setopt hist_ignore_space
setopt hist_reduce_blanks
setopt hist_verify
setopt inc_append_history
setopt share_history
# XDG - conventional locations for app data
# See https://specifications.freedesktop.org/basedir-spec/latest/
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
export LESSHISTFILE="$XDG_CACHE_HOME/lesshst"
#
# Homebrew
#
export BREW_ROOT="/opt/homebrew"
export BREW_BIN="$BREW_ROOT/bin"
export HOMEBREW_INSTALL_FROM_API=1
export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_ANALYTICS=1
# Describe all programs installed by brew (excluding dependencies)
function brewed
{
brew leaves | xargs brew desc 2>/dev/null
}
function casks
{
brew list --cask | xargs brew desc --cask
}
function brew-completions
{
if type brew &>/dev/null
then
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
autoload -Uz compinit
compinit
fi
}
#
# PATH
#
PATH="$HOME/bin"
PATH="$PATH:$BREW_ROOT/bin"
PATH="$PATH:$BREW_ROOT/sbin"
PATH="$PATH:/usr/local/bin:/usr/local/sbin"
PATH="$PATH:/usr/bin:/usr/sbin:/bin:/sbin"
PATH="$PATH:/opt/homebrew/opt/mysql-client/bin"
export PATH
#
# Modern Shell
#
# Edit the current command line with ctrl-x ctrl-e
autoload -z edit-command-line
zle -N edit-command-line
bindkey "^X^E" edit-command-line
function exists
{
which $1 >/dev/null
}
# ls => lsd
export LC_COLLATE="C" # Sort dotfiles first in `ls -la` output
if exists lsd; then
alias ll='lsd -lA --group-dirs=first --date=+%m-%d-%Y'
alias tree='lsd --tree'
else
alias ll='ls -lAFGh'
fi
# cat => bat
if exists bat; then
alias cat='bat'
fi
export BAT_THEME="Monokai Extended"
# du => dust
if exists dust; then
alias du='dust'
fi
# ps => procs
if exists procs; then
alias ps='procs'
fi
# df => duf
if exists duf; then
alias df='duf'
fi
# Fuzzy Finder `fzf`
export FZF_DEFAULT_COMMAND="fd --type file --color=always"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_OPTS="--preview 'lsd --tree --color=always {} | head -200'"
export FZF_DEFAULT_OPTS="--ansi"
source <(fzf --zsh) # keybindings and completions
source $XDG_CONFIG_HOME/fzf-git.sh
#
# Configuration
#
if exists nvim; then
export EDITOR="nvim"
export VISUAL="nvim"
alias vim='nvim'
alias vi='nvim'
fi
function edit
{
$EDITOR $*
}
# Shortcuts for config edits
alias gitconfig="edit ~/.gitconfig"
alias hosts="sudo $EDITOR /etc/hosts"
alias zshrc="edit ~/.zshrc; source ~/.zshrc"
alias sshconfig="edit ~/.ssh/config"
# Copy + print SSH public key
alias pubkey="cat ~/.ssh/id_rsa.pub | tee >(pbcopy)"
#
# Development
#
# Github
export GITHUB_USER='jrdmcgr'
#NOTE: Github key is in private.sh
# Python
export PYTHONDONTWRITEBYTECODE=1 # Python won't write .pyc files
export PYTHON_BIN="/Library/Frameworks/Python.framework/Versions/3.11/bin"
# Root Python - only used to create virtual environments
alias py="$PYTHON_BIN/python3.11"
# Source a python virtual environment,
# creating one if it doesn't exist.
function venv
{
if [ -d ".venv" ]
then py -m venv .venv
fi
source .venv/bin/activate
}
# Javascript
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
function bun-completions
{
[ -s "/Users/jrdmcgr/.bun/_bun" ] && source "/Users/jrdmcgr/.bun/_bun"
}
# npm
alias ni='npm install'
alias nid='npm install --save-dev'
alias nis='npm install --save'
# Rust
if [ -f $HOME/.cargo/env ]; then
source "$HOME/.cargo/env"
fi
# PHP
alias serve.php='php -S 0:9000'
alias art='php artisan'
if exists psysh; then
function php
{
if [ $# -eq 0 ]
then $BREW_BIN/psysh
else $BREW_BIN/php $*
fi
}
fi
#
# General Computing
#
# Make a directory and cd into it.
function mcd
{
mkdir -p "$1" && cd "$1";
}
# Scope out the contents of a file.
function inspect
{
(head -5; tail -5) < $1
}
function execute {
local file="$1"
if [ ! -x $file ]; then
chmod +x $file
fi
if [[ $1 =~ / ]]; then
$1
else
./$1
fi
}
alias x='execute'
alias isodate="date +%F"
alias isotime="date +%FT%TZ"
alias sqlite="sqlite3"
# Networking
alias wanip='curl ifconfig.me'
alias lanip="ipconfig getifaddr en0"
alias myip="lanip;wanip"
alias p3='ping -c3'
alias diga='dig +noall +answer'
alias ifactive="ifconfig | rg --multiline -o '^[^\t:]+:([^\n]|\n\t)*status: active'"
alias http-headers="curl -LsSD - -o /dev/null"
alias weather='curl http://wttr.in/lakeland,fl'
#
# macOS Computing
#
# Show/hide hidden files in Finder
alias showfile="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hidefile="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
# Hide/show all desktop icons (useful when presenting)
alias hidedesk="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesk="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
function trash
{
mv "$1" ~/.Trash
}
function flushdns
{
sudo dscacheutil -flushcache;
sudo killall -HUP mDNSResponder
}
# Mac: quicklook a file
function quicklook
{
qlmanage -p "$@" >& /dev/null &
}
alias ql="quicklook"
# Set the tab title in iTerm 2
function tab-title
{
echo -ne "\033];${1}\007";
}
alias tt="tab-title"
#
# Prompt
#
eval "$(starship init zsh)"
#
# Setup
#
brew-completions
bun-completions
eval "$(zoxide init zsh --cmd cd)"
# Login Data
# archey -o