Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

202 lines
7.7 KiB

# Directly start sway if we're on tty1
if [ "$(tty)" = "/dev/tty1" ]; then
exec sway-run
# 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"
# 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='$ '
plugins=(fzf fasd tmuxinator)
fpath=( ~/.kubectx/completion "${fpath[@]}" )
{{- if eq .chezmoi.fullHostname "mcnaught.uberspace.de" }}
{{ else }}
{{- end }}
export ZSH=${HOME}/.oh-my-zsh
source $ZSH/oh-my-zsh.sh
source $ZSH_CUSTOM/plugins/fzf-marks/fzf-marks.plugin.zsh
source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh
{{- if or (eq .chezmoi.hostname "pierogi") (eq .chezmoi.hostname "apfelstrudel") }}
export GPG_TTY="$(tty)"
export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
gpg-connect-agent updatestartuptty /bye &> /dev/null
{{- end }}
alias va="vagrant"
alias bi="bundle install"
alias be="bundle exec"
alias ber="bundle exec rake"
alias e=$EDITOR
alias vim=nvim
alias ssh-yop="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
alias scp-yop="scp -q -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 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 gp="gopass"
alias hl="hledger"
alias cm="chezmoi"
alias ls="exa --icons"
alias cm-private="chezmoi -S ~/.local/share/chezmoi-private"
alias kn="kubens"
alias alfaview-logfile="ls -d -- ~/.local/share/alfaview-staging/logs/*.log|tail -n 1"
alias ta="tmux attach -t \$(tmux ls -F '#{session_name}' | fzf)"
alias gf="git fetch -a && git rebase && git --no-pager today-all"
# 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} && touch $KUBECONFIG && chmod 0500 $KUBECONFIG && 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) }
letterup() {
if [[ ! -a $1 ]]; then
take $1;
cp ~/Documents/Personal/Brief-Vorlage/2021-LaTeX-Reworked/template.tex brief.tex;
cd $1;
tmuxinator start letter;
letterbuild() {
podman run -e VERBOSE=false -i --rm letter < $(*.tex) > $(basename *tex .tex)
# Pretty up FZF
--prompt=" "
# Pretty icons in lf
export LF_ICONS="tw=:st=:ow=:dt=:di=:fi=:ln=:or=:ex=:*.c=:*.cc=:*.clj=:*.coffee=:*.cpp=:*.css=:*.go=:*.h=:*.hh=:*.hpp=:*.html=:*.js=:*.json=:*.md=:*.php=:*.py=:*.rb=:*.rs=:*.ts=:*.vim=:*.cmd=:*.ps1=:*.sh=:*.bash=:*.zsh=:*.fish=:*.tar=:*.tgz=:*.arc=:*.arj=:*.taz=:*.lha=:*.lz4=:*.lzh=:*.lzma=:*.tlz=:*.txz=:*.tzo=:*.t7z=:*.zip=:*.z=:*.dz=:*.gz=:*.lrz=:*.lz=:*.lzo=:*.xz=:*.zst=:*.tzst=:*.bz2=:*.bz=:*.tbz=:*.tbz2=:*.tz=:*.deb=:*.rpm=:*.jar=:*.war=:*.ear=:*.sar=:*.rar=:*.alz=:*.ace=:*.zoo=:*.cpio=:*.7z=:*.rz=:*.cab=:*.wim=:*.swm=:*.dwm=:*.esd=:*.jpg=:*.jpeg=:*.mjpg=:*.mjpeg=:*.gif=:*.bmp=:*.pbm=:*.pgm=:*.ppm=:*.tga=:*.xbm=:*.xpm=:*.tif=:*.tiff=:*.png=:*.svg=:*.svgz=:*.mng=:*.pcx=:*.mov=:*.mpg=:*.mpeg=:*.m2v=:*.mkv=:*.webm=:*.ogm=:*.mp4=:*.m4v=:*.mp4v=:*.vob=:*.qt=:*.nuv=:*.wmv=:*.asf=:*.rm=:*.rmvb=:*.flc=:*.avi=:*.fli=:*.flv=:*.gl=:*.dl=:*.xcf=:*.xwd=:*.yuv=:*.cgm=:*.emf=:*.ogv=:*.ogx=:*.aac=:*.au=:*.flac=:*.m4a=:*.mid=:*.midi=:*.mka=:*.mp3=:*.mpc=:*.ogg=:*.ra=:*.wav=:*.oga=:*.opus=:*.spx=:*.xspf=:*.pdf=:*.nix=:"
# 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
zle reset-prompt
# Only load kubectl completion when needed. I's bog-slow
if [[ -f $KUBECONFIG ]]; then
source <(kubectl completion zsh);
zle -N fzf-ssh
bindkey '\es' fzf-ssh
# Tmux Quick Keys
bindkey -s '\egtn' 'tn^M'
bindkey -s '\egta' "ta^M"
# Git Quick Keys
bindkey -s '\eggf' "gf^M"
bindkey -s '\eggp' "git push^M"
bindkey -s '\eggs' "git status^M"
# Yaml Engineering
bindkey -s '\egba' "baml^M"
bindkey -s '\egoba' "obaml^M"
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
zle reset-prompt
zle -N fzf-vm
bindkey '\ev' fzf-vm
# rg on Asteroids
rga-fzf() {
RG_PREFIX="rga --files-with-matches"
local file
fzf --sort --preview="[[ ! -z {} ]] && rga --pretty --context 5 {q} {}" \
--phony -q "$1" \
--bind "change:reload:$RG_PREFIX {q}" \
)" &&
echo "opening $file" &&
xdg-open "$file"
# Via @leahneukirchen
autoload -Uz copy-earlier-word
zle -N copy-earlier-word
bindkey "^[m" copy-earlier-word
# 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
if [ -f ~/Code/architecture/bin/ia ]; then
source <(~/Code/architecture/bin/ia completion)
if [ -f ${HOME}/Code/infrastructure-cli/Rakefile ]; then
alias chuck="rake -f ${HOME}/Code/infrastructure-cli/Rakefile"
source ~/.zsh-custom/plugins/
source ~/.p10k.zsh
autoload -U compinit && compinit