2019-10-14 17:30:02 +02:00
|
|
|
# Directly start sway if we're on tty1
|
|
|
|
if [ "$(tty)" = "/dev/tty1" ]; then
|
2019-10-18 16:43:44 +02:00
|
|
|
exec sway-run
|
2019-10-14 17:30:02 +02:00
|
|
|
fi
|
|
|
|
|
2020-06-22 16:34:40 +02:00
|
|
|
# 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
|
|
|
|
|
2018-02-14 11:19:39 +01:00
|
|
|
# Back out if we're surrounded by Emacs
|
|
|
|
[ "$TERM" = "eterm-color" ] && exec bash
|
2019-07-30 23:54:50 +02:00
|
|
|
[ "$TERM" = "xterm-termite" ] && export TERM=xterm-256color
|
2018-02-14 11:19:39 +01:00
|
|
|
|
2019-03-07 11:28:43 +01:00
|
|
|
# Back out if we are in a Emacs tramp session
|
2019-07-30 23:54:50 +02:00
|
|
|
if [[ $TERM == "eterm-color " ]] || [[ $TERM == "dumb" ]]; then
|
|
|
|
unsetopt zle
|
|
|
|
PS1='$ '
|
|
|
|
return
|
|
|
|
fi
|
2019-03-07 11:28:43 +01:00
|
|
|
|
2020-07-23 12:09:51 +02:00
|
|
|
plugins=(fzf fasd tmuxinator)
|
2019-07-30 23:54:50 +02:00
|
|
|
fpath=( ~/.kubectx/completion "${fpath[@]}" )
|
2018-04-12 09:44:52 +02:00
|
|
|
|
2019-07-30 23:54:50 +02:00
|
|
|
ZSH_CUSTOM="${HOME}/.zsh-custom"
|
2022-04-04 11:25:28 +02:00
|
|
|
{{- if eq .chezmoi.fqdnHostname "mcnaught.uberspace.de" }}
|
2020-02-22 18:33:59 +01:00
|
|
|
ZSH_THEME="jreese"
|
|
|
|
{{ else }}
|
2019-07-30 23:54:50 +02:00
|
|
|
ZSH_THEME="powerlevel10k/powerlevel10k"
|
2020-02-22 18:33:59 +01:00
|
|
|
{{- end }}
|
2019-10-02 13:48:00 +02:00
|
|
|
FZF_MARKS_FILE="${HOME}/.config/fzf/${HOST}"
|
2017-12-05 22:12:38 +01:00
|
|
|
|
2020-10-08 10:06:02 +02:00
|
|
|
export ZSH=${HOME}/.oh-my-zsh
|
2020-03-11 11:43:36 +01:00
|
|
|
export DISABLE_AUTO_UPDATE="true"
|
2018-04-23 08:27:53 +02:00
|
|
|
|
2019-07-30 23:54:50 +02:00
|
|
|
source $ZSH/oh-my-zsh.sh
|
|
|
|
source $ZSH_CUSTOM/plugins/fzf-marks/fzf-marks.plugin.zsh
|
2021-03-08 15:04:02 +01:00
|
|
|
source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh
|
2018-10-29 16:20:38 +01:00
|
|
|
|
2021-01-11 16:17:41 +01:00
|
|
|
{{- if or (eq .chezmoi.hostname "pierogi") (eq .chezmoi.hostname "apfelstrudel") }}
|
2020-12-28 21:19:49 +01:00
|
|
|
export GPG_TTY="$(tty)"
|
|
|
|
export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
|
|
|
|
gpg-connect-agent updatestartuptty /bye &> /dev/null
|
|
|
|
{{- end }}
|
|
|
|
|
2017-12-05 22:12:38 +01:00
|
|
|
alias va="vagrant"
|
|
|
|
alias bi="bundle install"
|
|
|
|
alias be="bundle exec"
|
|
|
|
alias ber="bundle exec rake"
|
|
|
|
alias e=$EDITOR
|
2021-03-12 00:10:44 +01:00
|
|
|
alias vim=nvim
|
2017-12-05 22:12:38 +01:00
|
|
|
alias ssh-yop="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
2021-09-22 10:13:25 +02:00
|
|
|
alias scp-yop="scp -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
2017-12-05 22:12:38 +01:00
|
|
|
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"
|
2019-02-07 10:51:30 +01:00
|
|
|
alias dcorrm="docker-compose run --rm"
|
2017-12-05 22:12:38 +01:00
|
|
|
alias emacseval="emacs -batch -l ~/.emacs.d/init.el -eval '(org-batch-agenda "a")'"
|
2019-10-15 22:13:35 +02:00
|
|
|
alias drri="docker run --rm -ti"
|
|
|
|
alias dry="drri -v /var/run/docker.sock:/var/run/docker.sock skanehira/docui"
|
2019-03-07 11:28:35 +01:00
|
|
|
alias k=kubectl
|
2020-05-27 12:24:55 +02:00
|
|
|
alias kgp="kubectl get pods"
|
|
|
|
alias krs="kubectl rollout status"
|
2019-07-31 02:02:41 +02:00
|
|
|
alias g=git
|
2019-06-05 13:23:26 +02:00
|
|
|
alias git-cleanup-merged-branches="git fetch -va && git branch --merged | egrep -v '(^\*|master)' | xargs git branch -d"
|
2022-01-18 21:13:52 +01:00
|
|
|
alias wttr="curl 'wttr.in/Neuwied?1pQF&lang=de'"
|
2019-10-25 17:16:11 +02:00
|
|
|
alias termbin="nc termbin.com 9999"
|
2020-01-20 12:20:03 +01:00
|
|
|
alias gp="gopass"
|
|
|
|
alias hl="hledger"
|
2020-01-27 17:18:47 +01:00
|
|
|
alias cm="chezmoi"
|
2022-01-18 21:14:04 +01:00
|
|
|
alias cm-add-changed-file="cm add \$(cm diff|grep ^install|cut -d ' ' -f 5|fzf)"
|
2020-01-27 17:18:47 +01:00
|
|
|
alias cm-private="chezmoi -S ~/.local/share/chezmoi-private"
|
2022-01-18 21:14:04 +01:00
|
|
|
alias ls="exa --icons"
|
2020-05-27 12:24:55 +02:00
|
|
|
alias kn="kubens"
|
2021-10-01 09:40:50 +02:00
|
|
|
alias alfaview-logfile="/usr/bin/env ls -d -- ~/.local/share/alfaview-staging/logs/*.log|tail -n 1"
|
2021-06-04 13:16:46 +02:00
|
|
|
alias ta="tmux attach -t \$(tmux ls -F '#{session_name}' | fzf)"
|
2021-10-12 12:14:39 +02:00
|
|
|
alias gf="git fetch -a && git rebase && git --no-pager today-all && echo -n '\n'"
|
2021-11-02 09:56:53 +01:00
|
|
|
alias gbb="BRANCH=\$(git for-each-ref refs/heads/ --format='%(refname:short)' | fzf); git fetch origin \${BRANCH} && git checkout \${BRANCH}"
|
2022-02-04 20:54:25 +01:00
|
|
|
alias tdir="take \$(mktemp -d --suffix=\".\$(basename \${PWD})\")"
|
2020-05-27 12:24:55 +02:00
|
|
|
|
|
|
|
# Global Aliases
|
|
|
|
alias -g B="|bat"
|
|
|
|
alias -g baml="|bat -l yaml"
|
2020-08-25 11:11:08 +02:00
|
|
|
alias -g obaml="-o yaml|bat -l yaml"
|
2020-05-27 12:24:55 +02:00
|
|
|
|
|
|
|
# Switch between multiple kubeconfigs, stored in gopass
|
2022-02-04 21:00:44 +01:00
|
|
|
kp() { export KUBECONFIG=/dev/shm/kubeconfig-${1} && touch $KUBECONFIG && chmod 0600 $KUBECONFIG && gopass $(gopass ls -f | fzf --query "'${1} kubeconfig" --select-1) > $KUBECONFIG && source <(kubectl completion zsh) }
|
2020-07-07 10:24:24 +02:00
|
|
|
# Give my <tab> key some rest
|
2020-08-25 11:11:33 +02:00
|
|
|
kfp() { kubectl get pod -l app="${1:-$(basename $PWD)}" -o jsonpath="{.items[0].metadata.name}" }
|
2020-07-23 12:09:51 +02:00
|
|
|
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) }
|
2020-07-07 10:24:24 +02:00
|
|
|
|
2020-06-18 17:20:44 +02:00
|
|
|
letterup() {
|
|
|
|
if [[ ! -a $1 ]]; then
|
|
|
|
take $1;
|
2021-08-01 22:43:14 +02:00
|
|
|
cp ~/Documents/Personal/Brief-Vorlage/2021-LaTeX-Reworked/template.tex brief.tex;
|
2020-06-18 17:20:44 +02:00
|
|
|
else
|
|
|
|
cd $1;
|
|
|
|
fi;
|
|
|
|
tmuxinator start letter;
|
|
|
|
}
|
2021-08-01 22:43:14 +02:00
|
|
|
letterbuild() {
|
|
|
|
podman run -e VERBOSE=false -i --rm letter < $(*.tex) > $(basename *tex .tex)
|
|
|
|
}
|
|
|
|
|
2018-02-07 07:30:29 +01:00
|
|
|
|
2019-07-31 02:02:41 +02:00
|
|
|
# Pretty up FZF
|
|
|
|
export FZF_DEFAULT_OPTS='
|
2019-07-31 02:27:27 +02:00
|
|
|
--prompt=" "
|
2020-07-23 12:09:51 +02:00
|
|
|
--border
|
|
|
|
--height="40%"
|
|
|
|
--layout=reverse
|
2019-10-25 22:23:06 +02:00
|
|
|
--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
|
2019-07-31 02:02:41 +02:00
|
|
|
'
|
2021-07-21 20:26:22 +02:00
|
|
|
|
2019-06-05 13:22:52 +02:00
|
|
|
# Via @dohq
|
|
|
|
# https://gist.github.com/dohq/1dc702cc0b46eb62884515ea52330d60
|
|
|
|
function fzf-ssh () {
|
2019-07-30 23:54:50 +02:00
|
|
|
local selected_host=$(grep "Host " ~/.ssh/config | grep -v '*' | cut -b 6- | fzf --reverse --height=20 --query "$LBUFFER")
|
2019-06-05 13:22:52 +02:00
|
|
|
|
|
|
|
if [ -n "$selected_host" ]; then
|
|
|
|
BUFFER="ssh ${selected_host}"
|
|
|
|
zle accept-line
|
|
|
|
fi
|
|
|
|
zle reset-prompt
|
|
|
|
}
|
|
|
|
|
2019-10-15 20:28:49 +02:00
|
|
|
# Only load kubectl completion when needed. I's bog-slow
|
2019-10-18 16:42:58 +02:00
|
|
|
if [[ -f $KUBECONFIG ]]; then
|
2019-10-15 20:28:49 +02:00
|
|
|
source <(kubectl completion zsh);
|
|
|
|
fi;
|
|
|
|
|
2019-06-05 13:22:52 +02:00
|
|
|
zle -N fzf-ssh
|
|
|
|
bindkey '\es' fzf-ssh
|
|
|
|
|
2022-03-18 12:47:44 +01:00
|
|
|
# Editors
|
|
|
|
bindkey -s '\ege' "em -nw .^M"
|
|
|
|
|
2021-07-15 00:47:26 +02:00
|
|
|
# Tmux Quick Keys
|
2021-09-24 11:08:15 +02:00
|
|
|
bindkey -s '\egtn' 'tn^M'
|
|
|
|
bindkey -s '\egta' "ta^M"
|
2021-07-15 00:47:26 +02:00
|
|
|
|
|
|
|
# Git Quick Keys
|
2021-09-24 11:08:15 +02:00
|
|
|
bindkey -s '\eggf' "gf^M"
|
|
|
|
bindkey -s '\eggp' "git push^M"
|
|
|
|
bindkey -s '\eggs' "git status^M"
|
2021-10-12 12:14:39 +02:00
|
|
|
bindkey -s '\egbb' "gbb^M"
|
2021-09-24 11:08:15 +02:00
|
|
|
|
|
|
|
# Yaml Engineering
|
|
|
|
bindkey -s '\egba' "baml^M"
|
|
|
|
bindkey -s '\egoba' "obaml^M"
|
2021-07-15 00:47:26 +02:00
|
|
|
|
2021-10-12 12:14:39 +02:00
|
|
|
# Kubeshizzle
|
2022-03-18 12:47:54 +01:00
|
|
|
bindkey -s '\egkk' "<(_kubeconfig) && kubectx && kubens^M"
|
2021-10-12 12:14:39 +02:00
|
|
|
bindkey -s '\egkx' "kubectx^M"
|
|
|
|
bindkey -s '\egkn' "kubens^M"
|
|
|
|
|
2019-10-14 17:30:02 +02:00
|
|
|
function fzf-vm () {
|
2020-01-03 22:02:21 +01:00
|
|
|
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
|
2019-10-14 17:30:02 +02:00
|
|
|
}
|
2020-01-03 22:02:21 +01:00
|
|
|
zle -N fzf-vm
|
2019-10-14 17:30:02 +02:00
|
|
|
bindkey '\ev' fzf-vm
|
|
|
|
|
2021-01-04 15:32:56 +01:00
|
|
|
# rg on Asteroids
|
|
|
|
rga-fzf() {
|
|
|
|
RG_PREFIX="rga --files-with-matches"
|
|
|
|
local file
|
|
|
|
file="$(
|
|
|
|
FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \
|
|
|
|
fzf --sort --preview="[[ ! -z {} ]] && rga --pretty --context 5 {q} {}" \
|
|
|
|
--phony -q "$1" \
|
|
|
|
--bind "change:reload:$RG_PREFIX {q}" \
|
|
|
|
--preview-window="70%:wrap"
|
|
|
|
)" &&
|
|
|
|
echo "opening $file" &&
|
|
|
|
xdg-open "$file"
|
|
|
|
}
|
|
|
|
|
2019-07-30 23:54:50 +02:00
|
|
|
# Via @leahneukirchen
|
|
|
|
autoload -Uz copy-earlier-word
|
|
|
|
zle -N copy-earlier-word
|
|
|
|
bindkey "^[m" copy-earlier-word
|
|
|
|
|
2021-07-15 00:47:49 +02:00
|
|
|
# TODO: Revisit later once foot has an option to ignore shift / control
|
|
|
|
# or I decide to actually use those mappings
|
|
|
|
# https://codeberg.org/dnkl/foot/issues/628 is ignored
|
|
|
|
bindkey "\e[27;2;13~" accept-line # shift+return
|
|
|
|
bindkey "\e[27;5;13~" accept-line # ctrl+return
|
|
|
|
|
2019-07-16 14:10:01 +02:00
|
|
|
if [ -f ~/Code/architecture/bin/ia ]; then
|
|
|
|
source <(~/Code/architecture/bin/ia completion)
|
|
|
|
fi;
|
2019-07-31 13:04:29 +02:00
|
|
|
|
2020-10-26 10:41:02 +01:00
|
|
|
if [ -f ${HOME}/Code/infrastructure-cli/Rakefile ]; then
|
|
|
|
alias chuck="rake -f ${HOME}/Code/infrastructure-cli/Rakefile"
|
2020-01-06 16:20:38 +01:00
|
|
|
fi;
|
|
|
|
|
2019-07-30 23:54:50 +02:00
|
|
|
source ~/.zsh-custom/plugins/
|
|
|
|
source ~/.p10k.zsh
|
2020-01-20 12:20:03 +01:00
|
|
|
autoload -U compinit && compinit
|