2025-02-15 12:15:56 +00:00

198 lines
4.5 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
cfg = config.modules.shell.zsh;
in
{
options.modules.shell.zsh = {
enable = lib.mkOption {
default = false;
example = true;
};
};
config = lib.mkIf cfg.enable {
users.defaultUserShell = pkgs.zsh;
home.programs = {
zsh = {
enable = true;
autocd = true;
autosuggestion = {
enable = true;
strategy = [ "completion" ];
};
defaultKeymap = "viins";
dotDir = ".config/zsh";
enableCompletion = true;
enableVteIntegration = true;
history = {
append = true;
extended = true;
ignoreAllDups = true;
ignoreDups = true;
ignoreSpace = true;
save = 1000000;
size = 1000000;
};
initExtra = ''
## Colors
autoload -U colors && colors
## Directories
setopt AUTO_PUSHD
setopt CDABLE_VARS
setopt PUSHD_IGNORE_DUPS
setopt PUSHD_SILENT
setopt PUSHD_TO_HOME
## Expansion and globbing
setopt EXTENDED_GLOB
unsetopt GLOB_DOTS
unsetopt NOMATCH
## History
setopt BANG_HIST
setopt HIST_VERIFY
setopt INC_APPEND_HISTORY_TIME
## I/O
setopt INTERACTIVE_COMMENTS
setopt MULTIOS
unsetopt CLOBBER
## Jobs
setopt LONG_LIST_JOBS
setopt AUTO_RESUME
unsetopt BG_NICE
unsetopt NOTIFY
unsetopt HUP
unsetopt CHECK_JOBS
## Shell emulation
setopt APPEND_CREATE
## Prompt
PS1="%B%{$fg[magenta]%}%~%{$reset_color%} $%b "
## Vi mode
export KEYTIMEOUT=1
## Zsh line editor
unsetopt BEEP
'';
initExtraBeforeCompInit = ''
setopt HASH_LIST_ALL
'';
localVariables = {
# Prevent zsh-vi-mode overriding other keybinds
ZVM_INIT_MODE = "sourcing";
};
plugins = with pkgs; [
{
name = "zsh-vi-mode";
src = zsh-vi-mode;
file = "share/zsh-vi-mode/zsh-vi-mode.plugin.zsh";
}
{
name = "fast-syntax-highlighting";
src = zsh-fast-syntax-highlighting;
file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
}
{
name = "jq-zsh-plugin";
src = jq-zsh-plugin;
file = "share/jq-zsh-plugin/jq.plugin.zsh";
}
{
name = "zsh-autopair";
src = zsh-autopair;
file = "share/zsh/zsh-autopair/autopair.zsh";
}
{
name = "zsh-forgit";
src = zsh-forgit;
file = "share/zsh/zsh-forgit/forgit.plugin.zsh";
}
{
name = "zsh-fzf-tab";
src = zsh-fzf-tab;
file = "share/fzf-tab/fzf-tab.plugin.zsh";
}
{
name = "zsh-nix-shell";
src = zsh-nix-shell;
file = "share/zsh-nix-shell/nix-shell.plugin.zsh";
}
];
sessionVariables = {
MODE_INDICATOR = "";
MODE_CURSOR_VIINS = "#b77ee0 blinking bar";
MODE_CURSOR_REPLACE = "$MODE_CURSOR_VIINS #ff3334";
MODE_CURSOR_VICMD = "#b77ee0 block";
MODE_CURSOR_SEARCH = "#e7c547 steady underline";
MODE_CURSOR_VISUAL = "$MODE_CURSOR_VICMD steady bar";
MODE_CURSOR_VLINE = "$MODE_CURSOR_VISUAL #54ced6";
ZVM_LINE_INIT_MODE = "i";
};
shellAliases = {
# Verbose file operations
cp = "cp -iv";
mv = "mv -iv";
rm = "rm -v";
mkdir = "mkdir -v";
# Colorize commands
ls = "ls -h --color=auto --group-directories-first";
# Abbreviations
e = "$EDITOR";
f = "$FILE";
g = "git";
m = "neomutt";
n = "$FILE";
v = "$EDITOR";
};
};
broot.enable = true;
direnv = {
enable = true;
nix-direnv.enable = true;
};
fzf = {
enable = true;
enableZshIntegration = true;
package = pkgs.unstable.fzf;
};
mcfly.enable = true;
navi.enable = true;
nix-index.enable = true;
};
user.packages = with pkgs; [
bat
fd
jq
nix-zsh-completions
nnn
ripgrep
];
};
}