-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
208 lines (173 loc) · 6.22 KB
/
.zshrc
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
199
200
201
202
203
204
205
206
207
208
# 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
# tmux
case $- in *i*)
if [ -z "$TMUX" ]; then exec tmux; fi;;
esac
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="robbyrussell"
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
autojump
ansible
colorize
common-aliases
docker
docker-compose
helm
kubectl
kube-ps1
python
rsync
safe-paste
sudo
systemadmin
systemd
terraform
tmux
vi-mode
vundle
# zsh-autosuggestions
gcloud
)
source $ZSH/oh-my-zsh.sh
# aliases
alias v="nvim"
alias v.="nvim ."
alias vi="nvim"
alias vim="nvim"
alias pip="pip3"
alias lg="lazygit"
alias k="kubectl"
alias kubectl="kubecolor"
alias krew="kubectl krew"
alias kns="kubens"
alias kctx="kubectx"
alias kon="kubeon"
alias kof="kubeoff"
alias ts="tmux-sessionizer"
alias ghd="gh dash"
alias restish="noglob restish"
alias findhost='ssh exoadmin@infra-dns003 findhost \$1\'
#alias findhost='ssh [email protected] findhost'
alias exo-irc="ssh irc -t 'tmux attach; bash -l'"
alias exo-api-pp="export EXOSCALE_API_KEY=$EXOSCALE_API_KEY_PP; export EXOSCALE_API_SECRET=$EXOSCALE_API_SECRET_PP; export EXOSCALE_API_ENDPOINT=$EXOSCALE_API_ENDPOINT_PP; export EXOSCALE_API_ENVIRONMENT=$EXOSCALE_API_ENVIRONMENT_PP"
alias exo-api-prod="export EXOSCALE_API_KEY=$EXOSCALE_API_KEY_PROD; export EXOSCALE_API_SECRET=$EXOSCALE_API_SECRET_PROD; unset EXOSCALE_API_ENDPOINT; unset EXOSCALE_API_ENVIRONMENT"
alias exo-api-test="export EXOSCALE_API_KEY=$EXOSCALE_API_KEY_TEST; export EXOSCALE_API_SECRET=$EXOSCALE_API_SECRET_TEST; unset EXOSCALE_API_ENDPOINT; unset EXOSCALE_API_ENVIRONMENT"
alias exo-api-pp-julien="export EXOSCALE_API_KEY=$EXOSCALE_API_KEY_PP_PERSONAL; export EXOSCALE_API_SECRET=$EXOSCALE_API_SECRET_PP_PERSONAL; export EXOSCALE_API_ENDPOINT=$EXOSCALE_API_ENDPOINT_PP; export EXOSCALE_API_ENVIRONMENT=$EXOSCALE_API_ENVIRONMENT_PP"
alias exo-api-prod-julien="export EXOSCALE_API_KEY=$EXOSCALE_API_KEY_PROD_PERSONAL; export EXOSCALE_API_SECRET=$EXOSCALE_API_SECRET_PROD_PERSONAL; unset EXOSCALE_API_ENDPOINT; unset EXOSCALE_API_ENVIRONMENT"
alias exo-ts="tailscale status -json | jq '.BackendState, .TailscaleIPs, .CurrentTailnet'"
alias exo-tu="sudo tailscale logout && sudo tailscale up --accept-routes --hostname=laptop-julien-sudan --shields-up --stateful-filtering"
alias exo-tlo="sudo tailscale logout"
alias exo-cl='ssh [email protected] sudo puppet cert list'
# autocompletion
## general
autoload -U +X bashcompinit && bashcompinit
autoload -Uz compinit
compinit
## NOTE: must come before zsh-history-substring-search & zsh-syntax-highlighting.
autoload -U select-word-style
select-word-style bash # only alphanumeric chars are considered WORDCHARS
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=59'
ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd completion)
## kubectl
source <(kubectl completion zsh)
complete -F __start_kubectl k
## kubecolor
compdef kubecolor=kubectl
## aws
complete -C '/usr/bin/aws_completer' aws
## azure TODO: add it again later
# source /usr/share/bash-completion/completions/az
## terraform
complete -o nospace -C /usr/bin/terraform terraform
## fzf
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
## vagrant
fpath=(/opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/contrib/zsh $fpath)
## doctl
[[ $commands[doctl] ]] && source <(doctl completion zsh)
#
## openshift `oc`
if [ $commands[oc] ]; then
source <(oc completion zsh)
compdef _oc oc
fi
## talhelper
source <(talhelper completion zsh)
# options
export HISTSIZE=100000
export HISTFILE="$HOME/.history"
export SAVEHIST=$HISTSIZE
setopt NO_FLOW_CONTROL # disable start (C-s) and stop (C-q) characters
setopt HIST_FIND_NO_DUPS # don't show dupes when searching
setopt HIST_IGNORE_SPACE # [default] don't record commands starting with a space
setopt LIST_PACKED # make completion lists more densely packed
# Keybindings
## vi bindings
bindkey -v
## edit command with nvim
autoload -U edit-command-line
zle -N edit-command-line
bindkey '^x^x' edit-command-line
# Replace standard history-incremental-search-{backward,forward} bindings.
# These are the same but permit patterns (eg. a*b) to be used.
bindkey "^r" history-incremental-pattern-search-backward
bindkey "^s" history-incremental-pattern-search-forward
# Functions
## Change local git config
function gcexo() {
git config user.name "Julien Sudan"
git config user.email "[email protected]"
git config user.signingkey 9BEDF41A8472C335
}
function gcmain() {
git config user.name "Julien Sudan"
git config user.email "[email protected]"
git config user.signingkey 0B69285D11496F81
}
## Start command
function start() {
feh --bg-fill ~/personal/images/wallpaper-dune-2-09.jpg
$HOME/.config/polybar/launch.sh --forest
sudo systemctl restart logid.service
}
# Make CTRL-Z background things and unbackground them.
function fg-bg() {
if [[ $#BUFFER -eq 0 ]]; then
fg
else
zle push-input
fi
}
zle -N fg-bg
bindkey '^Z' fg-bg
# yazi gooodness
function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")"
yazi "$@" --cwd-file="$tmp"
if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
builtin cd -- "$cwd"
fi
rm -f -- "$tmp"
}
source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
complete -o nospace -C /usr/bin/tofu tofu
## zoxide
eval "$(zoxide init zsh)"