1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 11:39:46 +01:00

bash: allow unsetting shell options

This commit is contained in:
Renee Margaret McConahy 2021-08-23 01:28:21 -04:00 committed by Robert Helgesson
parent 039f786e60
commit 208e310e94
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -75,7 +75,14 @@ in
# Warn if closing shell with running jobs.
"checkjobs"
];
description = "Shell options to set.";
example = [
"extglob"
"-cdspell"
];
description = ''
Shell options to set. Prefix an option with
<quote><literal>-</literal></quote> to unset.
'';
};
sessionVariables = mkOption {
@ -146,8 +153,10 @@ in
mapAttrsToList (k: v: "alias ${k}=${escapeShellArg v}") cfg.shellAliases
);
shoptsStr = concatStringsSep "\n" (
map (v: "shopt -s ${v}") cfg.shellOptions
shoptsStr = let
switch = v: if hasPrefix "-" v then "-u" else "-s";
in concatStringsSep "\n" (
map (v: "shopt ${switch v} ${removePrefix "-" v}") cfg.shellOptions
);
sessionVarsStr = config.lib.shell.exportAll cfg.sessionVariables;