summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChloƩ Vulquin <code@toast.bunkerlabs.net>2026-01-18 21:53:18 +0100
committerChloƩ Vulquin <code@toast.bunkerlabs.net>2026-01-18 21:53:18 +0100
commite7e22d34089619349eaed54b213d575742748ce5 (patch)
tree532853f56020d0ba1b848c9e41662a1bf2ad7ade
parentzsh: ignore local files (diff)
zsh: even bigger rewrite
don't... worry about it I spent basically all day between this and monster hunter.
-rw-r--r--dot_config/zsh/.chezmoiignore6
-rw-r--r--dot_config/zsh/functions/prompt_fish_setup23
-rw-r--r--dot_config/zsh/zlogin4
-rw-r--r--dot_config/zsh/zlogout4
-rw-r--r--dot_config/zsh/zprofile15
-rw-r--r--dot_config/zsh/zshenv24
-rw-r--r--dot_config/zsh/zshrc84
-rw-r--r--dot_config/zsh/zshrc.options78
-rw-r--r--dot_config/zsh/zshrc.style44
9 files changed, 225 insertions, 57 deletions
diff --git a/dot_config/zsh/.chezmoiignore b/dot_config/zsh/.chezmoiignore
index aa1d33b..945b26b 100644
--- a/dot_config/zsh/.chezmoiignore
+++ b/dot_config/zsh/.chezmoiignore
@@ -1,3 +1,3 @@
-zshrc.local
-zshrc.post
-zshrc.pre
+*.pre
+*.local
+*.post
diff --git a/dot_config/zsh/functions/prompt_fish_setup b/dot_config/zsh/functions/prompt_fish_setup
new file mode 100644
index 0000000..35eaeb9
--- /dev/null
+++ b/dot_config/zsh/functions/prompt_fish_setup
@@ -0,0 +1,23 @@
+# vim: ft=zsh
+# a prompt meant to imitate fish's default prompt
+# it's not meant to be too close necessarily, just same feel overall,
+# while being a minimal/cheap implementation
+
+setopt promptsubst
+autoload -Uz add-zsh-hook
+autoload -Uz vcs_info # make sure you configure yours!
+
+_prompt_fish_chpwd() { FORCE_RUN_VCS_INFO=1; }
+_prompt_fish_precmd() { vcs_info fish; }
+
+add-zsh-hook chpwd _prompt_fish_chpwd
+add-zsh-hook precmd _prompt_fish_precmd
+
+add-zsh-hook -Uz chpwd vcs_info
+
+local login='%(!.%F{red}.%F{green})%n%f@%m'
+local vcsinfo='${vcs_info_msg_0_:+ $vcs_info_msg_0_}'
+local returnc='%(0?.. %F{red}[%?]%f)'
+local separator='%(!.#.>)'
+
+PS1="$login %~$vcsinfo$returnc$separator "
diff --git a/dot_config/zsh/zlogin b/dot_config/zsh/zlogin
new file mode 100644
index 0000000..600af43
--- /dev/null
+++ b/dot_config/zsh/zlogin
@@ -0,0 +1,4 @@
+# vim: ft=zsh
+xzsource zlogin.pre
+
+xzsource zlogin.{local,post}
diff --git a/dot_config/zsh/zlogout b/dot_config/zsh/zlogout
new file mode 100644
index 0000000..0dd9533
--- /dev/null
+++ b/dot_config/zsh/zlogout
@@ -0,0 +1,4 @@
+# vim: ft=zsh
+xzsource zlogout.pre
+
+xzsource zlogout.{local,post}
diff --git a/dot_config/zsh/zprofile b/dot_config/zsh/zprofile
new file mode 100644
index 0000000..9a1692a
--- /dev/null
+++ b/dot_config/zsh/zprofile
@@ -0,0 +1,15 @@
+# vim: ft=zsh
+xzsource zprofile.pre
+
+: ${PAGER:=less} ${EDITOR:=vi} \
+ ${HOSTNAME:=$(uname -n)} ${USER:=$(id -un)} \
+ ${HISTFILE:=~/.local/state/history/zsh}
+export EDITOR HISTFILE PAGER
+
+setopt nullglob
+path=(~/bin ~/.local/share/sh ~/.local/*/bin /opt/*/bin {/usr,}{/local,}/{s,}bin)
+fpath[1,0]=($ZDOTDIR/functions)
+
+xsource ~/.local/share/sh/xdg
+
+xzsource zprofile.{local,post}
diff --git a/dot_config/zsh/zshenv b/dot_config/zsh/zshenv
index e38dde8..0327691 100644
--- a/dot_config/zsh/zshenv
+++ b/dot_config/zsh/zshenv
@@ -1,14 +1,16 @@
-: ${PAGER:=less} ${EDITOR:=vi} \
- ${HOSTNAME:=$(uname -n)} ${USER:=$(id -un)} \
- ${HISTFILE:=~/.local/state/history/zsh} \
- ${ZDOTDIR:=~/.config/zsh}
-export EDITOR HISTFILE PAGER
+# vim: ft=zsh
+: ${ZDOTDIR:=~/.config/zsh}
-NOPATHHELPER=1
-zstyle :grml:completion:compinit arguments -iC
+xsource() {
+ local i
+ for i; do
+ [ -r "$i" ] && source "$i"
+ done
+}
+xzsource() {
+ xsource "${@/#/$ZDOTDIR/}"
+}
-setopt nullglob
-path=(~/bin ~/.local/share/sh ~/.local/*/bin /opt/*/bin {/usr,}{/local,}/{s,}bin)
-fpath[1,0]=("$ZDOTDIR"/functions)
+xzsource zshenv.pre
-[ -r ~/.local/share/sh/xdg ] && source ~/.local/share/sh/xdg
+xzsource zshenv.{local,post}
diff --git a/dot_config/zsh/zshrc b/dot_config/zsh/zshrc
index a959e2b..72452e9 100644
--- a/dot_config/zsh/zshrc
+++ b/dot_config/zsh/zshrc
@@ -1,63 +1,46 @@
-setopt autocd noautopushd nocdablevars
-setopt pushdignoredups pushdtohome
-setopt globstarshort nullglob rematchpcre
-setopt appendhistory histfindnodups histignoredups histignorespace histlexwords
-setopt interactivecomments hashexecutablesonly pathdirs
-setopt printexitvalue rcquotes shortloops
-setopt hup
-setopt promptpercent transientrprompt
-setopt cbases functionargzero multios pipefail
+# vim: ft=zsh
-bindkey -e
+xzsource zshrc.pre
+
+xzsource zshrc.{options,style}
-# grml did not run, source zshrc.pre and zshrc.local ourselves
-if [ -z "$GRML_OSTYPE" ]; then
- xsource() {
- local i
- for i in "$@"; do
- [ -r "$i" ] && source "$i"
- done
- }
- xsource "${ZDOTDIR:-~}/.zshrc.local"
- autoload compinit
- compinit -C
-fi
-# remove stale: 14 days
-find "${ZDOTDIR:-~}" -name .zcompdump -mtime 14 -exec rm '{}' ';'
+### Bindings
+bindkey -e
-hascmd() { (( ${+commands[$1]} )) }
-# command replacements
-hascmd bat && alias cat=bat c='bat -pp'
-hascmd bfs && alias find=bfs
-hascmd bsdtar && alias tar=bsdtar
-hascmd colordiff && alias diff=colordiff dif='colordiff -u'
-hascmd jaq && alias jq=jaq
-hascmd podman && alias docker=podman
-(hascmd eza && alias ls=eza tree='ls -T') ||
- (hascmd exa && alias ls=exa tree='ls -T') ||
- (hascmd lsd && alias ls=lsd lh='ls --hyperlink=auto' tree='lh --tree')
+### Functions, Aliases
+## Command replacements
+[[ -x =bat ]] && alias cat=bat c='bat -pp'
+[[ -x =bfs ]] && alias find=bfs
+[[ -x =bsdtar ]] && alias tar=bsdtar
+[[ -x =colordiff ]] && alias diff=colordiff dif='colordiff -u'
+[[ -x =jaq ]] && alias jq=jaq
+[[ -x =podman ]] && alias docker=podman
+if [[ -x =eza ]] { alias ls=eza tree='ls -T'
+} elif [[ -x =exa ]] { alias ls=exa tree='ls -T'
+} elif [[ -x =lsd ]] { alias ls=lsd lh='ls --hyperlink=auto' tree='lh --tree' }
alias l='ls -l' ll='ls -l' la='ls -a' lla='ls -la'
-hascmd ugrep && alias grep='ugrep -G -.' xdump='ugrep -X ""'
+[[ -x =ugrep ]] && alias grep='ugrep -G -.' xdump='ugrep -X ""'
alias uq='ug -Q' ux='ug -UX' uz='ug -z' g='ug -G -.'
-# convenience aliases
+## Convenience aliases
alias e='emacsclient -c -nw' E='emacsclient -c' m=micro n=nvim
alias ip='ip -c=auto'
alias dit='docker run -it --rm' drun='dit -v "$(pwd)":/pwd:Z -w /pwd'
alias ossh='ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=Error'
alias x='xh -b'
-# program configuration
+## Program configuration
alias chafa='chafa -f sixel'
alias ffmpeg='ffmpeg -hide_banner'
alias ffprobe='ffprobe -hide_banner'
[ -f ~/.config/ripgrep.conf ] && export RIPGREP_CONFIG_PATH=~/.config/ripgrep.conf
export SKIM_DEFAULT_COMMAND='fd -t f || rg --files || find .'
-if hascmd luarocks; then
+if [[ -x =luarocks ]] {
typeset -T LUA_CPATH=$(luarocks path --lr-cpath) lua_cpath
typeset -T LUA_PATH="$(luarocks path --lr-path);/?.lua" lua_path
-fi
+}
+## Functions
t() {
mkdir -p /tmp/t
cd /tmp/t
@@ -69,7 +52,22 @@ tt() {
trap "rm -rf '$dir'" EXIT
}
-# jump/zoxide/etc should be in zshrc.local or similar
+# you may want to:
+# set up jump/zoxide/etc
+# zstyle :completion:*:hosts list of hosts
+# hash -d short=directory
+xzsource zshrc.{local,post}
-# source zshrc.post
-xsource "${ZDOTDIR:-~}/.zshrc.post"
+# if compinit hasn't ran, run it now
+# this way there's at least some minimum compatibility with /etc/zshrc
+if (( ! ${+_comps} )) {
+ autoload -Uz compinit
+ compinit -i
+}
+
+# if promptinit hasn't ran, run it now, and set a default prompt
+if (( ! ${+functions[prompt]} )) {
+ autoload -Uz promptinit
+ promptinit
+ prompt fish
+}
diff --git a/dot_config/zsh/zshrc.options b/dot_config/zsh/zshrc.options
new file mode 100644
index 0000000..c32f3e6
--- /dev/null
+++ b/dot_config/zsh/zshrc.options
@@ -0,0 +1,78 @@
+# vim: ft=zsh
+### Options
+# Almost all options are set explicitly
+## Changing Directories
+# TODO: consider -T
+setopt -JED +NTw
+setopt nocdsilent nochasedots noposixcd pushdignoredups
+
+## Completion
+setopt -9X +SY
+setopt alwayslastprompt noalwaystoend automenu autonamedirs autoparamkeys
+setopt autoparamslash autoremoveslash nobashautolist completealiases
+setopt completeinword noglobcomplete nohashlistall listambiguous nolistbeep
+setopt listpacked listrowsfirst
+
+## Expansion and Globbing
+setopt -3GP +2F4I8u
+setopt bareglobqual nobraceccl caseglob casematch nocasepaths nocshnullglob
+# TODO: consider forcefloat, globassign
+setopt equals extendedglob noforcefloat noglobassign globstarshort noglobsubst
+setopt nohistsubstpattern noignoreclosebraces nokshglob nomagicequalsubst
+setopt multibyte numericglobsort rematchpcre noshglob
+setopt warncreateglobal nowarnnestedvar
+
+## History
+setopt -hg +K
+setopt appendhistory noextendedhistory nohistallowclobber nohistbeep
+setopt histexpiredupsfirst histfcntllock histfindnodups nohistignorealldups
+setopt histlexwords nohistnofunctions histnostore histreduceblanks
+setopt histsavebycopy histsavenodups histverify noincappendhistory
+setopt noincappendhistorytime nosharehistory
+
+## Initialisation
+# NOTE: +df unspecified on purpose
+setopt +a
+
+## Input/Output
+# NOTE: +1 since that should be handled by the prompt ideally
+setopt -kQ +C0O7U1HL
+# TODO: consider nohashcmds
+setopt aliases clobberempty nodvorak flowcontrol hashcmds hashdirs
+setopt hashexecutablesonly nopathscript noprinteightbit rcquotes normstarwait
+setopt shortloops noshortrepeat
+
+## Job Control
+# TODO: consider -R
+setopt -6m5 +WR
+setopt autocontinue checkjobs checkrunningjobs hup noposixjobs
+
+## Prompting
+setopt +V
+setopt nopromptbang promptsp promptpercent promptsubst transientrprompt
+
+## Scripts and Functions
+setopt +en
+# TODO: consider cprecedences
+setopt noaliasfuncdef cbases nocprecedences debugbeforecmd noerrreturn
+setopt evallineno functionargzero nolocalloops nolocaloptions nolocalpatterns
+setopt nolocaltraps multifuncdef multios nooctalzeroes pipefail
+# NOTE: nosourcetrace, +vx not set for specifying it on the CLI
+setopt notypesetsilent notypesettounset
+
+## Shell Emulation
+setopt +y
+setopt appendcreate nobashrematch nobsdecho nocontinueonerror
+setopt nocshjunkiehistory nocshjunkieloops nocshjunkiequotes nocshnullcmd
+# TODO: consider kshautoload, be sad about kshzerosubscript
+setopt noksharrays nokshautoload kshoptionprint nokshtypeset nokshzerosubscript
+setopt noposixaliases noposixargzero noposixbuiltins noposixidentifiers
+setopt noposixstrings noposixtraps noshfileexpansion noshnullcmd noshoptionletters
+setopt notrapsasync
+
+## Shell State
+# NOTE: Omitted intentionally
+
+## Zle
+setopt -B +M
+# NOTE: Many omitted intentionally
diff --git a/dot_config/zsh/zshrc.style b/dot_config/zsh/zshrc.style
new file mode 100644
index 0000000..d2a5514
--- /dev/null
+++ b/dot_config/zsh/zshrc.style
@@ -0,0 +1,44 @@
+# vim: ft=zsh
+### ZStyle
+## completion
+# TODO: a lot of this is stolen from grml; probably figure out more details
+zstyle ':completion:*:complete:*' cache-path ~/.cache/zsh
+zstyle ':completion:*' use-cache yes
+
+# detected options that aren't specified
+zstyle ':completion:*:messages' format %d
+zstyle ':completion:*:options' auto-description %d
+
+zstyle ':completion:*:options' description no
+
+zstyle ':completion:*' menu 'select=5'
+zstyle ':completion:*:matches' group yes
+zstyle ':completion:*' group-name ''
+
+zstyle ':completion:*:descriptions' format 'completing %B%d%b'
+
+zstyle ':completion:*' verbose true
+zstyle ':completion:*:-command-:*' verbose false
+
+# allow completing uppercase options from lowercase inputs
+zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
+
+zstyle ':completion:*:processes' command 'ps -au$USER'
+zstyle ':completion:*:processes-names' command 'ps c -u$USER -o comm | uniq'
+
+zstyle ':completion:*:manuals' separate-sections true
+zstyle ':completion:*:manuals.*' insert-sections true
+zstyle ':completion:*:man:*' menu yes select
+
+zstyle ':completion:*' special-dirs ..
+
+# you may want the following in zshrc.local...
+# :completion:*:hosts list of hosts
+
+## vcs_info
+zstyle ':vcs_info:*' use-simple true
+zstyle ':vcs_info:*' enable git darcs fossil
+zstyle ':vcs_info:*' formats '(%b)'
+zstyle ':vcs_info:*' actionformats '(%b : %a)'
+zstyle ':vcs_info:*' branchformat '%b'
+zstyle ':vcs_info:*' max-exports 1