mirror of
https://github.com/nix-community/home-manager
synced 2024-12-25 03:09:47 +01:00
bash: improve initialisation (#1850)
Resolves #1843. Allows aliases to be expanded in initExtra, and adds a visible bashrcExtra option for commands that should be run in ~/.bashrc even by non-interactive shells.
This commit is contained in:
parent
90223cf3eb
commit
447ed0fbcb
1 changed files with 20 additions and 24 deletions
|
@ -111,17 +111,6 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
bashrcExtra = mkOption {
|
|
||||||
# Hide for now, may want to rename in the future.
|
|
||||||
visible = false;
|
|
||||||
default = "";
|
|
||||||
type = types.lines;
|
|
||||||
description = ''
|
|
||||||
Extra commands that should be added to
|
|
||||||
<filename>~/.bashrc</filename>.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
initExtra = mkOption {
|
initExtra = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
|
@ -131,6 +120,15 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bashrcExtra = mkOption {
|
||||||
|
default = "";
|
||||||
|
type = types.lines;
|
||||||
|
description = ''
|
||||||
|
Extra commands that should be placed in <filename>~/.bashrc</filename>.
|
||||||
|
Note that these commands will be run even in non-interactive shells.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
logoutExtra = mkOption {
|
logoutExtra = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
|
@ -171,19 +169,6 @@ in
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
in mkIf cfg.enable {
|
in mkIf cfg.enable {
|
||||||
programs.bash.bashrcExtra = ''
|
|
||||||
# Commands that should be applied only for interactive shells.
|
|
||||||
if [[ $- == *i* ]]; then
|
|
||||||
${historyControlStr}
|
|
||||||
|
|
||||||
${shoptsStr}
|
|
||||||
|
|
||||||
${aliasesStr}
|
|
||||||
|
|
||||||
${cfg.initExtra}
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
|
|
||||||
home.file.".bash_profile".text = ''
|
home.file.".bash_profile".text = ''
|
||||||
# -*- mode: sh -*-
|
# -*- mode: sh -*-
|
||||||
|
|
||||||
|
@ -208,6 +193,17 @@ in
|
||||||
# -*- mode: sh -*-
|
# -*- mode: sh -*-
|
||||||
|
|
||||||
${cfg.bashrcExtra}
|
${cfg.bashrcExtra}
|
||||||
|
|
||||||
|
# Commands that should be applied only for interactive shells.
|
||||||
|
[[ $- == *i* ]] || return
|
||||||
|
|
||||||
|
${historyControlStr}
|
||||||
|
|
||||||
|
${shoptsStr}
|
||||||
|
|
||||||
|
${aliasesStr}
|
||||||
|
|
||||||
|
${cfg.initExtra}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
home.file.".bash_logout" = mkIf (cfg.logoutExtra != "") {
|
home.file.".bash_logout" = mkIf (cfg.logoutExtra != "") {
|
||||||
|
|
Loading…
Reference in a new issue