snowflake/user/shells.nix
datsudo c38929e6b1 reconfigure bash
because nix shells uses this
2025-06-06 20:47:57 +08:00

88 lines
2.1 KiB
Nix

{ config, pkgs, lib, ... }:
let
inherit (lib) mkIf mkOption mkMerge types;
cfg = config.shells;
aliases = {
"ls" = "lsd --color=never";
"ll" = "lsd -la --color=never";
"llt" = "lsd --tree --color=never";
"cp" = "cp --verbose";
"rm" = "rm --verbose";
"mv" = "mv --verbose";
"mkdir" = "mkdir --verbose";
"v" = "nvim";
"music" = "ncmpcpp";
"tls" = "tmux ls";
"tkl" = "tmux kill-session -t";
"tch" = "tmux attach";
"ytmusic" = "yt-dlp -f 'ba' -x --audio-format mp3 -o '%(id)s.%(ext)s'";
"ytvid" = "yt-dlp -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'";
};
in
{
options.shells = {
fish.enable = mkOption {
default = false;
type = types.bool;
description = ''Enables FISH'';
};
zsh.enable = mkOption {
default = true;
type = types.bool;
description = ''Enables ZSH'';
};
};
config = {
programs.fish = {
enable = cfg.fish.enable;
shellAliases = aliases;
plugins = [
{ name = "hydro"; src = pkgs.fishPlugins.hydro.src; }
];
functions = {
__fish_command_not_found_handler = {
body = "__fish_default_command_not_found_handler $argv[1]";
onEvent = "fish_command_not_found";
};
su = "command su --shell=/usr/bin/fish $argv";
};
};
programs.bash = {
enable = true;
historyIgnore = ["ls" "exit"];
shellAliases = aliases;
};
programs.zsh = {
enable = cfg.zsh.enable;
enableCompletion = true;
defaultKeymap = "emacs";
shellAliases = aliases;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
history.path = "${config.xdg.dataHome}/zsh/zsh_history";
initContent = ''
[ -f ~/.p10k.zsh ]; source ~/.p10k.zsh
'';
plugins = [
{
name = "powerlevel10k";
src = pkgs.zsh-powerlevel10k;
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
}
];
};
home.file.".p10k.zsh" = mkIf cfg.zsh.enable {
source = ../config/p10k-config;
};
};
}