home | blog | art | now | git gpg | email | rss

dotfiles

My personal dotfiles
git clone git://pollux.codes/git/dotfiles.git
Log | Files | Refs
commit 24dea474b0658a3d34093bf28cfddbc8abd24cc7
parent 41f1f0317a02850d3798c078c7436c80ea0569af
Author: Pollux <pollux@pollux.codes>
Date:   Mon, 26 May 2025 21:48:16 -0500

zsh: add zsh configuration

Signed-off-by: Pollux <pollux@pollux.codes>

Diffstat:
A.zshrc | 7+++++++
A.zshrc.d/00_env.zsh | 5+++++
A.zshrc.d/05_zinit.zsh | 18++++++++++++++++++
A.zshrc.d/10_alias.zsh | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
A.zshrc.d/10_controls.zsh | 15+++++++++++++++
A.zshrc.d/10_history.zsh | 11+++++++++++
A.zshrc.d/10_theme.zsh | 17+++++++++++++++++
A.zshrc.d/20_shell_integration.zsh | 8++++++++
A.zshrc.d/99_prompt.zsh | 13+++++++++++++
9 files changed, 147 insertions(+), 0 deletions(-)

diff --git a/.zshrc b/.zshrc @@ -0,0 +1,7 @@ +export ZSH_RC_SNIPPETS=(~/.zshrc.d/*) + +for file in ~/.zshrc.d/* ; do + if [ -f "$file" ] ; then + . "$file" + fi +done diff --git a/.zshrc.d/00_env.zsh b/.zshrc.d/00_env.zsh @@ -0,0 +1,5 @@ +export NOTMUCH_CONFIG="$HOME/.config/notmuch/config" + +path+=(~/.cargo/bin) +path+=(~/.local/bin{,/**/*(N/)}) +path+=(~/.config/emacs/bin) diff --git a/.zshrc.d/05_zinit.zsh b/.zshrc.d/05_zinit.zsh @@ -0,0 +1,18 @@ +ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" + +if [ ! -d "$ZINIT_HOME" ]; then + mkdir -p "$(dirname $ZINIT_HOME)" + git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" +fi + +source "${ZINIT_HOME}/zinit.zsh" +zinit ice depth=1 +zinit light zsh-users/zsh-autosuggestions +zinit light zsh-users/zsh-syntax-highlighting +zinit light zsh-users/zsh-completions +zinit light Aloxaf/fzf-tab +zinit light jeffreytse/zsh-vi-mode + +autoload -U compinit && compinit + +zinit cdreplay -q diff --git a/.zshrc.d/10_alias.zsh b/.zshrc.d/10_alias.zsh @@ -0,0 +1,53 @@ +# Git +gs() { git status $@ } +ga() { git add $@ } +gc() { git commit -s $@ } +gca() { git commit -s --amend $@ } +gp() { git push --force-with-lease $@ } +gf() { git fetch $@ } + +# Run remote post-receive hook without changing repository. +grecv() { git commit --amend --allow-empty --no-edit; git push -f } + +# Dotfiles +dotfiles() { git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME $@ } + +ds() { dotfiles status $@ } +da() { dotfiles add $@ } +dc() { dotfiles commit -s $@ } +dca() { dotfiles commit -s --amend $@ } +dp() { dotfiles push --force-with-lease $@ } +df() { dotfiles fetch $@ } + +# VPN +vpnup() { doas wg-quick up } +vpndown() { doas wg-quick down } + +# Misc +reload() { source ~/.zshrc } +ls() { lsd --hyperlink=auto -AlL --icon-theme unicode $@ 2>/dev/null } + +# Better ui for core utils +# Note: None of these ultimately change the behavior of the commands, just give +# a better user experience + +# Helper function, runs the first argument with a nice UI showing the progress. +# It waits 5 seconds before showing the progress in case it is a quick operation. +# See progress --help for a list of the commands supported. +monitor() { + $@ &! + PID=$! + waitpid --timeout 5 $PID &> /dev/null + if [ $? -gt 0 ]; then + progress --wait --monitor --additional-command $1 --pid $PID + kill $PID &> /dev/null + fi + exit 0 +} + +#cp() { monitor /usr/bin/cp $@ } +#rm() { monitor /usr/bin/rm $@ } +#mv() { monitor /usr/bin/mv $@ } +#tar() { monitor /usr/bin/tar $@ } +#gzip() { monitor /usr/bin/gzip $@ } +#gunzip() { monitor /usr/bin/gunzip $@ } diff --git a/.zshrc.d/10_controls.zsh b/.zshrc.d/10_controls.zsh @@ -0,0 +1,15 @@ + +autoload -U up-line-or-beginning-search +autoload -U down-line-or-beginning-search + +zle -N up-line-or-beginning-search +zle -N down-line-or-beginning-search + +zvm_bindkey vicmd "k" up-line-or-beginning-search +zvm_bindkey vicmd "j" down-line-or-beginning-search + +zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' +zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" +zstyle ':completion:*' menu no + +VIM_MODE_INITIAL_KEYMAP=last diff --git a/.zshrc.d/10_history.zsh b/.zshrc.d/10_history.zsh @@ -0,0 +1,11 @@ +HISTSIZE=1000 +HISTFILE=~/.zsh_history +SAVEHIST=$HISTSIZE +HISTDUP=erase +setopt appendhistory +setopt sharehistory +setopt hist_ignore_space +setopt hist_ignore_all_dups +setopt hist_save_no_dups +setopt hist_ignore_dups +setopt hist_find_no_dups diff --git a/.zshrc.d/10_theme.zsh b/.zshrc.d/10_theme.zsh @@ -0,0 +1,17 @@ +ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=red,bold +ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=magenta +ZSH_HIGHLIGHT_STYLES[alias]=fg=magenta +ZSH_HIGHLIGHT_STYLES[suffix-alias]=fg=magenta +ZSH_HIGHLIGHT_STYLES[global-alias]=fg=magenta +ZSH_HIGHLIGHT_STYLES[builtin]=fg=magenta +ZSH_HIGHLIGHT_STYLES[function]=fg=magenta +ZSH_HIGHLIGHT_STYLES[command]=fg=green +ZSH_HIGHLIGHT_STYLES[precommand]=fg=magenta,bold +ZSH_HIGHLIGHT_STYLES[commandseparator]=none +ZSH_HIGHLIGHT_STYLES[hashed-command]=fg=black +ZSH_HIGHLIGHT_STYLES[autodirectory]=fg=magenta +ZSH_HIGHLIGHT_STYLES[path]=underline + + +ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=fg=cyan +ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=fg=blue diff --git a/.zshrc.d/20_shell_integration.zsh b/.zshrc.d/20_shell_integration.zsh @@ -0,0 +1,8 @@ +eval "$(fzf --zsh)" +eval "$(zoxide init --cmd cd zsh)" + +command_not_found_handler() { + echo "Command $1 not found." + echo + find-command "$1" +} diff --git a/.zshrc.d/99_prompt.zsh b/.zshrc.d/99_prompt.zsh @@ -0,0 +1,13 @@ + +eval "$(oh-my-posh init zsh --config ~/.posh-pollux-theme.json)" + +visiblelen() { + local zero='%([BSUbfksu]|([FK]|){*})' + echo ${#${(S%%)1//$~zero/}} +} + +center() { + TEXT=$(print -P "$1") + LENGTH=$(visiblelen "$1") + printf "%$(( ( $(tput cols) - $LENGTH ) / 2 + ${#TEXT} ))s\n" "$TEXT" +}