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 = {
|
|
|
|
|
2023-06-06 15:38:06 +02:00
|
|
|
home.packages = [ pkgs.perl ];
|
|
|
|
|
2023-05-21 21:15:04 +02:00
|
|
|
# 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"
|
2023-09-21 17:38:37 +02:00
|
|
|
"eza"
|
2023-05-23 17:38:19 +02:00
|
|
|
"fg"
|
|
|
|
"cd"
|
|
|
|
"ls"
|
|
|
|
"z"
|
|
|
|
];
|
|
|
|
historyControl = [
|
|
|
|
"ignorespace"
|
|
|
|
"ignoredups"
|
|
|
|
];
|
|
|
|
historySize = 100000;
|
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-09-21 17:38:37 +02:00
|
|
|
"t" = "${eza}/bin/eza -T";
|
|
|
|
"l" = "${eza}/bin/eza";
|
2023-05-23 17:38:19 +02:00
|
|
|
".." = "cd ..";
|
|
|
|
|
|
|
|
# Git command aliases
|
|
|
|
"rebase" = "git rebase -i --autosquash --committer-date-is-author-date";
|
|
|
|
"uncommit" = "git reset --soft HEAD~";
|
|
|
|
|
|
|
|
# Git selectors
|
2023-06-15 20:41:51 +02:00
|
|
|
".changed" = "git diff --diff-filter=AM --name-only";
|
|
|
|
".staged" = "git diff --diff-filter=AM --name-only --cached";
|
2023-05-23 17:38:19 +02:00
|
|
|
".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-06-06 15:38:06 +02:00
|
|
|
export EDITOR=${helix}/bin/hx
|
2023-05-24 11:00:38 +02:00
|
|
|
'';
|
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 = {
|
2023-06-06 16:07:28 +02:00
|
|
|
add_newline = false;
|
2023-05-22 01:38:26 +02:00
|
|
|
format = ''
|
2023-06-06 16:07:28 +02:00
|
|
|
$username at $hostname // $directory$git_branch $character
|
2023-05-22 01:38:26 +02:00
|
|
|
'';
|
|
|
|
character = {
|
2023-06-06 16:07:28 +02:00
|
|
|
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";
|
2023-05-22 01:38:26 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-05-21 21:15:04 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|