at 23.11-pre 1.1 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 enable = config.programs.bash.enableCompletion; 7in 8{ 9 options = { 10 programs.bash.enableCompletion = mkEnableOption (lib.mdDoc "Bash completion for all interactive bash shells") // { 11 default = true; 12 }; 13 }; 14 15 config = mkIf enable { 16 programs.bash.promptPluginInit = '' 17 # Check whether we're running a version of Bash that has support for 18 # programmable completion. If we do, enable all modules installed in 19 # the system and user profile in obsolete /etc/bash_completion.d/ 20 # directories. Bash loads completions in all 21 # $XDG_DATA_DIRS/bash-completion/completions/ 22 # on demand, so they do not need to be sourced here. 23 if shopt -q progcomp &>/dev/null; then 24 . "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh" 25 nullglobStatus=$(shopt -p nullglob) 26 shopt -s nullglob 27 for p in $NIX_PROFILES; do 28 for m in "$p/etc/bash_completion.d/"*; do 29 . "$m" 30 done 31 done 32 eval "$nullglobStatus" 33 unset nullglobStatus p m 34 fi 35 ''; 36 }; 37}