forked from lix-project/lix
Allow setting bash-prompt-prefix nix develop configuration
This commit is contained in:
parent
eb957ad6d8
commit
2998527b18
|
@ -31,7 +31,7 @@ static void writeTrustedList(const TrustedList & trustedList)
|
||||||
|
|
||||||
void ConfigFile::apply()
|
void ConfigFile::apply()
|
||||||
{
|
{
|
||||||
std::set<std::string> whitelist{"bash-prompt", "bash-prompt-suffix", "flake-registry"};
|
std::set<std::string> whitelist{"bash-prompt", "bash-prompt-prefix", "bash-prompt-suffix", "flake-registry"};
|
||||||
|
|
||||||
for (auto & [name, value] : settings) {
|
for (auto & [name, value] : settings) {
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,9 @@ struct DevelopSettings : Config
|
||||||
Setting<std::string> bashPrompt{this, "", "bash-prompt",
|
Setting<std::string> bashPrompt{this, "", "bash-prompt",
|
||||||
"The bash prompt (`PS1`) in `nix develop` shells."};
|
"The bash prompt (`PS1`) in `nix develop` shells."};
|
||||||
|
|
||||||
|
Setting<std::string> bashPromptPrefix{this, "", "bash-prompt-prefix",
|
||||||
|
"Prefix prepended to the `PS1` environment variable in `nix develop` shells."};
|
||||||
|
|
||||||
Setting<std::string> bashPromptSuffix{this, "", "bash-prompt-suffix",
|
Setting<std::string> bashPromptSuffix{this, "", "bash-prompt-suffix",
|
||||||
"Suffix appended to the `PS1` environment variable in `nix develop` shells."};
|
"Suffix appended to the `PS1` environment variable in `nix develop` shells."};
|
||||||
};
|
};
|
||||||
|
@ -482,6 +485,9 @@ struct CmdDevelop : Common, MixEnvironment
|
||||||
if (developSettings.bashPrompt != "")
|
if (developSettings.bashPrompt != "")
|
||||||
script += fmt("[ -n \"$PS1\" ] && PS1=%s;\n",
|
script += fmt("[ -n \"$PS1\" ] && PS1=%s;\n",
|
||||||
shellEscape(developSettings.bashPrompt.get()));
|
shellEscape(developSettings.bashPrompt.get()));
|
||||||
|
if (developSettings.bashPromptPrefix != "")
|
||||||
|
script += fmt("[ -n \"$PS1\" ] && PS1=%s\"$PS1\";\n",
|
||||||
|
shellEscape(developSettings.bashPromptPrefix.get()));
|
||||||
if (developSettings.bashPromptSuffix != "")
|
if (developSettings.bashPromptSuffix != "")
|
||||||
script += fmt("[ -n \"$PS1\" ] && PS1+=%s;\n",
|
script += fmt("[ -n \"$PS1\" ] && PS1+=%s;\n",
|
||||||
shellEscape(developSettings.bashPromptSuffix.get()));
|
shellEscape(developSettings.bashPromptSuffix.get()));
|
||||||
|
|
Loading…
Reference in a new issue