os/shared/home/bash.nix

85 lines
2 KiB
Nix
Raw Normal View History

2023-05-21 22:26:26 +02:00
# Configuration of the shell.
2023-05-22 00:45:36 +02:00
# TODO: switch to a shell from this century
2023-05-21 21:15:04 +02:00
{ pkgs, lib, config, ... }:
2023-05-22 00:45:36 +02:00
let cfg = config.custom.bash;
2023-05-21 21:15:04 +02:00
in with lib; {
2023-05-22 00:45:36 +02:00
options.custom.bash = with types; {
2023-05-21 21:15:04 +02:00
extraAliases = mkOption {
default = {};
};
};
config = {
# Configure the shell itself
2023-05-23 17:38:19 +02:00
programs.bash = with pkgs; {
2023-05-21 21:15:04 +02:00
enable = true;
2023-05-23 17:38:19 +02:00
historyIgnore = [
"poweroff"
"reboot"
"exit"
"exa"
"fg"
"cd"
"ls"
"z"
];
historyControl = [
"ignorespace"
"ignoredups"
];
historySize = 100000;
sessionVariables = {
"EDITOR" = "${helix}/bin/hx";
};
2023-05-22 01:38:26 +02:00
shellAliases = {
2023-05-23 17:38:19 +02:00
# General aliases
2023-05-22 01:38:26 +02:00
":q" = "exit";
2023-05-23 17:38:19 +02:00
"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";
2023-05-22 01:38:26 +02:00
} // cfg.extraAliases;
2023-05-24 11:00:38 +02:00
bashrcExtra = ''
export PATH=${../../script}:/home/riley/.nix-profile/bin:$PATH
'';
2023-05-21 21:15:04 +02:00
};
2023-05-21 22:26:26 +02:00
# Configure the prompt
2023-05-22 01:38:26 +02:00
programs.starship = {
enable = true;
settings = {
format = ''
$directory$git_branch$cmd_duration$sudo
$character
'';
character = {
success_symbol = "[>](bold green)";
error_symbol = "[](bold red)";
};
};
};
2023-05-21 21:15:04 +02:00
};
}