-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_zshrc.tmpl
198 lines (156 loc) · 5.9 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
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
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# 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
### Added by Zinit's installer
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit"
command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \
print -P "%F{33} %F{34}Installation successful.%f%b" || \
print -P "%F{160} The clone has failed.%f%b"
fi
source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
zdharma-continuum/zinit-annex-as-monitor \
zdharma-continuum/zinit-annex-bin-gem-node \
zdharma-continuum/zinit-annex-patch-dl \
zdharma-continuum/zinit-annex-rust
### End of Zinit's installer chunk
# Setup up some paths and environment variables
# homebrew
if [ -d "/opt/homebrew" ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
export PATH="${HOME}/bin:${HOME}/.local/bin:${PATH}"
# combustion directory
export COMBUSTION_DIR="${HOME}/combustion"
export MASA_HOME="${COMBUSTION_DIR}/install/MASA"
# pyenv
export PYENV_ROOT="${HOME}/.pyenv"
if [ -d "${PYENV_ROOT}" ]; then
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
fi
# poetry
if [ -d "${HOME}/.poetry" ]; then
export PATH="$HOME/.poetry/bin:$PATH"
fi
# exawind-manager
if [ -d "${HOME}/exawind/exawind-manager" ]; then
export EXAWIND_MANAGER=${HOME}/exawind/exawind-manager
source ${EXAWIND_MANAGER}/start.sh
fi
# zoxide
export _ZO_DATA_DIR=$HOME/.local/share
# hunspell dicts
if [ -d "${HOME}/.local/share/hunspell/dicts" ]; then
export DICPATH="${HOME}/.local/share/hunspell/dicts"
fi
export WORKON_HOME=${HOME}/.virtualenvs
{{- if eq .chezmoi.os "darwin" }}
# paths for Mac OSX
# github tokens
source "${HOME}/.github_tokens"
# openmpi fails because tmp dir name is too long
# see: https://www.open-mpi.org/faq/?category=osx
export TMPDIR=/tmp
# Set vlc for terminal
alias vlc="{HOME}/Applications/VLC.app/Contents/MacOS/VLC"
# Enchant lib path for python
if [[ ! -x "$(command -v pyenv)" ]]; then
export PYENCHANT_LIBRARY_PATH=/opt/homebrew/lib/libenchant-2.dylib
fi
{{- end }}
# towards the beginning to make sure some software is loaded
zinit lucid light-mode for "hpc"
zinit ice lucid depth"1"
zinit light romkatv/powerlevel10k
zinit wait lucid light-mode \
dl'https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/emacs/emacsclient.sh' \
atclone'chmod +x emacsclient.sh' \
atpull'%atclone' \
for "OMZP::emacs"
zinit wait lucid light-mode for \
"OMZP::fzf" \
has'fzf' @Aloxaf/fzf-tab \
"OMZP::git" \
"OMZP::poetry" \
"OMZP::pyenv" \
"OMZP::tmux" \
"OMZP::zoxide"
zinit ice lucid from"gh-r" as"command" \
mv"vivid-*/vivid -> vivid" \
atload'export LS_COLORS="$(vivid generate one-dark)"; zstyle ":completion:*" list-colors "${(s.:.)LS_COLORS}"'
zinit light sharkdp/vivid
# towards the end because it assumes some things are set in other plugins
zinit wait lucid light-mode for "personal"
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# OMZL options
zstyle ':omz:lib:theme-and-appearance' gnu-ls yes
ENABLE_CORRECTION="true"
CORRECT_IGNORE_FILE='.*'
# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=()
source $ZSH/oh-my-zsh.sh
# User configuration
# better terminal colors
export TERM=xterm-256color
# This is a bit sneaky... but nice!
# Separate up arrow lookback for local and global ZSH history
# http://superuser.com/questions/446594/separate-up-arrow-lookback-for-local-and-global-zsh-history/691603
# up/down arrow steps through LOCAL terminal history
# Ctrl-up/down steps through GLOBAL terminal history
# Ctrl-R searches global terminal history
bindkey "${terminfo[kpp]}" up-line-or-local-history
bindkey "${terminfo[knp]}" down-line-or-local-history
up-line-or-local-history() {
zle set-local-history 1
zle up-line-or-history
zle set-local-history 0
}
zle -N up-line-or-local-history
down-line-or-local-history() {
zle set-local-history 1
zle down-line-or-history
zle set-local-history 0
}
zle -N down-line-or-local-history
bindkey "^[[1;5A" up-line-or-history # [CTRL] + Cursor up
bindkey "^[[1;5B" down-line-or-history # [CTRL] + Cursor down
# Use ctrl-p/n to go up/down search
bindkey "^P" up-line-or-beginning-search
# bindkey "^N" down-line-or-beginning-search
# History
HISTFILE=~/.zsh_history
HISTSIZE=1000000
SAVEHIST=$HISTSIZE
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_FIND_NO_DUPS
# zsh history backups
export HIST_BACKUP_DIR="${HOME}/.zsh_history_backups"
if [ ! -d "${HIST_BACKUP_DIR}" ]; then
mkdir "${HIST_BACKUP_DIR}"
fi
function backup_zsh_history () {
if [ -d "${HIST_BACKUP_DIR}" ]; then
HISTFILE_BAK="${HIST_BACKUP_DIR}/zsh_history_$(date +\%Y_\%m_\%d).bak"
if [ ! -f "${HISTFILE_BAK}" ] && [ -f "${HISTFILE}" ]; then
cp "${HISTFILE}" "${HISTFILE_BAK}"
fi
fi
}
backup_zsh_history
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh