diff options
| author | Daiderd Jordan <daiderd@gmail.com> | 2018-10-17 19:04:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-17 19:04:48 +0200 |
| commit | e6a698a7011487f16dd061d65e36ec330465ed16 (patch) | |
| tree | b675c5c1c5582356501a43d721ba0d54e7e68880 /modules/programs/bash | |
| parent | 5fa894c90ac224f86592a3d7da76932593542a16 (diff) | |
| parent | 1a786eb08879d66ac67c3c584f05f3d9c2567c2b (diff) | |
Merge pull request #109 from marsam/feature/update-bashrc-config
Do not evaluate /etc/bashrc on non-interactive shells
Diffstat (limited to 'modules/programs/bash')
| -rw-r--r-- | modules/programs/bash/default.nix | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/modules/programs/bash/default.nix b/modules/programs/bash/default.nix index 0e116ae..ea5afe2 100644 --- a/modules/programs/bash/default.nix +++ b/modules/programs/bash/default.nix @@ -52,9 +52,6 @@ in # /etc/bashrc: DO NOT EDIT -- this file has been generated automatically. # This file is read for interactive shells. - # Make bash check its window size after a process completes - shopt -s checkwinsize - [ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM" # Only execute this file once per shell. @@ -66,23 +63,32 @@ in export PATH=${config.environment.systemPath} ${config.system.build.setEnvironment.text} + + # Return early if not running interactively, but after basic nix setup. + [[ $- != *i* ]] && return + + # Make bash check its window size after a process completes + shopt -s checkwinsize + ${config.system.build.setAliases.text} ${config.environment.interactiveShellInit} ${cfg.interactiveShellInit} ${optionalString cfg.enableCompletion '' - source "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh" - - nullglobStatus=$(shopt -p nullglob) - shopt -s nullglob - for p in $NIX_PROFILES; do - for m in "$p/etc/bash_completion.d/"* "$p/share/bash-completion/completions/"*; do - source $m + if [ "$TERM" != "dumb" ]; then + source "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh" + + nullglobStatus=$(shopt -p nullglob) + shopt -s nullglob + for p in $NIX_PROFILES; do + for m in "$p/etc/bash_completion.d/"* "$p/share/bash-completion/completions/"*; do + source $m + done done - done - eval "$nullglobStatus" - unset nullglobStatus p m + eval "$nullglobStatus" + unset nullglobStatus p m + fi ''} # Read system-wide modifications. |
