diff --git a/modules/home/bash.nix b/modules/home/bash.nix new file mode 100644 index 0000000..dcfadc6 --- /dev/null +++ b/modules/home/bash.nix @@ -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; + }; +} diff --git a/modules/home/bash/complete-alias.nix b/modules/home/bash/complete-alias.nix new file mode 100644 index 0000000..1b3a6c6 --- /dev/null +++ b/modules/home/bash/complete-alias.nix @@ -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[@]}" + ''; + }; +} diff --git a/modules/home/users/msyds/bash.nix b/modules/home/users/msyds/bash.nix index 2c65897..4c155ca 100644 --- a/modules/home/users/msyds/bash.nix +++ b/modules/home/users/msyds/bash.nix @@ -6,25 +6,25 @@ in { options.sydnix.users.msyds.bash.enable = lib.mkEnableOption "Bash, à la msyds"; config = lib.mkIf cfg.enable { - programs.bash = { - enable = true; - shellOptions = [ - # Correct minor typos in cd commands. - "cdspell" - # Implicitly prepend `cd` to directory names. - "autocd" - # Extra glob power. - "extglob" - # Recursive glob w/ **. - "globstar" - # Append to history file. - "histappend" - # Require user confirmation for commands using expansion. - "histverify" - # Re-edit failed history substitutions. - "histreedit" - ]; - }; + sydnix.bash.enable = true; + sydnix.bash.complete-alias.enable = true; + + programs.bash.shellOptions = [ + # Correct minor typos in cd commands. + "cdspell" + # Implicitly prepend `cd` to directory names. + "autocd" + # Extra glob power. + "extglob" + # Recursive glob w/ **. + "globstar" + # Append to history file. + "histappend" + # Require user confirmation for commands using expansion. + "histverify" + # Re-edit failed history substitutions. + "histreedit" + ]; home.shellAliases = { nix2json = "nix eval --impure --json --file -";