feat(zsh): split config
This commit is contained in:
parent
7545c840f2
commit
91a01ec1e3
10 changed files with 162 additions and 133 deletions
10
dot_config/zsh/config.d/aliases/chezmoi.zsh
Normal file
10
dot_config/zsh/config.d/aliases/chezmoi.zsh
Normal file
|
@ -0,0 +1,10 @@
|
|||
alias cm='chezmoi'
|
||||
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'
|
0
dot_config/zsh/config.d/aliases/empty_general.zsh
Normal file
0
dot_config/zsh/config.d/aliases/empty_general.zsh
Normal file
13
dot_config/zsh/config.d/aliases/ls.zsh
Normal file
13
dot_config/zsh/config.d/aliases/ls.zsh
Normal file
|
@ -0,0 +1,13 @@
|
|||
if [ -x "$(command -v lsd)" ]; then
|
||||
# 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'
|
||||
else
|
||||
alias l='ls'
|
||||
alias ll='ls -l'
|
||||
alias la='ls -lA'
|
||||
fi
|
10
dot_config/zsh/config.d/functions/diff.zsh
Normal file
10
dot_config/zsh/config.d/functions/diff.zsh
Normal file
|
@ -0,0 +1,10 @@
|
|||
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
|
64
dot_config/zsh/config.d/functions/icat.zsh
Normal file
64
dot_config/zsh/config.d/functions/icat.zsh
Normal file
|
@ -0,0 +1,64 @@
|
|||
local MAPPINGS='
|
||||
video/3gpp,3gp
|
||||
video/3gpp2,3g2
|
||||
video/MP2T,mpegts
|
||||
video/MP2T,mpegtsraw
|
||||
video/mp4,mp4
|
||||
video/mpeg,mpeg
|
||||
video/ogg,ogv
|
||||
video/quicktime,mov
|
||||
video/webm,webm
|
||||
'
|
||||
# format=$(echo "$MAPPINGS" | grep "$headers" | cut -d "," -f2-)
|
||||
|
||||
function icat() {
|
||||
function display() {
|
||||
if [[ "$TERM_PROGRAM" == "WezTerm" ]]; then
|
||||
cat - | wezterm imgcat
|
||||
elif [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
||||
cat - | $(alias imgcat | cut -d "=" -f2-)
|
||||
elif [[ "$TERM" = "xterm-kitty" ]]; then
|
||||
cat - | kitty +kitten icat
|
||||
else
|
||||
echo "No image viewer defined for this terminal" && return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
function displaySVG() {
|
||||
[[ ! -x "$(command -v convert)" ]] && echo "convert not found, install imagemagick" && return 1
|
||||
convert -background none -density 192 - png:- | display
|
||||
}
|
||||
function displayVID() {
|
||||
ffmpeg -loglevel fatal -hide_banner -i "$1" -vf scale=720:-1 -r 10 -f image2pipe -vcodec ppm pipe:1 | \
|
||||
convert -delay 10 -loop 1 - gif:- | \
|
||||
display
|
||||
}
|
||||
|
||||
if [ ! -t 0 ]; then
|
||||
input="$(cat - | base64)"
|
||||
headers="$(echo "$input" | base64 -d | file - --mime-type | cut -d " " -f2-)"
|
||||
|
||||
case $headers in
|
||||
*svg*) echo "$input" | base64 -d | displaySVG ;;
|
||||
*video*) echo "haven't figured this part out yet" && return 1;;
|
||||
*image*) echo "$input" | base64 -d | display ;;
|
||||
*) echo "Unknown file type" && return 1 ;;
|
||||
esac
|
||||
elif [[ "$1" == http* ]]; then
|
||||
case "$(curl -sSLI "$1" | grep -i "^content-type:")" in
|
||||
*svg*) curl -fsSL "$1" | displaySVG ;;
|
||||
*video*) echo "haven't figured this part out yet" && return 1;;
|
||||
*image*) curl -fsSL "$1" | display ;;
|
||||
*) echo "Unknown file type" && return 1 ;;
|
||||
esac
|
||||
else
|
||||
[[ -z "$1" ]] && echo "Usage: icat <file|url>" && return 1
|
||||
[[ ! -f "$1" ]] && echo "File not found: $1" && return 1
|
||||
case "$(file -b --mime-type "$1")" in
|
||||
*svg*) cat "$1" | displaySVG ;;
|
||||
*video*) displayVID $1 ;;
|
||||
*image*) cat "$1" | display ;;
|
||||
*) echo "Unknown file type" && return 1 ;;
|
||||
esac
|
||||
fi
|
||||
}
|
25
dot_config/zsh/config.d/functions/macOS.zsh
Normal file
25
dot_config/zsh/config.d/functions/macOS.zsh
Normal file
|
@ -0,0 +1,25 @@
|
|||
# if we're not on mac, exit
|
||||
[[ "$(uname)" != "Darwin" ]] && exit 0
|
||||
|
||||
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"'
|
16
dot_config/zsh/dot_zsh_plugins.txt
Normal file
16
dot_config/zsh/dot_zsh_plugins.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
# omz
|
||||
ohmyzsh/ohmyzsh path:lib
|
||||
ohmyzsh/ohmyzsh path:plugins/colored-man-pages
|
||||
ohmyzsh/ohmyzsh path:plugins/colorize
|
||||
ohmyzsh/ohmyzsh path:plugins/docker-compose
|
||||
ohmyzsh/ohmyzsh path:plugins/git
|
||||
ohmyzsh/ohmyzsh path:plugins/gpg-agent
|
||||
ohmyzsh/ohmyzsh path:plugins/kubectl
|
||||
|
||||
jeffreytse/zsh-vi-mode
|
||||
|
||||
greymd/docker-zsh-completion
|
||||
|
||||
zsh-users/zsh-autosuggestions
|
||||
zsh-users/zsh-completions
|
||||
zsh-users/zsh-syntax-highlighting
|
|
@ -32,6 +32,9 @@ export KUBECACHEDIR="$XDG_CACHE_HOME/kube"
|
|||
export KREW_ROOT="$XDG_DATA_HOME/krew"
|
||||
[ -d "$KREW_ROOT" ] && export PATH="$KREW_ROOT/bin:$PATH"
|
||||
export MINIKUBE_HOME="$XDG_DATA_HOME/minikube"
|
||||
export HOMEBREW_INSTALL_BADGE="☕️"
|
||||
export HOMEBREW_CLEANUP_MAX_AGE_DAYS=30
|
||||
export HOMEBREW_AUTOREMOVE=1
|
||||
#}}}
|
||||
### python {{{
|
||||
export PYENV_ROOT="$XDG_DATA_HOME/pyenv"
|
||||
|
|
|
@ -2,42 +2,13 @@
|
|||
# load starship
|
||||
[[ -x "$(command -v starship)" ]] && eval "$(starship init zsh)"
|
||||
|
||||
### plugins via antigen {{{
|
||||
# don't pollute $HOME with antigen
|
||||
ADOTDIR="$XDG_DATA_HOME/antigen"
|
||||
# bootstrap antigen
|
||||
if [[ ! -d "$ADOTDIR" ]]; then
|
||||
mkdir -p "$ADOTDIR"
|
||||
curl -L https://git.io/antigen > "$ADOTDIR/antigen.zsh"
|
||||
chmod +x "$ADOTDIR/antigen.zsh"
|
||||
fi
|
||||
|
||||
# load antigen
|
||||
source "$ADOTDIR/antigen.zsh"
|
||||
|
||||
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
|
||||
### plugins via antidote {{{
|
||||
autoload -Uz compinit && compinit
|
||||
zstyle ':antidote:bundle' use-friendly-names 'yes'
|
||||
antidote_dir="${ZDOTDIR:-$HOME}/antidote"
|
||||
[ ! -d "$antidote_dir" ] && git clone --depth=1 https://github.com/mattmc3/antidote.git "$antidote_dir"
|
||||
source "$antidote_dir/antidote.zsh"
|
||||
antidote load
|
||||
# }}}
|
||||
|
||||
### basics {{{
|
||||
|
@ -48,117 +19,35 @@ export SAVEHIST=10000
|
|||
setopt HIST_IGNORE_ALL_DUPS
|
||||
setopt HIST_IGNORE_DUPS
|
||||
|
||||
# use fuck if available
|
||||
[[ -x "$(command -v thefuck)" ]] && eval $(thefuck --alias)
|
||||
[ -x "$(command -v thefuck)" ] && eval "$(thefuck --alias)"
|
||||
[ -x "$(command -v zoxide)" ] && eval "$(zoxide init zsh)"
|
||||
bindkey -r "^R"
|
||||
[ -x "$(command -v mcfly)" ] && eval "$(mcfly init zsh)"
|
||||
# }}}
|
||||
|
||||
### aliases & functions {{{
|
||||
## basics {{{
|
||||
if [ -x "$(command -v vivid)" ]; then
|
||||
export LS_COLORS="$(vivid generate catppuccin-mocha)"
|
||||
fi
|
||||
|
||||
if [ -x "$(command -v lsd)" ]; then
|
||||
# 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'
|
||||
else
|
||||
alias l='ls'
|
||||
alias ll='ls -l'
|
||||
alias la='ls -lA'
|
||||
fi
|
||||
[ -f "$ZDOTDIR/lscolors" ] && export LS_COLORS="$(cat "$ZDOTDIR/lscolors")"
|
||||
|
||||
# both names for bat
|
||||
export BAT_THEME="catppuccin-mocha"
|
||||
if [ -x "$(command -v batcat)" ]; then
|
||||
alias cat='batcat'
|
||||
elif [ -x "$(command -v bat)" ]; then
|
||||
alias cat='bat'
|
||||
fi
|
||||
|
||||
[[ -x "$(command -v zoxide)" ]] && eval "$(zoxide init zsh)"
|
||||
|
||||
# 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'
|
||||
[ -x "$(command -v batcat)" ] && alias cat='batcat'
|
||||
[ -x "$(command -v bat)" ] && alias cat='bat'
|
||||
[ -x "$(command -v nvim)" ] && alias vim='nvim' alias wiki='nvim -c VimwikiIndex'
|
||||
[ -x "$(command -v taskwarrior-tui)" ] && alias tt='taskwarrior-tui'
|
||||
|
||||
# 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'
|
||||
## }}}
|
||||
|
||||
## 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'
|
||||
function icat() {
|
||||
if [ "$TERM_PROGRAM" = "WezTerm" ]; then
|
||||
wezterm imgcat "$@"
|
||||
elif [ "$TERM" = "xterm-kitty" ]; then
|
||||
kitty +kitten icat "$@"
|
||||
else
|
||||
echo 'No image viewer defined for this terminal'
|
||||
fi
|
||||
}
|
||||
## }}}
|
||||
|
||||
## 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'
|
||||
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'
|
||||
## }}}
|
||||
for conf in "$ZDOTDIR"/config.d/**/*.zsh; do
|
||||
source "${conf}"
|
||||
done
|
||||
unset conf
|
||||
|
||||
function debugnvim() {
|
||||
cd $(mktemp -d)
|
||||
|
@ -171,10 +60,8 @@ function debugnvim() {
|
|||
### languages & frameworks {{{
|
||||
# python, my old friend
|
||||
[[ -x "$(command -v pyenv)" ]] && eval "$(pyenv init -)"
|
||||
|
||||
# ruby
|
||||
[[ -x "$(command -v rbenv)" ]] && eval "$(rbenv init - zsh)"
|
||||
|
||||
# node
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
||||
# }}}
|
||||
|
|
1
dot_config/zsh/lscolors
Normal file
1
dot_config/zsh/lscolors
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue