Repository navigation
Expand file tree
/
Copy pathdotfile.zshrc
More file actions
173 lines (148 loc) · 4.69 KB
/
Copy pathdotfile.zshrc
File metadata and controls
173 lines (148 loc) · 4.69 KB
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
umask 022
bindkey -v # vi mode
alias ls="ls --color=tty -F"
alias ag="rg"
alias vim="nvim"
alias k="kubectl"
alias ck="colima kubectl"
###########
# Zsh options (bash shopt equivalents)
###########
setopt AUTO_CD
setopt APPEND_HISTORY
setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
setopt CORRECT # like cdspell
setopt CHECK_JOBS
unsetopt NOMATCH # avoid "no matches found" errors
###########
# PATH
###########
PATH=/opt/homebrew/bin:$PATH
PATH="$HOME/bin:$PATH"
PATH=$PATH:$HOME/bin
PATH=$PATH:$HOME/.local/bin
PATH=$PATH:~/.kube/plugins/jordanwilson230
PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
PATH="$HOME/.cargo/bin:$PATH"
PATH="$HOME/.atuin/bin/env:$PATH"
PATH="$HOME/.local/bin:$PATH"
export PATH
[[ -r '/Users/jarv/Downloads/gcloud/google-cloud-sdk/path.zsh.inc' ]] && . '/Users/jarv/Downloads/gcloud/google-cloud-sdk/path.zsh.inc'
###########
# Completion (native zsh)
###########
autoload -Uz compinit
compinit
# gcloud / azure
[[ -r '/Users/jarv/Downloads/gcloud/google-cloud-sdk/completion.zsh.inc' ]] && . '/Users/jarv/Downloads/gcloud/google-cloud-sdk/completion.zsh.inc'
[[ -r '/Users/jarv/lib/azure-cli/az.completion' ]] && . '/Users/jarv/lib/azure-cli/az.completion'
# ssh host completion
zstyle ':completion:*:(ssh|scp|sftp|rsync):*' hosts \
$(awk '{print $1}' ~/.ssh/known_hosts 2>/dev/null | sed 's/,.*//' | grep -v '^\[' | uniq) \
$(grep -i '^Host ' ~/.ssh/config 2>/dev/null | awk '{for(i=2;i<=NF;i++) print $i}')
###########
# Prompt
###########
eval "$(starship init zsh)"
###########
# History
###########
HISTFILESIZE=10000
HISTSIZE=10000
HISTDIR="$HOME/.zsh_histories/$(uname -n)"
[[ ! -d $HISTDIR ]] && mkdir -p "$HISTDIR"
HISTFILE="$HISTDIR/$(date +%Y_%m)"
export HISTFILESIZE HISTDIR HISTFILE
HISTIGNORE="ls:fg:bg:exit"
setopt HIST_IGNORE_ALL_DUPS
setopt EXTENDED_HISTORY
h() {
ls -tr ~/.zsh_histories/*/* ~/.bash_histories/*/* | xargs grep -i "$1"
}
###########
# fzf / rg defaults
###########
if type rg &>/dev/null; then
export FZF_DEFAULT_COMMAND='rg --files'
export FZF_DEFAULT_OPTS='-m --height 50% --border'
fi
export FZF_DEFAULT_OPTS='--bind ctrl-d:page-down,ctrl-u:page-up'
###########
# Git helpers
###########
git_diff() {
git diff --no-ext-diff -w "$@" | vim -R -
}
git-cd() {
if git rev-parse --show-toplevel >/dev/null 2>&1; then
cd "$(git rev-parse --show-toplevel)"
else
echo "Not in a Git repository."
fi
}
#########
# kube ctx reset
#########
kubectx-reset() {
kubectl config unset current-context
}
###########
# Misc exports
###########
[[ -r "$HOME/.config/zsh/local.zsh" ]] && source "$HOME/.config/zsh/local.zsh"
if command -v brew >/dev/null 2>&1; then
eval "$(brew shellenv)"
fi
# macOS: ssh keys are served by a password-manager agent (1Password/Bitwarden)
# selected per host in ~/.config/ssh/config.local, so SSH_AUTH_SOCK is left alone.
if [[ "$OSTYPE" == "linux-gnu"* ]] && [[ -S "$XDG_RUNTIME_DIR/ssh-agent.socket" ]]; then
SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
export SSH_AUTH_SOCK
fi
export VAULT_ADDR=https://vault.ops.gke.gitlab.net
export VAULT_PROXY_ADDR=socks5://localhost:18200
export GO111MODULE=on
EDITOR=$(which nvim)
VISUAL=$EDITOR
FCEDIT=$EDITOR
PAGER=$(which less)
export EDITOR VISUAL FCEDIT PAGER
LESS="-f-R-P?f[%f]:[STDIN].?m(file %i of %m)?x[Next\: %x]. .?lb [line %lb?L/%L]..?e(END) :?pB [%pB\%]..%t"
RI='--format ansi'
export LESS RI
###########
# mise, direnv, atuin (zsh versions)
###########
command -v mise >/dev/null && eval "$(mise activate zsh)"
command -v direnv >/dev/null && eval "$(direnv hook zsh)"
command -v atuin >/dev/null && eval "$(atuin init zsh --disable-up-arrow)"
# kubectl
command -v kubectl >/dev/null && source <(kubectl completion zsh)
###########
# fzf
###########
if [[ ! "$PATH" == */opt/homebrew/opt/fzf/bin* ]]; then
PATH="${PATH:+${PATH}:}/opt/homebrew/opt/fzf/bin"
fi
# ###########
# # Predictive completions
# ###########
#
# # zsh-autosuggestions (predictive ghost text from history)
# if [[ -r /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]]; then
# source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8' # dim gray for suggestions
# fi
#
# # zsh-syntax-highlighting (color commands as you type)
# if [[ -r /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]]; then
# source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# fi
#
# # Key bindings for accepting suggestions
# bindkey '^ ' autosuggest-accept # Ctrl+Space accepts full suggestion
# bindkey '^P' history-beginning-search-backward # Up (like fish shell)
# bindkey '^N' history-beginning-search-forward # Down (like fish shell)