diff options
| author | seth <[email protected]> | 2024-02-03 19:27:26 -0500 |
|---|---|---|
| committer | seth <[email protected]> | 2024-02-03 20:47:55 -0500 |
| commit | fcc60b84e5e3cc44986d40af63f5de488caae909 (patch) | |
| tree | 45f4455c7dcbc63e59e62a9af79783e2e5509a2e /users/seth/module/shell/zsh.nix | |
| parent | de003fa28e56b81a33e831099987cd94d2f53b39 (diff) | |
make everything a module
Diffstat (limited to 'users/seth/module/shell/zsh.nix')
| -rw-r--r-- | users/seth/module/shell/zsh.nix | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/users/seth/module/shell/zsh.nix b/users/seth/module/shell/zsh.nix new file mode 100644 index 0000000..b3f31b9 --- /dev/null +++ b/users/seth/module/shell/zsh.nix @@ -0,0 +1,128 @@ +{ + config, + lib, + pkgs, + ... +}: let + cfg = config.seth.shell.zsh; +in { + options.seth.shell.zsh = { + enable = lib.mkEnableOption "Zsh configuration"; + withPlugins = lib.mkEnableOption "Zsh plugins" // {default = true;}; + }; + + config = lib.mkIf cfg.enable { + programs.zsh = lib.mkMerge [ + { + enable = true; + enableAutosuggestions = true; + + completionInit = '' + autoload -Uz bashcompinit compinit + local zdump="${config.xdg.cacheHome}/zsh/zdump" + bashcompinit + compinit -d "$zdump" + if [[ ! "$zdump.zwc" -nt "$zdump" ]] + then + zcompile "$zdump" + fi + unset zdump + ''; + + defaultKeymap = "emacs"; + dotDir = ".config/zsh"; + + initExtra = '' + if [[ -r "$XDG_CACHE_HOME/p10k-instant-prompt-*.zsh" ]]; then + source "$XDG_CACHE_HOME/p10k-instant-prompt-*.zsh" + fi + autoload -Uz promptinit colors + promptinit + colors + + ${lib.getExe pkgs.nix-your-shell} zsh | source /dev/stdin + + zmodload zsh/zutil + zmodload zsh/complist + zstyle ":completion::*" group-name "" + zstyle ":completion:*" menu "select" + zstyle ":completion:*" squeeze-slashes "true" + zstyle ":completion::*" use-cache "true" + zstyle ":completion::*" cache-path "$zdump" + + unsetopt beep + unsetopt hist_beep + unsetopt ignore_braces + unsetopt list_beep + setopt always_to_end + setopt prompt_subst + setopt share_history + + # clear backbuffer with ctrl-l + function clear-screen-and-scrollback() { + echoti civis >"$TTY" + printf '%b' '\e[H\e[2J' >"$TTY" + zle .reset-prompt + zle -R + printf '%b' '\e[3J' >"$TTY" + echoti cnorm >"$TTY" + } + + zle -N clear-screen-and-scrollback + bindkey '^L' clear-screen-and-scrollback + + [[ ! -f ~/.config/zsh/.p10k.zsh ]] || source ~/.config/zsh/.p10k.zsh + ''; + + history = { + expireDuplicatesFirst = true; + path = "${config.xdg.stateHome}/zsh/zsh_history"; + save = 1000; + size = 100; + }; + } + + (lib.mkIf cfg.withPlugins { + plugins = [ + { + name = "cattppuccin-zsh-syntax-highlighting"; + src = pkgs.fetchFromGitHub { + owner = "catppuccin"; + repo = "zsh-syntax-highlighting"; + rev = "06d519c20798f0ebe275fc3a8101841faaeee8ea"; + sha256 = "sha256-Q7KmwUd9fblprL55W0Sf4g7lRcemnhjh4/v+TacJSfo="; + }; + + file = "themes/catppuccin_mocha-zsh-syntax-highlighting.zsh"; + } + + { + name = "nix-zsh-completions"; + src = pkgs.nix-zsh-completions; + file = "share/zsh/plugins/nix/nix-zsh-completions.plugin.zsh"; + } + + { + name = "powerlevel10k"; + src = pkgs.zsh-powerlevel10k; + file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme"; + } + + { + name = "zsh-autopair"; + src = pkgs.zsh-autopair; + file = "share/zsh/zsh-autopair/autopair.zsh"; + } + + { + name = "zsh-completions"; + src = pkgs.zsh-completions; + file = "share/zsh-completions/zsh-completions.plugin.zsh"; + } + ]; + + enableSyntaxHighlighting = true; + }) + ]; + }; +} |
