-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc.tmpl
143 lines (125 loc) · 4.43 KB
/
dot_zshrc.tmpl
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
# init zinit
ZINIT_HOME="${HOME}/.local/share/zinit/zinit.git"
[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)"
[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
source "${ZINIT_HOME}/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
# Critical environment variables (needed early)
export EDITOR=vim
export HOMEBREW_NO_ENV_HINTS=true
export SSH_AUTH_SOCK=$HOME/Library/Group\ Containers/2BUA8C4S2C.com.1password/t/agent.sock
export ASDF_FORCE_PREPEND=no
# History settings
HISTSIZE=50000
HISTFILE=~/.zsh_history
SAVEHIST=99999999
setopt appendhistory
setopt sharehistory
setopt incappendhistory
setopt histignorespace
# Load theme first
zinit light NICHOLAS85/z-a-eval
zi ice pick"spaceship.zsh" as"theme" depth"1"
zi light spaceship-prompt/spaceship-prompt
# Theme configuration
SPACESHIP_PROMPT_ORDER=(
user
dir
git
venv
exec_time
line_sep
jobs
exit_code
char
)
SPACESHIP_RPROMPT_ORDER=(time)
SPACESHIP_PROMPT_ADD_NEWLINE=false
SPACESHIP_TIME_SHOW=true
SPACESHIP_EXIT_CODE_SHOW=true
SPACESHIP_EXIT_CODE_COLOR=red
SPACESHIP_GIT_BRANCH_SHOW=true
SPACESHIP_GIT_BRANCH_ASYNC=true
SPACESHIP_GIT_BRANCH_COLOR="magenta"
SPACESHIP_GIT_STATUS_SHOW=false
# Custom git branch function for jj support
spaceship_git_branch () {
if [[ -d .jj ]] && command -v jj >/dev/null 2>&1; then
jj_branch=$(jj log -n 1 --ignore-working-copy --no-graph --color always -r @ -T 'surround(" ", " ", bookmarks.join(", "))')
jj_changes=$(jj log -n 1 --ignore-working-copy --no-graph --color always -r @ -T 'surround("(", ")", change_id.shortest(6) ++ " " ++ commit_id.shortest(6))')
spaceship::section --color "$SPACESHIP_GIT_BRANCH_COLOR" "$jj_branch$jj_changes"
else
[[ $SPACESHIP_GIT_BRANCH_SHOW == false ]] && return
vcs_info
local git_current_branch="$vcs_info_msg_0_"
[[ -z "$git_current_branch" ]] && return
[[ "$git_current_branch" == branchless/* ]] && git_current_branch="(detached)"
git_current_branch="${git_current_branch#heads/}"
git_current_branch="${git_current_branch/.../}"
spaceship::section --color "$SPACESHIP_GIT_BRANCH_COLOR" "$SPACESHIP_GIT_BRANCH_PREFIX$git_current_branch$SPACESHIP_GIT_BRANCH_SUFFIX"
fi
}
# URL magic
autoload -U url-quote-magic bracketed-paste-magic
zle -N self-insert url-quote-magic
zle -N bracketed-paste bracketed-paste-magic
# compinit / completions
autoload -Uz compinit
[[ ! -d ~/.local/share/zinit/completions ]] && mkdir -p ~/.local/share/zinit/completions
compinit -u -C
# Main plugin block
zi ice wait lucid atload'zstyle ":completion:*" fast-theme -q clean' atinit'zpcompinit; zpcdreplay'
zi wait lucid for \
zdharma-continuum/fast-syntax-highlighting \
atload"fast-theme -q clean" \
blockf \
zsh-users/zsh-completions \
atload'!_zsh_autosuggest_start' \
zsh-users/zsh-autosuggestions \
zdharma-continuum/history-search-multi-word
# zinit completion
zi ice has"jj" as"completion" id-as"jj-completion" \
atclone"mkdir -p ~/.local/share/zinit/completions" \
atload'source <(jj util completion zsh); source <(COMPLETE=zsh jj)'
zi light zdharma-continuum/null
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
# Colors
zinit ice atclone"/opt/homebrew/bin/gdircolors -b LS_COLORS > clrs.zsh" \
atpull'%atclone' pick"clrs.zsh" nocompile'!' \
atload'zstyle ":completion:*" list-colors "${(s.:.)LS_COLORS}"'
zinit light trapd00r/LS_COLORS
# Tools and utilities
zinit wait lucid for \
andrewferrier/fzf-z \
ptavares/zsh-direnv
# OMZ snippets
zi wait"0" lucid for \
OMZL::clipboard.zsh \
OMZL::history.zsh \
OMZP::brew/brew.plugin.zsh \
OMZP::command-not-found/command-not-found.plugin.zsh \
OMZP::git-extras/git-extras.plugin.zsh \
OMZP::kubectl/kubectl.plugin.zsh \
OMZP::sudo/sudo.plugin.zsh \
PZTM::osx
# Environment setup
zi wait lucid for \
atload'eval "$(/opt/homebrew/bin/brew shellenv)"' \
zdharma-continuum/null \
atload'export PATH=$HOME/.krew/bin:/usr/local/bin:$PATH' \
zdharma-continuum/null \
has"zoxide" \
atload'eval "$(zoxide init --cmd cd zsh)"' \
zdharma-continuum/null
# asdf
zi ice lucid wait="0" atload'
ASDF_DIR="$(brew --prefix asdf)/libexec"
export ASDF_DIR
source $ASDF_DIR/asdf.sh
'
zi light zdharma-continuum/null
# Custom configs
zi ice wait="1" lucid multisrc"~/.zsh/*.zsh"
zi light zdharma-continuum/null