212 lines
6.8 KiB
Cheetah
212 lines
6.8 KiB
Cheetah
# 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.fqdnHostname "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
|
|
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/Neuwied?1pQF&lang=de'"
|
|
alias termbin="nc termbin.com 9999"
|
|
alias gp="gopass"
|
|
alias hl="hledger"
|
|
alias cm="chezmoi"
|
|
alias cm-add-changed-file="cm add \$(cm diff|grep ^install|cut -d ' ' -f 5|fzf)"
|
|
alias cm-private="chezmoi -S ~/.local/share/chezmoi-private"
|
|
alias ls="exa --icons"
|
|
alias kn="kubens"
|
|
alias alfaview-logfile="/usr/bin/env 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 && echo -n '\n'"
|
|
alias gbb="BRANCH=\$(git for-each-ref refs/heads/ --format='%(refname:short)' | fzf); git fetch origin \${BRANCH} && git checkout \${BRANCH}"
|
|
alias tdir="take \$(mktemp -d --suffix=\".\$(basename \${PWD})\")"
|
|
|
|
# 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 0600 $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;
|
|
else
|
|
cd $1;
|
|
fi;
|
|
tmuxinator start letter;
|
|
}
|
|
letterbuild() {
|
|
podman run -e VERBOSE=false -i --rm letter < $(*.tex) > $(basename *tex .tex)
|
|
}
|
|
|
|
|
|
# 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
|
|
'
|
|
|
|
# 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
|
|
|
|
# Editors
|
|
bindkey -s '\ege' "em -nw .^M"
|
|
|
|
# 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"
|
|
bindkey -s '\egbb' "gbb^M"
|
|
|
|
# Yaml Engineering
|
|
bindkey -s '\egba' "baml^M"
|
|
bindkey -s '\egoba' "obaml^M"
|
|
|
|
# Kubeshizzle
|
|
bindkey -s '\egkk' "<(_kubeconfig) && kubectx && kubens^M"
|
|
bindkey -s '\egkx' "kubectx^M"
|
|
bindkey -s '\egkn' "kubens^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
|
|
fi
|
|
zle reset-prompt
|
|
}
|
|
zle -N fzf-vm
|
|
bindkey '\ev' fzf-vm
|
|
|
|
# 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"
|
|
}
|
|
|
|
# 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)
|
|
fi;
|
|
|
|
if [ -f ${HOME}/Code/infrastructure-cli/Rakefile ]; then
|
|
alias chuck="rake -f ${HOME}/Code/infrastructure-cli/Rakefile"
|
|
fi;
|
|
|
|
source ~/.zsh-custom/plugins/
|
|
source ~/.p10k.zsh
|
|
autoload -U compinit && compinit
|