Split zsh config into separate files

This commit is contained in:
ItsDrike 2024-06-10 16:23:40 +02:00
parent aa8cc54140
commit 7e265f51b1
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
2 changed files with 39 additions and 23 deletions

View file

@ -3,30 +3,46 @@ let
inherit (builtins) readFile; inherit (builtins) readFile;
in in
{ {
config = {
# I prefer having the rc files split across multiple files in my system rather
# than just using readFile and putting them all into the generated zshrc
# this also allows me to source them individually if I need to
# (like in the anonymize function with my prompt)
home.file = {
# TODO: Load these dynamically, by going over all files in ./rc
".config/zsh/rc/fallback_term.zsh".source = ./rc/fallback_term.zsh;
".config/zsh/rc/opts.zsh".source = ./rc/opts.zsh;
".config/zsh/rc/prompt.zsh".source = ./rc/prompt.zsh;
".config/zsh/rc/keybinds.zsh".source = ./rc/keybinds.zsh;
".config/zsh/rc/aliases.zsh".source = ./rc/aliases.zsh;
".config/zsh/rc/functions.zsh".source = ./rc/functions.zsh;
".config/zsh/rc/misc.zsh".source = ./rc/misc.zsh;
".config/zsh/rc/completion.zsh".source = ./rc/completion.zsh;
".config/zsh/rc/profile.zsh".source = ./rc/profile.zsh;
};
programs.zsh = { programs.zsh = {
initExtraFirst = '' initExtraFirst = ''
# Do this early so anything that relies on $TERM can work properly # Do this early so anything that relies on $TERM can work properly
${readFile ./rc/fallback_term.zsh} . ~/.config/zsh/rc/fallback_term.zsh
''; '';
initExtra = '' initExtra = ''
${readFile ./rc/opts.zsh} . ~/.config/zsh/rc/opts.zsh
${readFile ./rc/prompt.zsh} . ~/.config/zsh/rc/prompt.zsh
${readFile ./rc/keybinds.zsh} . ~/.config/zsh/rc/keybinds.zsh
${readFile ./rc/aliases.zsh} . ~/.config/zsh/rc/aliases.zsh
${readFile ./rc/functions.zsh} . ~/.config/zsh/rc/functions.zsh
${readFile ./rc/misc.zsh} . ~/.config/zsh/rc/misc.zsh
''; '';
completionInit = '' completionInit = ''
${readFile ./rc/completion.zsh} . ~/.config/zsh/rc/completion.zsh
''; '';
profileExtra = '' profileExtra = ''
${readFile ./rc/profile.zsh} . ~/.config/zsh/rc/profile.zsh
''; '';
}; };
};
} }

View file

@ -198,8 +198,8 @@ anonymize() {
# Reset the prompt on initial run to allow this script # Reset the prompt on initial run to allow this script
# to be ran multiple times without user having to reload # to be ran multiple times without user having to reload
# PS1 manually # PS1 manually
# shellcheck source=/home/itsdrike/.config/shell/prompt # shellcheck source=/home/itsdrike/.config/zsh/rc/prompt
. "${XDG_CONFIG_DIR:-$HOME/.config}/shell/prompt" . "${XDG_CONFIG_DIR:-$HOME/.config}/zsh/rc/prompt.zsh"
# Regular expression to match 0-255 numbers (color) # Regular expression to match 0-255 numbers (color)
color_int_re='^(0+)?([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])$' color_int_re='^(0+)?([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])$'