dotfiles/dot_config/zsh/dot_zshrc

189 lines
4.5 KiB
Text
Raw Normal View History

2022-07-30 21:21:08 +02:00
# vim:ft=zsh:fenc=utf-8:fdm=marker
2022-07-30 07:17:12 +02:00
# load starship
[[ -x "$(command -v starship)" ]] && eval "$(starship init zsh)"
2022-07-30 07:17:12 +02:00
### plugins via antigen {{{
# don't pollute $HOME with antigen
2022-11-19 22:21:54 +01:00
ADOTDIR="$XDG_DATA_HOME/antigen"
# bootstrap antigen
if [[ ! -d "$ADOTDIR" ]]; then
mkdir -p "$ADOTDIR"
curl -L https://git.io/antigen > "$ADOTDIR/antigen.zsh"
2022-11-19 22:21:54 +01:00
chmod +x "$ADOTDIR/antigen.zsh"
fi
2022-07-30 07:17:12 +02:00
# load antigen
source "$ADOTDIR/antigen.zsh"
2022-07-30 07:17:12 +02:00
antigen use oh-my-zsh
antigen bundle colored-man-pages
antigen bundle colorize
antigen bundle docker-compose
antigen bundle git
antigen bundle gpg-agent
antigen bundle kubectl
# omz's vi-mode doesn't vibe with starship
antigen bundle jeffreytse/zsh-vi-mode
antigen bundle greymd/docker-zsh-completion
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-completions
antigen bundle zsh-users/zsh-syntax-highlighting
antigen apply
# https://github.com/ohmyzsh/ohmyzsh/issues/10728
if [[ ! -d "$ZSH_CACHE_DIR/completions" ]]; then
mkdir -p "$ZSH_CACHE_DIR/completions"
fi
2022-07-30 07:17:12 +02:00
# }}}
### basics {{{
# history
export HISTFILE="$ZDOTDIR/.zhistory"
2022-07-30 07:17:12 +02:00
export HISTSIZE=10000
export SAVEHIST=10000
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_DUPS
# use fuck if available
2022-07-30 07:17:12 +02:00
[[ -x "$(command -v thefuck)" ]] && eval $(thefuck --alias)
# }}}
### aliases & functions {{{
## basics {{{
if [ -x "$(command -v vivid)" ]; then
export LS_COLORS="$(vivid generate catppuccin-mocha)"
fi
if [ -x "$(command -v lsd)" ]; then
2022-07-30 07:17:12 +02:00
# add a bit more space between the file icon & name
alias ls='lsd'
alias l='lsd'
alias ll='lsd -l'
alias la='lsd -la'
alias lt='lsd -l --total-size' alias lat='lsd -lA --total-size'
alias tree='lsd --tree'
2022-07-30 07:17:12 +02:00
else
alias l='ls'
alias ll='ls -l'
alias la='ls -lA'
fi
# both names for bat
export BAT_THEME="catppuccin-mocha"
if [ -x "$(command -v batcat)" ]; then
alias cat='batcat'
elif [ -x "$(command -v bat)" ]; then
2022-12-01 18:00:57 +01:00
alias cat='bat'
fi
[[ -x "$(command -v zoxide)" ]] && eval "$(zoxide init zsh)"
2022-07-30 07:17:12 +02:00
# use neovim as vim, if installed
if [[ -x "$(command -v nvim)" ]]; then
alias vim='nvim'
# open vimwiki
alias wiki='nvim -c VimwikiIndex'
fi
[[ -x "$(command -v taskwarrior-tui)" ]] && alias tt='taskwarrior-tui'
2022-07-30 07:17:12 +02:00
# switch between yubikeys for the same GPG key
alias switch_yubikeys='gpg-connect-agent "scd serialno" "learn --force" /bye'
# list tty devices on macOS, useful for Arduino & other boards
alias lstty='ls /dev | grep -E "^(tty\.|cu\.)" --color=never'
## }}}
2022-07-30 07:17:12 +02:00
## OS-dependent tweaks {{{
# manage yabai & ecosystem easier
function twm() {
case "$1" in
"start")
brew services start skhd
brew services start yabai
;;
"stop")
brew services stop skhd
brew services stop yabai
;;
"restart")
launchctl kickstart -k "gui/${UID}/homebrew.mxcl.skhd"
launchctl kickstart -k "gui/${UID}/homebrew.mxcl.yabai"
;;
*)
echo "Usage: twm <start|restart|stop>"
return 1
;;
esac
}
alias sbks='launchctl kickstart -k "gui/${UID}/homebrew.mxcl.sketchybar"'
alias onefetch='onefetch --true-color=never'
alias mbsync='mbsync --config ~/.config/mbsyncrc'
2022-07-30 07:17:12 +02:00
function icat() {
if [ "$TERM_PROGRAM" = "WezTerm" ]; then
wezterm imgcat "$@"
elif [ "$TERM" = "xterm-kitty" ]; then
kitty +kitten icat "$@"
2022-07-30 07:17:12 +02:00
else
echo 'No image viewer defined for this terminal'
fi
}
## }}}
2022-07-30 07:17:12 +02:00
## development {{{
# use the combination of colordiff & diff-so-fancy
if [ -x "$(command -v colordiff)" ] && [ -x "$(command -v diff-so-fancy)" ]; then
function diff() {
colordiff -N -u "$@" | diff-so-fancy
}
function kdiff() {
KUBECTL_EXTERNAL_DIFF="colordiff -N -u"
kubectl diff "$@" | diff-so-fancy
}
fi
## chezmoi
alias cm='chezmoi'
2022-07-30 07:17:12 +02:00
alias cma='chezmoi add'
alias cmap='chezmoi apply'
alias cmcd='cd $(chezmoi source-path)'
alias cmd='chezmoi diff'
alias cme='chezmoi edit'
alias cmm='chezmoi merge'
alias cmrm='chezmoi remove'
alias cmst='chezmoi status'
alias cmup='chezmoi update'
## }}}
function debugnvim() {
cd $(mktemp -d)
export XDG_DATA_HOME=$PWD XDG_CACHE_HOME=$PWD XDG_CONFIG_HOME=$PWD
mkdir nvim
nvim nvim/init.lua
}
2022-07-30 07:17:12 +02:00
### }}}
### languages & frameworks {{{
# python, my old friend
[[ -x "$(command -v pyenv)" ]] && eval "$(pyenv init -)"
2022-07-30 07:17:12 +02:00
2022-08-14 06:26:05 +02:00
# ruby
[[ -x "$(command -v rbenv)" ]] && eval "$(rbenv init - zsh)"
# node
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
2022-07-30 07:17:12 +02:00
# }}}
### technical BS {{{
2022-10-04 05:42:44 +02:00
# some bs setting the window title, apparently
2022-07-30 07:17:12 +02:00
function set_win_title(){
echo -ne "\033]0;$(basename "$PWD")\007"
}
precmd_functions+=(set_win_title)
# }}}