-
Notifications
You must be signed in to change notification settings - Fork 0
/
private_dot_zshrc.tmpl
197 lines (161 loc) · 7.22 KB
/
private_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
# Personal Zsh configuration file. It is strongly recommended to keep all
# shell customization and configuration (including exported environment
# variables such as PATH) in this file or in files sourced from it.
#
# Documentation: https://github.com/romkatv/zsh4humans/blob/v5/README.md.
# Periodic auto-update on Zsh startup: 'ask' or 'no'.
# You can manually run `z4h update` to update everything.
zstyle ':z4h:' auto-update 'no'
# Ask whether to auto-update this often; has no effect if auto-update is 'no'.
zstyle ':z4h:' auto-update-days '28'
# Keyboard type: 'mac' or 'pc'.
{{- if eq .chezmoi.os "darwin" }}
zstyle ':z4h:bindkey' keyboard 'mac'
{{- else }}
zstyle ':z4h:bindkey' keyboard 'pc'
{{ end }}
{{- if eq .chezmoi.os "linux" }}
# Start tmux if not already in tmux.
#zstyle ':z4h:' start-tmux command tmux -u new -A -D -t z4h
{{- end }}
# Enable term shell integration
zstyle ':z4h:' term-shell-integration 'yes'
# Whether to move prompt to the bottom when zsh starts and on Ctrl+L.
zstyle ':z4h:' prompt-at-bottom 'yes'
# Mark up shell's output with semantic information.
zstyle ':z4h:' term-shell-integration 'yes'
# Right-arrow key accepts one character ('partial-accept') from
# command autosuggestions or the whole thing ('accept')?
zstyle ':z4h:autosuggestions' forward-char 'accept'
# Recursively traverse directories when TAB-completing files.
zstyle ':z4h:fzf-complete' recurse-dirs 'no'
# Enable direnv to automatically source .envrc files.
zstyle ':z4h:direnv' enable 'no'
# Show "loading" and "unloading" notifications from direnv.
zstyle ':z4h:direnv:success' notify 'yes'
# Enable ('yes') or disable ('no') automatic teleportation of z4h over
# SSH when connecting to these hosts.
#zstyle ':z4h:ssh:example-hostname1' enable 'yes'
#zstyle ':z4h:ssh:*.example-hostname2' enable 'no'
zstyle ':z4h:ssh:*noname0*' enable 'yes'
zstyle ':z4h:ssh:*noname1*' enable 'yes'
# The default value if none of the overrides above match the hostname.
zstyle ':z4h:ssh:*' enable 'no'
# Send these files over to the remote host when connecting over SSH to the
# enabled hosts.
#zstyle ':z4h:ssh:*' send-extra-files '~/.nanorc' '~/.env.zsh'
zstyle ':z4h:ssh:*' send-extra-files '~/.vim/vimrc' '~/.zsh_functions'
# Addionnal config for z4h teleportatio over SSH
zstyle ':completion:*:ssh:argument-1:' tag-order hosts users
zstyle ':completion:*:scp:argument-rest:' tag-order hosts files users
zstyle ':completion:*:(ssh|scp|rdp):*:hosts' hosts
# Makes transient prompt work properly when closing ssh connections
#z4h bindkey z4h-eof Ctrl+D
#setopt ignore_eof
# Terminal title
zstyle ':z4h:term-title:ssh' preexec '%n@%m: ${1//\%/%%}'
zstyle ':z4h:term-title:ssh' precmd '%n@%m: %~'
zstyle ':z4h:term-title:local' preexec '${1//\%/%%}'
zstyle ':z4h:term-title:local' precmd '%~ %*'
# Inactive zsh-syntax-highlighting
zstyle ':z4h:zsh-syntax-highlighting' channel 'none'
# Clone additional Git repositories from GitHub.
#
# This doesn't do anything apart from cloning the repository and keeping it
# up-to-date. Cloned files can be used after `z4h init`.
z4h install ohmyzsh/ohmyzsh || return # Install ohmyzsh
z4h install zdharma-continuum/fast-syntax-highlighting || return # Install fast-syntax-highlighting
{{- if eq .chezmoi.os "linux" }}
if [[ -e ~/.ssh/keys/.loadkeys ]]; then
zstyle ':z4h:ssh-agent:' start yes
zstyle ':z4h:ssh-agent:' extra-args -t 20h
fi
{{ end }}
# Install or update core components (fzf, zsh-autosuggestions, etc.) and
# initialize Zsh. After this point console I/O is unavailable until Zsh
# is fully initialized. Everything that requires user interaction or can
# perform network I/O must be done above. Everything else is best done below.
z4h init || return
# Extend PATH.
path=(~/.local/bin ${HOMEBREW_PREFIX}/opt/ruby/bin ${KREW_ROOT:-$HOME/.krew}/bin $HOME/.rd/bin ${HOME}/.pkenv/bin ${HOMEBREW_PREFIX}/openssl@3/bin $path)
# Prompt smooth rendering
# See https://github.com/romkatv/zsh4humans/blob/master/tips.md#prompt
POSTEDIT=$'\n\n\e[2A'
# Export environment variables.
export GPG_TTY=$TTY
export EDITOR=nvim
export VISUAL=nvim
export ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
export AWS_CONFIG_FILE="$XDG_CONFIG_HOME"/aws/config
export AWS_SHARED_CREDENTIALS_FILE="$XDG_CONFIG_HOME"/aws/credentials
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/workspace
{{- if (and (eq .chezmoi.os "linux") (.chezmoi.kernel.osrelease | lower | contains "microsoft")) }}
export PATH="/opt/google-cloud-cli/bin:$PATH"
export BROWSER=/usr/bin/wslview # wslview is a part of wslu
{{- end }}
# Source additional local files if they exist.
source <(ng completion script)
z4h source ~/.zsh_functions
z4h source ${ASDF_DIR}/asdf.sh
z4h source ${HOMEBREW_PREFIX}/bin/virtualenvwrapper.sh
z4h source ${HOME}/.cargo/env
z4h source ${HOMEBREW_PREFIX}/opt/nvm/nvm.sh
z4h source $Z4H/ohmyzsh/ohmyzsh/lib/cli.zsh
{{- if (and (eq .chezmoi.os "linux") (.chezmoi.kernel.osrelease | lower | contains "microsoft")) }}
z4h source /usr/share/doc/pkgfile/command-not-found.zsh
z4h source /usr/share/bash-completion/completions/az
{{- end }}
z4h load ohmyzsh/ohmyzsh/plugins/aws
z4h load ohmyzsh/ohmyzsh/plugins/gitignore
z4h load ohmyzsh/ohmyzsh/plugins/shell-proxy
z4h load zdharma-continuum/fast-syntax-highlighting
# Define key bindings.
z4h bindkey z4h-backward-kill-word Ctrl+Backspace Ctrl+H
z4h bindkey z4h-backward-kill-zword Ctrl+Alt+Backspace
z4h bindkey undo Ctrl+/ Shift+Tab # undo the last command line change
z4h bindkey redo Alt+/ # redo the last undone command line change
z4h bindkey z4h-cd-back Alt+Left # cd into the previous directory
z4h bindkey z4h-cd-forward Alt+Right # cd into the next directory
z4h bindkey z4h-cd-up Alt+Up # cd into the parent directory
z4h bindkey z4h-cd-down Alt+Down # cd into a child directory
# Autoload functions.
autoload -Uz zmv
autoload edit-command-line
#bindkey -v
#zle -N edit-command-line-inplace
#bindkey -M vicmd v edit-command-line
#bindkey "^E" edit-command-line-inplace
# Define functions
#unalias md # remove alias from omz/directories
function md() { [[ $# == 1 ]] && mkdir -p -- "$1" && cd -- "$1" }
# ==> see also .zsh_function
# Deal with completions.
compdef _directories md
fpath=($HOME/.local/share/zsh/site-functions ${ASDF_DIR}/completions $fpath)
# Define aliases.
alias clear=z4h-clear-screen-soft-bottom
alias tree='tree -a -I .git'
alias diff='diff --color'
# Add flags to existing aliases.
if [[ "$(uname -s)" == "Darwin" ]]; then
alias rm="grm"
alias ls="gls --group-directories-first --color=auto --literal"
else
#alias ls="ls --group-directories-first --color=auto --literal"
alias ls="eza --group-directories-first --icons=always $@"
fi
alias ll="${aliases[ls]:-ls} -lh --git"
alias la="${aliases[ll]:-ls} -A"
alias l="${aliases[ll]:-ls}"
alias vi="nvim"
#export PYENV_ROOT="$HOME/.pyenv"
if (command -v pyenv >/dev/null); then
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
fi
## Set shell options: http://zsh.sourceforge.net/Doc/Release/Options.html.
setopt glob_dots # no special treatment for file names with a leading dot
setopt no_auto_menu # require an extra TAB press to open the completion menu
# Load Angular CLI autocompletion.
source <(ng completion script)