bash: support bash completion
This commit is contained in:
parent
d9e03b7f8c
commit
f5e9879e74
6 changed files with 60 additions and 1 deletions
|
|
@ -30,6 +30,27 @@ in
|
|||
programs.bash = {
|
||||
enable = mkEnableOption "GNU Bourne-Again SHell";
|
||||
|
||||
enableCompletion = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to enable Bash completion for all interactive Bash shells.
|
||||
|
||||
</para><para>
|
||||
|
||||
Note, if you use NixOS or nix-darwin and do not have Bash completion
|
||||
enabled in the system configuration, then make sure to add
|
||||
|
||||
<programlisting language="nix">
|
||||
environment.pathsToLink = [ "/share/bash-completion" ];
|
||||
</programlisting>
|
||||
|
||||
to your system configuration to get completion for system packages.
|
||||
Note, the legacy <filename>/etc/bash_completion.d</filename> path is
|
||||
not supported by Home Manager.
|
||||
'';
|
||||
};
|
||||
|
||||
historySize = mkOption {
|
||||
type = types.int;
|
||||
default = 10000;
|
||||
|
|
@ -193,6 +214,15 @@ in
|
|||
[[ -f ~/.bashrc ]] && . ~/.bashrc
|
||||
'';
|
||||
|
||||
# If completion is enabled then make sure it is sourced very early. This
|
||||
# is to avoid problems if any other initialization code attempts to set up
|
||||
# completion.
|
||||
programs.bash.initExtra = mkIf cfg.enableCompletion (mkOrder 100 ''
|
||||
if [[ ! -v BASH_COMPLETION_VERSINFO ]]; then
|
||||
. "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh"
|
||||
fi
|
||||
'');
|
||||
|
||||
home.file.".profile".source = writeBashScript "profile" ''
|
||||
. "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue