os/shared/home/bash.nix

105 lines
2.6 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 = {
home.packages = [ pkgs.perl ];
# Configure the shell itself
programs.bash = with pkgs; {
enable = true;
historyIgnore = [
"poweroff"
"reboot"
"exit"
"exa"
"eza"
"fg"
"cd"
"ls"
"z"
];
historyControl = [
"ignorespace"
"ignoredups"
];
historySize = 100000;
shellAliases = {
# General aliases
":q" = "exit";
"t" = "${eza}/bin/eza -T";
"l" = "${eza}/bin/eza";
".." = "cd ..";
# Git command aliases
"rebase" = "git rebase -i --autosquash --committer-date-is-author-date";
"uncommit" = "git reset --soft HEAD~";
# Git selectors
".changed" = "git diff --diff-filter=AM --name-only";
".staged" = "git diff --diff-filter=AM --name-only --cached";
".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
export EDITOR=${helix}/bin/hx
'';
};
# Configure the prompt
programs.starship = {
enable = true;
settings = {
add_newline = false;
format = ''
$username at $hostname // $directory$git_branch $character
'';
character = {
success_symbol = "[>](bold #1fed71)";
error_symbol = "[!](bold #ff8426)";
};
username = {
show_always = true;
format = "[$user]($style)";
style_user = "bold #40de46";
};
hostname = {
ssh_only = false;
format = "[$hostname]($style)";
style = "bold #1fb8ff";
};
directory = {
format = "[$path]($style)";
};
git_branch = {
format = " :: [$symbol$branch]($style)";
style = "bold #c745ff";
};
};
};
};
}