-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc
593 lines (502 loc) · 21.6 KB
/
dot_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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
# debug perf: also run `zsh -l --sourcetrace`
# https://www.reddit.com/r/zsh/comments/ycm6fa/comment/itn2i3l/?context=3
# [ -z "$ZPROF" ] || zmodload zsh/zprof
# zmodload zsh/zprof
#
# https://www.reddit.com/r/zsh/comments/1bqtb7m/comment/kx4pqxw/?context=3
# This should make it clear which files takes a long time to source. After that you can start disabling stuff in that file to find the culprit:
# exec -l zsh --sourcetrace
#
# This might immediately tell you which command takes a long time:
# ( exec -l zsh --sourcetrace 2>&1 ) | ts -i '%.s'
# Clone zcomet if necessary
if [[ ! -f ${ZDOTDIR:-${HOME}}/.zcomet/bin/zcomet.zsh ]]; then
command git clone https://github.com/agkozak/zcomet.git ${ZDOTDIR:-${HOME}}/.zcomet/bin
fi
source ${ZDOTDIR:-${HOME}}/.zcomet/bin/zcomet.zsh
# load prompt
zcomet load romkatv/powerlevel10k
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# exit 1
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# https://www.reddit.com/r/KittyTerminal/comments/13ephdh/xtermkitty_ssh_woes_i_know_about_the_kitten_but/
# kitty ssh fix
# [[ "$TERM" == "xterm-kitty" ]] && alias ssh="TERM=xterm-256color ssh"
export PATH="/opt/homebrew/opt/postgresql@13/bin:$PATH"
export PATH="/opt/homebrew/opt/sqlite/bin:$PATH"
# fpath=(
# $fpath
# $HOME/.local/share/zsh/site_functions
# )
# zcomet fpath ~/.local/share/zsh/site_functions
# color term
export CLICOLOR=1
export LSCOLORS=Dxfxcxdxbxegedabadacad
export ZLS_COLORS=$LSCOLORS
export LC_CTYPE=en_US.UTF-8
# https://github.com/kovidgoyal/kitty/issues/2047#issuecomment-934058006 ?
# export LANG=en_US.UTF-8
# export LANGUAGE=en_US.UTF-8
# export LC_ALL=en_US.UTF-8
# set for git delta, iirc
export LESS=FRX
# telescope and less? https://github.com/nvim-telescope/telescope.nvim/issues/253#issuecomment-730071741
# export LESS=iMRS
export XDG_CONFIG_HOME=$HOME/.config
# export XDG_DATA_HOME=$HOME/.local/.share
# does this do anything?
# make with the pretty colors
autoload colors; colors
# TODO: replace with https://github.com/jeffreytse/zsh-vi-mode ??
# https://rm-rf.ca/posts/2020/zsh-vi-mode/
#vim binding
bindkey -v
# bindkey -M vicmd '^r' history-incremental-search-backward
# bindkey -M viins '^r' history-incremental-search-backward
# incremental search in vi command mode
bindkey -M vicmd '?' history-incremental-search-backward
bindkey -M vicmd '/' history-incremental-search-forward
# navigate matches in incremental search
bindkey -M viins '^R' history-incremental-pattern-search-backward
bindkey -M viins '^F' history-incremental-pattern-search-forward
# beginning search with arrow keys and j/k
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
# up/down arrow to complete history for commands matching my beginning input
bindkey -M viins '^[[A' up-line-or-beginning-search
bindkey -M vicmd '^[[A' up-line-or-beginning-search
bindkey -M viins '^[OA' up-line-or-beginning-search
bindkey -M vicmd '^[OA' up-line-or-beginning-search
bindkey -M viins '^[[B' down-line-or-beginning-search
bindkey -M vicmd '^[[B' down-line-or-beginning-search
bindkey -M viins '^[OB' down-line-or-beginning-search
bindkey -M vicmd '^[OB' down-line-or-beginning-search
# https://github.com/zsh-users/zsh-autosuggestions#key-bindings
bindkey "^[[H" beginning-of-line # Home key
bindkey "^[[F" end-of-line # End key
# bindkey '^ ' autosuggest-accept # ctrl + space to accept the current suggestion. right arrow or EOL, also works
bindkey '^x' autosuggest-execute # ctrl + x to execute the current suggestion
bindkey '^ ' forward-char
bindkey '^n' forward-word
bindkey '^p' backward-word
# remove normal/insert mode switch delay, 10ms for key sequences
export KEYTIMEOUT=1
# ci", ci', ci`, di", etc
autoload -U select-quoted
zle -N select-quoted
for m in visual viopp; do
for c in {a,i}{\',\",\`}; do
bindkey -M $m $c select-quoted
done
done
# ci{, ci(, ci<, di{, etc
autoload -U select-bracketed
zle -N select-bracketed
for m in visual viopp; do
for c in {a,i}${(s..)^:-'()[]{}<>bB'}; do
bindkey -M $m $c select-bracketed
done
done
# ic camelCase motions
autoload -U select-word-match
zle -N select-in-camel select-word-match
zle -N select-a-camel select-word-match
zstyle ':zle:*-camel' word-style normal-subword
bindkey -M viopp ic select-in-camel
# i/ and a/ path component motions
zstyle ':zle:select-*-directory' word-style unspecified
zstyle ':zle:select-*-directory' word-chars $'/<>=;&| \t\n'
# Change cursor shape for different vi modes.
function zle-keymap-select {
if [[ ${KEYMAP} == vicmd ]] ||
[[ $2 = 'block' ]]; then
echo -ne '\e[1 q'
elif [[ ${KEYMAP} == main ]] ||
[[ ${KEYMAP} == viins ]] ||
[[ ${KEYMAP} = '' ]] ||
[[ $1 = 'beam' ]]; then
echo -ne '\e[5 q'
fi
}
zle -N zle-keymap-select
zle-line-init() {
zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
echo -ne "\e[5 q"
}
zle -N zle-line-init
echo -ne '\e[5 q' # Use beam shape cursor on startup.
preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
# reload zsh shell with ctrl N
# exec-zsh() {
# zle -I
# exec zsh <$TTY
# }
# zle -N exec-zsh
# bindkey '^N' exec-zsh
# history
HISTFILE=~/.zsh_history
HISTSIZE=1000000000 # The maximum number of events to save in the internal history.
SAVEHIST=1000000000 # The maximum number of events to save in the history file.
# options https://gist.github.com/mattmc3/c490d01751d6eb80aa541711ab1d54b1
# changing dirs
setopt auto_cd # if a command isn't valid, but is a directory, cd to that dir
# completions
setopt always_to_end # move cursor to the end of a completed word
setopt glob_dots # include dotfiles when globbing
setopt no_case_glob # ignore case https://www.reddit.com/r/zsh/comments/1088i0z/case_insensitive_file_completion/
# expansion/globbing
setopt extendedglob # Treat the ‘#’, ‘~’ and ‘^’ characters as part of filename
# history
setopt hist_expire_dups_first # expire a duplicate event first when trimming history
setopt hist_ignore_all_dups # Delete old recorded entry if new entry is a duplicate
setopt hist_find_no_dups # don't display a previously found event
setopt hist_ignore_dups # don't record an event that was just recorded again
# setopt hist_ignore_space # don't record an event starting with a space
unsetopt hist_ignore_space
setopt hist_reduce_blanks # remove superfluous blanks from each command line being added to the history list
setopt hist_save_no_dups # don't write a duplicate event to the history file
setopt inc_append_history # write to the history file immediately, not when the shell exits
setopt share_history # Share history between all sessions
# input/output
setopt interactive_comments # Allow comments even in interactive shells
# job control
setopt auto_resume # attempt to resume existing job before creating a new process (vim!)
setopt rc_quotes # allow 'Henry''s Garage' instead of 'Henry'\''s Garage'
unsetopt rm_star_silent # ask for confirmation for `rm *' or `rm path/*'
# prompting
setopt nonomatch # tell zsh to pass the unevaluated argument like bash
setopt prompt_subst # parameter expansion, command substitution and arithmetic expansion are performed in prompts
# don't append failed command to ~/.zsh_history
# this excludes commands that don't exist, assuming that the first word is the command name...
# this doesn't save commands starting with an ENV :(
# zshaddhistory() { whence ${${(z)1}[1]} >| /dev/null || return 1 }
# Bindings
# external editor support
autoload edit-command-line; zle -N edit-command-line
bindkey '^o' edit-command-line
# bindkey '^e' edit-command-line
# bindkey '^x^e' edit-command-line
# Partial word history completion
bindkey '\ep' up-line-or-search
bindkey '\en' down-line-or-search
bindkey '\ew' kill-region
# alt-c
bindkey "ç" fzf-cd-widget
# disable in tmux
if [ -z "$TMUX" ]; then
fg-widget() {
stty icanon echo pendin -inlcr < /dev/tty
stty discard '^O' dsusp '^Y' lnext '^V' quit '^\' susp '^Z' < /dev/tty
zle reset-prompt
if jobs %- >/dev/null 2>&1; then
fg %-
else
fg
fi
}
# Use C-z to foreground in zsh
zle -N fg-widget
bindkey -M emacs "^Z" fg-widget
bindkey -M vicmd "^Z" fg-widget
bindkey -M viins "^Z" fg-widget
fi
# bindkey -s '^z' 'fg^M'
# I have no idea why I have to unset this but otherwise I don't get LESS paging
unset DELTA_PAGER
export PAGER='less'
export EDITOR='nvim -u NONE'
export VISUAL='nvim -u NONE'
# export MANPAGER='nvim +Man!'
export MANPAGER='nvim --clean +Man!'
# export MANPAGER="sh -c 'col -bx | bat -l man -p'"
export MANWIDTH=999
# tmux
export FZF_TMUX=1 # open in pop-up
export FZF_TMUX_OPTS="-p -w 90% -h 60%"
export FZF_TMUX_POP_UP_OPTS="-p 90%,90%"
# default fzf
export FZF_HEADER_DEFAULT="ALT-k/j page up/down, CTRL-u/d preview half-page up/down, \ to toggle"
export FZF_HEADER_FILES="CTRL-s/ALT-d to select/unselect-all, CTRL-v open in nvim"
export FZF_HEADER_PASTE="CTRL-y to copy into clipboard"
export FZF_YANK_COMMAND="--bind 'ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'"
# preview cycle window rotate: https://github.com/junegunn/fzf/commit/43f0d0c
export FZF_HIDE_PREVIEW="--preview-window=:hidden"
# to add image preview https://github.com/junegunn/fzf/blob/0.44.0/bin/fzf-preview.sh
export FZF_SHOW_PREVIEW="
--preview '([[ -f {} ]] && (bat --style=full --color=always {} || cat {})) || ([[ -d {} ]] && (tree -C {} | less)) || echo {} 2> /dev/null | head -200'
--preview-window 'right,50%,border-left,<50(up,50%,border-bottom)'
--bind '\:toggle-preview'
--bind 'ctrl-u:preview-half-page-up'
--bind 'ctrl-d:preview-half-page-down'
"
# TODO: remove --preview from FZF_DEFAULT_OPTS and use FZF_SHOW_PREVIEW
export FZF_DEFAULT_OPTS="
--walker=file,dir,hidden,follow --walker-skip=.git,node_modules,target
--history=$HOME/.fzf_history
--layout=reverse
--info=inline
--height=80%
--multi
--border=double
--prompt='> ' --pointer='▶' --marker='✓'
--header '$FZF_HEADER_DEFAULT'
--scrollbar '▌▐'
--bind 'ctrl-s:select-all'
--bind 'alt-d:deselect-all'
--preview-window 'right,50%,border-left,<50(up,50%,border-bottom)'
--bind 'ctrl-\:toggle-preview'
--bind 'ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'
--bind 'ctrl-u:preview-half-page-up'
--bind 'ctrl-d:preview-half-page-down'
--bind 'alt-k:page-up'
--bind 'alt-j:page-down'
--bind 'ctrl-v:execute(nvim {} < /dev/tty > /dev/tty 2>&1)+accept'
"
# generated from tokyo dark colorscheme
# export FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS'
# --color=bg+:#292e42,bg:#1a1b26,spinner:#bb9af7,hl:#565f89,fg:#c0caf5,header:#565f89,info:#7dcfff,pointer:#bb9af7,marker:#7dcfff,fg+:#c0caf5,preview-bg:#292e42,prompt:#bb9af7,hl+:#bb9af7
# '
export FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS'
--color fg:#c0caf5,bg:#1a1b26,hl:#FFFFFF
--color fg+:#c0caf5,bg+:#292e42,hl+:#FFFFFF
--color info:#bb9af7,prompt:#7dcfff,pointer:#bb9af7
--color marker:#9ece6a,spinner:#9ece6a,header:#565f89
--color border:#7aa2f7,gutter:#1a1b26
--color preview-bg:#292e42,preview-border:#7aa2f7,preview-scrollbar:#7aa2f7
--color header:italic
'
export RIPGREP_CONFIG_PATH="$HOME/.ripgreprc"
export ESCDELAY="1" # https://github.com/junegunn/fzf/issues/2052
export FZF_DEFAULT_COMMAND='rg --files'
# files
export FZF_CTRL_T_COMMAND="fd --hidden --follow --exclude '.git' --exclude 'node_modules' --exclude '.rvm' --exclude '.frum' --exclude '.pyenv' --exclude '.npm'"
export FZF_CTRL_T_OPTS="$FZF_DEFAULT_OPTS $FZF_SHOW_PREVIEW --select-1"
# directories
export FZF_ALT_C_COMMAND="$FZF_CTRL_T_COMMAND --type d"
export FZF_ALT_C_OPTS="$FZF_DEFAULT_OPTS $FZF_SHOW_PREVIEW --select-1"
# history
# modify keybindings.zsh or add plugin: https://github.com/junegunn/fzf/issues/477#issuecomment-230338992
# ctrl-x to execute, enter to put in cmd line
export FZF_CTRL_R_OPTS="$FZF_HIDE_PREVIEW"
# https://github.com/junegunn/fzf/commit/f84b3de24b63e2e26cbfa2a24e61a4173824fffd
# tweak above nvim open?
# ls | fzf --bind "enter:execute(vim {})"
# override builtin fzf functions for `app **<tab>`
_fzf_compgen_path() {
fd --hidden --follow --exclude ".git" . "$1"
}
# override builtin fzf functions for `cd **<tab>`
# Use fd to generate the list for directory completion
_fzf_compgen_dir() {
fd --type d --hidden --follow --exclude ".git" . "$1"
}
# Advanced customization of fzf options via _fzf_comprun function
# - The first argument to the function is the name of the command.
# - You should make sure to pass the rest of the arguments to fzf.
_fzf_comprun() {
local command=$1
shift
case "$command" in
cd) fzf --preview 'tree -C {} | head -200' "$@" ;;
export|unset) fzf --preview "eval 'echo \$'{}" "$@" ;;
ssh) fzf --preview 'dig {}' "$@" ;;
*) fzf --preview 'bat -n --color=always {}' "$@" ;;
esac
}
# zle -N kube-toggle
# bindkey '^]' kube-toggle # ctrl-] to toggle kubecontext in powerlevel10k prompt
zcomet snippet ~/zsh/utils.zsh
zcomet snippet ~/zsh/aliases.zsh
# remove duplicates in $PATH
typeset -aU path
# export PATH="$HOME/Library/Python/2.7/bin:$PATH"
# export PATH="$(yarn global bin):$PATH"
export PATH="$HOME/.yarn/bin:$PATH"
export PATH="$HOME/bin:$PATH"
#export GOPATH="${HOME>/.go
export GOROOT="/opt/homebrew/opt/go/libexec"
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOPATH
export PATH=$PATH:$GOROOT/bin
export PYTHONPATH="."
[ -f $HOME/.cargo/env ] && source $HOME/.cargo/env
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# export FZF_COMPLETION_TRIGGER=''
# bindkey '^T' fzf-completion #context (dir) aware completion
# bindkey '^I' $fzf_default_completion
# prevent paste readability issue https://github.com/zdharma-continuum/fast-syntax-highlighting/issues/25
zle_highlight=('paste:none')
# to benchmark, run: ~/zsh-bench/zsh-bench
zcomet trigger zsh-prompt-benchmark romkatv/zsh-prompt-benchmark
#load plugins
zcomet load aloxaf/fzf-tab
zcomet load zsh-vi-more/vi-motions
zcomet load zsh-vi-more/evil-registers
zcomet load romkatv/zsh-no-ps2
# zcomet load MichaelAquilina/zsh-you-should-use
zcomet load greymd/docker-zsh-completion
zcomet load zsh-users/zsh-autosuggestions
zcomet load zdharma-continuum/fast-syntax-highlighting
zcomet load zsh-users/zsh-completions
# Where would this fit in? https://github.com/zsh-users/zsh-autosuggestions
zstyle :plugin:fast-syntax-highlighting theme base16
# zsh-vi-more/evil-registers, send all yanks to system clipboard
(){
local op
local -a handler
for op in yank put; do
# get the current behavior for '+'
zstyle -a :zle:evil-registers:'+' $op handler
# if there is a handler, assign it for the empty pattern
(($#handler)) && zstyle :zle:evil-registers:'' $op $handler
done
}
# zsh-vi-more/evil-registers, do not save delete or change to clipboard
for w (
vi-delete vi-delete-char vi-kill-line vi-kill-eol
vi-change vi-change-eol vi-change-whole-line
);{
# dot-prefixed widgets are builtins and cannot be overridden
zle -A .$w $w
}
# Completion for kill-like commands
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
zstyle ':completion:*:ssh:*' tag-order hosts users
zstyle ':completion:*:ssh:*' group-order hosts-domain hosts-host users hosts-ipaddr
zstyle ':completion:*:*:docker:*' option-stacking yes
zstyle ':completion:*:*:docker-*:*' option-stacking yes
# ignore completion functions (until the _ignored completer)
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zshcache
zstyle ':completion:*' special-dirs true
# disable sort when completing options of any command
zstyle ":completion:*:git-checkout:*" sort false
zstyle ':completion:complete:*:options' sort false
# TODO fix all this: https://superuser.com/questions/265547/zsh-cdpath-and-autocompletion
# set cd autocompletion to commonly visited directories
cdpath=($HOME/code/brandfolder $HOME/code/timtyrrell)
zstyle ':completion:*:complete:(cd|pushd):*' tag-order 'local-directories named-directories'
# set list-colors to enable filename colorizing
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# set descriptions format to enable group support
zstyle ':completion:*:descriptions' format '[%d]'
# https://github.com/Aloxaf/dotfiles/blob/180d97c8f13b001dbba49a69d964f4377d306748/zsh/.config/zsh/zshrc.zsh#L100-L113
# == fzf-tab
# zstyle ':fzf-tab:complete:_zlua:*' query-string input
# zstyle ':fzf-tab:complete:kill:argument-rest' fzf-preview 'ps --pid=$word -o cmd --no-headers -w -w'
# zstyle ':fzf-tab:complete:kill:argument-rest' fzf-flags '--preview-window=down:3:wrap'
# zstyle ':fzf-tab:complete:kill:*' popup-pad 0 3
# zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath'
# zstyle ':fzf-tab:complete:cd:*' popup-pad 30 0
# zstyle ":fzf-tab:*" fzf-flags --color=bg+:23
# zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup
# zstyle ':fzf-tab:*' switch-group ',' '.'
# zstyle ":completion:*:git-checkout:*" sort false
# zstyle ':completion:*' file-sort modification
# zstyle ':completion:*:exa' sort false
# zstyle ':completion:files' sort false
# https://github.com/Aloxaf/dotfiles/blob/180d97c8f13b001dbba49a69d964f4377d306748/zsh/.config/zsh/zshrc.zsh#L100-L113
# == fzf-tab
zstyle ':fzf-tab:*' show-group brief
zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup
zstyle ':fzf-tab:*' popup-pad 200 200
zstyle ':fzf-tab:*' popup-min-size 50 8
zstyle ':fzf-tab:*' fzf-min-height 50
# switch group using `,` and `.`
zstyle ':fzf-tab:*' switch-group ',' '.'
# use input as query string when completing zlua
zstyle ':fzf-tab:complete:_zlua:*' query-string input
zstyle ':fzf-tab:complete:(kill|ps):argument-rest' fzf-preview \
'[[ $group == "[process ID]" ]] && ps --pid=$word -o cmd --no-headers -w -w'
zstyle ':fzf-tab:complete:(kill|ps):argument-rest' fzf-flags --preview-window=down:3:wrap
zstyle ':fzf-tab:*' fzf-bindings 'ctrl-u:preview-half-page-up' 'ctrl-d:preview-half-page-down' 'space:accept' 'alt-k:page-up' 'alt-j:page-down'
zstyle ':fzf-tab:*' continuous-trigger '/'
zstyle ':fzf-tab:*' accept-line ctrl-x
local preview_command='
if [[ -d $realpath ]]; then
eza -a --icons --tree --level=1 --color=always $realpath
elif [[ -f $realpath ]]; then
bat --pager=never --color=always --line-range :80 $realpath
else
# lesspipe.sh $word | bat --color=always
exit 1
fi
'
zstyle ':fzf-tab:complete:*' fzf-preview $preview_command
# zstyle ':fzf-tab:complete:*.*' fzf-preview $preview_command
# zstyle ':fzf-tab:complete:*:*' fzf-preview 'less ${(Q)realpath}'
# export LESSOPEN="|/usr/local/bin/lesspipe.sh %s" LESS_ADVANCED_PREPROCESSOR=1
# zstyle ':fzf-tab:complete:(\\|)run-help:*' fzf-preview 'run-help $word'
# zstyle ':fzf-tab:complete:(\\|*/|)man:*' fzf-preview 'man $word'
# zstyle ':fzf-tab:complete:(-command-|-parameter-|-brace-parameter-|export|unset|expand):*' \
# fzf-preview 'echo ${(P)word}'
# zstyle ':fzf-tab:complete:cd:*' fzf-preview 'lsd --color always --icon always --depth 2 --tree $realpath'
# zstyle ':fzf-tab:complete:exa:*' extra-opts --preview=$extract'preview_file_or_folder.sh $realpath' --preview-window=right:40%
# zstyle ':fzf-tab:complete:git-checkout:argument-rest' fzf-preview '
# [[ $group == "[recent branches]" || $group == "[local head]" ]] && git log --max-count=3 -p $word | delta
# '
# zstyle ':fzf-tab:complete:*' fzf-preview 'less $realpath'
# zstyle ':fzf-tab:complete:git-(add|diff|restore):*' fzf-preview 'git diff $word'
# zstyle -s ':fzf-tab:complete:git-add:*' fzf-preview str
zstyle ':fzf-tab:complete:git-(add|diff|restore):*' fzf-preview \
'git diff $word | delta'
zstyle ':fzf-tab:complete:git-log:*' fzf-preview \
'git log --color=always $word'
zstyle ':fzf-tab:complete:git-help:*' fzf-preview \
'git help $word | bat -plman --color=always'
zstyle ':fzf-tab:complete:git-show:*' fzf-preview \
'case "$group" in
"commit tag") git show --color=always $word ;;
*) git show --color=always $word | delta ;;
esac'
zstyle ':fzf-tab:complete:git-checkout:*' fzf-preview \
'case "$group" in
"modified file") git diff $word | delta ;;
"recent commit object name") git show --color=always $word | delta ;;
*) git log --color=always $word ;;
esac'
# export PYENV_ROOT="$HOME/.pyenv"
# export PATH="$PYENV_ROOT/shims:$PATH"
# [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
# eval "$(pyenv init -)"
# source <(stern --completion=zsh)
# fnm
eval "$(fnm --version-file-strategy=recursive --log-level=quiet env --use-on-cd)"
# directly executing the command (CTRL-X CTRL-R)
fzf-history-widget-accept() {
fzf-history-widget
zle accept-line
}
zle -N fzf-history-widget-accept
bindkey '^X^R' fzf-history-widget-accept
# in case I need java
# If you need to have openjdk first in your PATH, run:
# echo 'export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"' >> ~/.zshrc
# For compilers to find openjdk you may need to set:
# export CPPFLAGS="-I/opt/homebrew/opt/openjdk/include"
export VOLTA_HOME="$HOME/.volta"
export PATH="$VOLTA_HOME/bin:$PATH"
eval "$(zoxide init zsh)"
# eval "$(frum init)"
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
# Run compinit and compile its cache
zcomet compinit
# [ -z "$ZPROF" ] || zprof
# zprof
# pnpm
export PNPM_HOME="/Users/ttyrrell/Library/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end