os/shared/home/bash.nix

85 lines
No EOL
2 KiB
Nix

# Configuration of the shell.
# TODO: switch to a shell from this century
{ pkgs, lib, config, ... }:
let cfg = config.custom.bash;
in with lib; {
options.custom.bash = with types; {
extraAliases = mkOption {
default = {};
};
};
config = {
# Configure the shell itself
programs.bash = with pkgs; {
enable = true;
historyIgnore = [
"poweroff"
"reboot"
"exit"
"exa"
"fg"
"cd"
"ls"
"z"
];
historyControl = [
"ignorespace"
"ignoredups"
];
historySize = 100000;
sessionVariables = {
"EDITOR" = "${helix}/bin/hx";
};
shellAliases = {
# General aliases
":q" = "exit";
"t" = "${exa}/bin/exa -T";
".." = "cd ..";
# Git command aliases
"rebase" = "git rebase -i --autosquash --committer-date-is-author-date";
"uncommit" = "git reset --soft HEAD~";
# Git selectors
".changed" = "git diff --name-only";
".conflicted" = "git status --porcelain | rg '^UU' | sd '^.. ' ''";
".branches" = "git branch -a | rg -v '\*|HEAD' | sd 'remotes/origin/' '' | sd '^ *' '' | uniq";
# File extension selectors
".hs" = "${fd}/bin/fd -e hs";
".nix" = "${fd}/bin/fd -e nix";
".py" = "${fd}/bin/fd -e py";
".rs" = "${fd}/bin/fd -e rs";
".sh" = "${fd}/bin/fd -e sh";
".yaml" = "${fd}/bin/fd -e yaml -e yml";
".yml" = ".yaml";
} // cfg.extraAliases;
bashrcExtra = ''
export PATH=${../../script}:/home/riley/.nix-profile/bin:$PATH
'';
};
# Configure the prompt
programs.starship = {
enable = true;
settings = {
format = ''
$directory$git_branch$cmd_duration$sudo
$character
'';
character = {
success_symbol = "[>](bold green)";
error_symbol = "[](bold red)";
};
};
};
};
}