-
Notifications
You must be signed in to change notification settings - Fork 1
/
dot_zshrc.tmpl
161 lines (138 loc) · 4.94 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
# Directly start sway if we're on tty1
if [ "$(tty)" = "/dev/tty1" ]; then
exec sway-run
fi
# 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
# Back out if we're surrounded by Emacs
[ "$TERM" = "eterm-color" ] && exec bash
[ "$TERM" = "xterm-termite" ] && export TERM=xterm-256color
# Back out if we are in a Emacs tramp session
if [[ $TERM == "eterm-color " ]] || [[ $TERM == "dumb" ]]; then
unsetopt zle
PS1='$ '
return
fi
plugins=(fzf fasd tmuxinator)
fpath=( ~/.kubectx/completion "${fpath[@]}" )
ZSH_CUSTOM="${HOME}/.zsh-custom"
{{- if eq .chezmoi.fullHostname "mcnaught.uberspace.de" }}
ZSH_THEME="jreese"
{{ else }}
ZSH_THEME="powerlevel10k/powerlevel10k"
{{- end }}
FZF_MARKS_FILE="${HOME}/.config/fzf/${HOST}"
export ZSH=${HOME}/.oh-my-zsh
export DISABLE_AUTO_UPDATE="true"
source $ZSH/oh-my-zsh.sh
source $ZSH_CUSTOM/plugins/fzf-marks/fzf-marks.plugin.zsh
alias va="vagrant"
alias bi="bundle install"
alias be="bundle exec"
alias ber="bundle exec rake"
alias e=$EDITOR
alias ssh-yop="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
alias docker-rm-stopped="docker rm (docker ps -a -q)"
alias docker-rm-dangling="docker rmi (docker images -q -f dangling=true)"
alias dco="docker-compose"
alias dcorrm="docker-compose run --rm"
alias emacseval="emacs -batch -l ~/.emacs.d/init.el -eval '(org-batch-agenda "a")'"
alias drri="docker run --rm -ti"
alias dry="drri -v /var/run/docker.sock:/var/run/docker.sock skanehira/docui"
alias k=kubectl
alias kgp="kubectl get pods"
alias krs="kubectl rollout status"
alias g=git
alias gpr="git pull -r"
alias git-cleanup-merged-branches="git fetch -va && git branch --merged | egrep -v '(^\*|master)' | xargs git branch -d"
alias wttr="curl 'wttr.in/Bogenhausen?1pQF&lang=de'"
alias termbin="nc termbin.com 9999"
alias ssh='TERM=xterm-256color ssh'
alias sudo='TERM=xterm-256color sudo'
alias gp="gopass"
alias hl="hledger"
alias cm="chezmoi"
alias ls="exa --icons"
alias cm-private="chezmoi -S ~/.local/share/chezmoi-private"
alias kn="kubens"
# Global Aliases
alias -g B="|bat"
alias -g baml="|bat -l yaml"
alias -g obaml="-o yaml|bat -l yaml"
# Switch between multiple kubeconfigs, stored in gopass
kp() { export KUBECONFIG=/dev/shm/kubeconfig-${1} && gopass $(gopass ls -f | fzf --query "'${1} kubeconfig" --select-1) > $KUBECONFIG && source <(kubectl completion zsh) }
# Give my <tab> key some rest
kfp() { kubectl get pod -l app="${1:-$(basename $PWD)}" -o jsonpath="{.items[0].metadata.name}" }
kpe() { kubectl exec -ti $(kfp ${1:-$(basename $PWD)}) $2 }
kpb() { kpe ${1:-$(basename $PWD)} bash }
kgc() { k get pod $(kfp) -o jsonpath="{.spec.containers[*].name}" | tr -s '[[:space:]]' '\n' }
kgl() { kubectl logs -f $(kfp ${1:-$(basename $PWD)}) $(kgc|fzf) }
timestamp() { date +%Y-%m-%d-%H%M%S }
letterup() {
if [[ ! -a $1 ]]; then
take $1;
cp -a ~/Documents/Personal/Brief-Vorlage/2017-LaTeX/* .;
else
cd $1;
fi;
tmuxinator start letter;
}
# Pretty up FZF
export FZF_DEFAULT_OPTS='
--prompt=" "
--border
--height="40%"
--layout=reverse
--color=bg+:#f0f0f1,bg:#fafafa,spinner:#0184bc,hl:#4078f2
--color=fg:#696c77,header:#4078f2,info:#c18401,pointer:#0184bc
--color=marker:#0184bc,fg+:#202227,prompt:#c18401,hl+:#4078f2
'
#source /usr/share/zsh/site-functions/tmuxinator.zsh
# Via @dohq
# https://gist.github.com/dohq/1dc702cc0b46eb62884515ea52330d60
function fzf-ssh () {
local selected_host=$(grep "Host " ~/.ssh/config | grep -v '*' | cut -b 6- | fzf --reverse --height=20 --query "$LBUFFER")
if [ -n "$selected_host" ]; then
BUFFER="ssh ${selected_host}"
zle accept-line
fi
zle reset-prompt
}
# Only load kubectl completion when needed. I's bog-slow
if [[ -f $KUBECONFIG ]]; then
source <(kubectl completion zsh);
fi;
zle -N fzf-ssh
bindkey '\es' fzf-ssh
function fzf-vm () {
local selected_vm=$(grep "Host " ~/.ssh/config | grep -oP "vm-(\w+)" | sort -u | cut -b 4- | fzf --reverse --height=20 --query "$LBUFFER")
if [ -n "$selected_vm" ]; then
BUFFER="vm ${selected_vm} ''"
zle accept-line
fi
zle reset-prompt
}
zle -N fzf-vm
bindkey '\ev' fzf-vm
function fzf-ta () {
tmux attach $(tmux ls -F "#{session_name}" | fzf)
}
zle -N fzf-ta
bindkey '\et' fzf-ta
# Via @leahneukirchen
autoload -Uz copy-earlier-word
zle -N copy-earlier-word
bindkey "^[m" copy-earlier-word
if [ -f ~/Code/architecture/bin/ia ]; then
source <(~/Code/architecture/bin/ia completion)
fi;
if [ -f /home/bascht/Code/infrastructure-cli/Rakefile ]; then
alias chuck="rake -f /home/bascht/Code/infrastructure-cli/Rakefile"
fi;
source ~/.zsh-custom/plugins/
source ~/.p10k.zsh
autoload -U compinit && compinit