feat(bash): alias completions

This commit is contained in:
2026-03-26 08:44:41 -06:00
parent c551e8f86e
commit da60eaa936
3 changed files with 51 additions and 19 deletions

16
modules/home/bash.nix Normal file
View File

@@ -0,0 +1,16 @@
{ config, lib, pkgs, ... }:
let cfg = config.sydnix.bash;
in {
options.sydnix.bash = {
enable = lib.mkEnableOption "Bash";
};
imports = [
./bash/complete-alias.nix
];
config = lib.mkIf cfg.enable {
programs.bash.enable = true;
};
}

View File

@@ -0,0 +1,16 @@
{ config, lib, pkgs, ... }:
let
cfg = config.sydnix.bash.complete-alias;
in {
options.sydnix.bash.complete-alias = {
enable = lib.mkEnableOption "Alias completion";
};
config = lib.mkIf cfg.enable {
programs.bash.initExtra = lib.mkAfter ''
. ${lib.getExe pkgs.complete-alias}
complete -F _complete_alias "''${!BASH_ALIASES[@]}"
'';
};
}

View File

@@ -6,25 +6,25 @@ in {
options.sydnix.users.msyds.bash.enable = options.sydnix.users.msyds.bash.enable =
lib.mkEnableOption "Bash, à la msyds"; lib.mkEnableOption "Bash, à la msyds";
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.bash = { sydnix.bash.enable = true;
enable = true; sydnix.bash.complete-alias.enable = true;
shellOptions = [
# Correct minor typos in cd commands. programs.bash.shellOptions = [
"cdspell" # Correct minor typos in cd commands.
# Implicitly prepend `cd` to directory names. "cdspell"
"autocd" # Implicitly prepend `cd` to directory names.
# Extra glob power. "autocd"
"extglob" # Extra glob power.
# Recursive glob w/ **. "extglob"
"globstar" # Recursive glob w/ **.
# Append to history file. "globstar"
"histappend" # Append to history file.
# Require user confirmation for commands using expansion. "histappend"
"histverify" # Require user confirmation for commands using expansion.
# Re-edit failed history substitutions. "histverify"
"histreedit" # Re-edit failed history substitutions.
]; "histreedit"
}; ];
home.shellAliases = { home.shellAliases = {
nix2json = "nix eval --impure --json --file -"; nix2json = "nix eval --impure --json --file -";