-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzi-config.zsh
133 lines (107 loc) · 4.42 KB
/
zi-config.zsh
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
### Load ZI (https://github.com/z-shell/zi)
# Docs: https://wiki.zshell.dev/docs/guides/syntax/ice-modifiers
export ZI_HOME="${HOME}/.zi"
if [[ ! -f "$ZI_HOME/bin/zi.zsh" ]]; then
print -P "%F{33}▓▒░ %F{220}Installing %F{33}Z-SHELL%F{220} A Swiss Army Knife for Zsh (%F{33}z-shell/zi%F{220})…%f"
command mkdir -p "$ZI_HOME" && command chmod g-rwX "$ZI_HOME"
command git clone https://github.com/z-shell/zi.git "$ZI_HOME/bin" && \
print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \
print -P "%F{160}▓▒░ The clone has failed.%f%b"
fi
source "$ZI_HOME/bin/zi.zsh"
autoload -Uz _zi
(( ${+_comps} )) && _comps[zi]=_zi
# Annexes (extensions) for ZI. Adds ice modifiers:
# - patch-dl: Download and apply patches. ice: `dl` `patch`
# - bin-gem-node: Executable not on PATH. `fbin` ice
zi light-mode for \
z-shell/z-a-patch-dl \
z-shell/z-a-bin-gem-node
## Modules
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=1"
zi ice id-as="autosuggestions"; zi light zsh-users/zsh-autosuggestions
# Completions
zi ice wait lucid blockf id-as="zsh-completions"
zi light zsh-users/zsh-completions
zi snippet PZT::modules/completion
zstyle ':completion:*' completer _complete _match _expand
zi ice as="completion" id-as="docker-completions"
zi snippet https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker
zi wait lucid light-mode depth=1 for \
pick="autopair.zsh" atload="autopair-init" hlissner/zsh-autopair \
pick="async.zsh" mafredri/zsh-async
# Fuzzy Finder package (from z-shell/fzf) (ctrl + T)
zi pack"default+keys" for fzf
# Fasd
zi ice as="command" pick="$ZPFX/bin/fasd" make="!PREFIX=$ZPFX install" \
atclone="mkdir -p $ZPFX/bin; cp -vf fasd $ZPFX/bin" atpull="%atclone" depth=1 \
atload='eval "$(fasd --init auto)"'
zi light clvv/fasd
## History search
# ctrl-r
zi light-mode for \
z-shell/H-S-MW \
zsh-users/zsh-history-substring-search
# ZI plugin for diff-so-fancy https://github.com/z-shell/zsh-diff-so-fancy
zi ice wait lucid as'program' pick'bin/git-dsf'
zi load z-shell/zsh-diff-so-fancy
## Theme
# Font
zi ice id-as"meslo" from"gh-r" as"null" bpick"Meslo.zip" extract depth=1 \
atclone="rm -f *Windows*; mv -f *.ttf $HOME/Library/Fonts/" atpull"%atclone"
zi light ryanoasis/nerd-fonts
# Use either Oh-My-Posh or Powerlevel10k (default) for rendering depending on the Terminal
if [ "$TERM_PROGRAM" = "WarpTerminal" ] && [ "$DISABLE_OH_MY_POSH" != "1" ]; then
eval "$(oh-my-posh init zsh --config ~/.config/oh-my-posh.omp.json)"
# eval "$(starship init zsh)"
else
zi ice depth=1; zi load romkatv/powerlevel10k
if [[ ($(ps -p $PPID) =~ 'Visual Studio') && (-f ~/.p10k-lean.zsh) ]] then; source ~/.p10k-lean.zsh
elif [[ -f ~/.p10k.zsh ]] then; source ~/.p10k.zsh
fi
fi
## Version Managers
# Tarball with the bin-gem-node annex-utilizing ice list
# zi wait"1" lucid pack"bgn" depth=1 for pyenv
# lucid: Removes `loaded` message for async
## ASDF
function _post_zi_asdf() {
export ASDF_DIR=${ASDF_DIR:-"$ZI[PLUGINS_DIR]/asdf"}
export ASDF_HOME=${ASDF_HOME:-"$HOME/.asdf"}
# Set JAVA_HOME
if [[ -f "$ASDF_HOME/plugins/java/set-java-home.zsh" ]]; then
source "$HOME/.asdf/plugins/java/set-java-home.zsh"
fi
# Set golang config
if [[ -d "$ASDF_HOME/plugins/golang" ]]; then
export GOROOT=$(asdf where golang)/go
export GOPATH=$(asdf where golang)/packages
export PATH="${PATH}:$(go env GOPATH)/bin"
fi
# Hook direnv into zsh
# &>: Redirect file descriptor 1-2 (STDOUT-STERR, 0 is STDIN) to the file on the other side of operand
if [[ -d "$ASDF_HOME/plugins/direnv" ]]; then
if command -v direnv &> /dev/null; then
# Use system managed version
export ASDF_DIRENV_BIN="$(command -v direnv)"
eval "$($ASDF_DIRENV_BIN hook zsh)"
else
eval "$(asdf exec direnv hook zsh)"
direnv() { asdf exec direnv "$@"; }
fi
[[ ! -f "$HOME/.envrc" ]] && echo 'use asdf' > "$HOME/.envrc"
fi
}
# The commented line configures ASDF adding shims to the PATH. In which case global .envrc is not needed
# Must be AFTER framework (oh-my-posh)
zi ice wait lucid depth=1 id-as="asdf" pick="asdf.sh" atload='!_post_zi_asdf'
zi light asdf-vm/asdf
## END ASDF
# Syntax highlight must be the last one
zi wait lucid for id-as="fast-highlight" \
atinit"ZI[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \
z-shell/F-SY-H
# Call compinit after load zsh-completions
autoload -Uz compinit
# Man pages
[[ -d $ZPFX/man ]] && export MANPATH="$ZPFX/man:$MANPATH"