mirror of
https://github.com/NixOS/nix.git
synced 2024-11-23 15:22:27 +00:00
Make the prompt used in development shells configurable
This commit is contained in:
parent
ac0e24f21b
commit
dc7d1322ef
@ -11,6 +11,19 @@
|
||||
|
||||
using namespace nix;
|
||||
|
||||
struct DevelopSettings : Config
|
||||
{
|
||||
Setting<std::string> bashPrompt{this, "", "bash-prompt",
|
||||
"The bash prompt (`PS1`) in `nix develop` shells."};
|
||||
|
||||
Setting<std::string> bashPromptSuffix{this, "", "bash-prompt-suffix",
|
||||
"Suffix appended to the `PS1` environment variable in `nix develop` shells."};
|
||||
};
|
||||
|
||||
static DevelopSettings developSettings;
|
||||
|
||||
static GlobalConfig::Register rDevelopSettings(&developSettings);
|
||||
|
||||
struct Var
|
||||
{
|
||||
bool exported = true;
|
||||
@ -429,6 +442,10 @@ struct CmdDevelop : Common, MixEnvironment
|
||||
|
||||
else {
|
||||
script += "[ -n \"$PS1\" ] && [ -e ~/.bashrc ] && source ~/.bashrc;\n";
|
||||
if (developSettings.bashPrompt != "")
|
||||
script += fmt("[ -n \"$PS1\" ] && PS1=%s;\n", shellEscape(developSettings.bashPrompt));
|
||||
if (developSettings.bashPromptSuffix != "")
|
||||
script += fmt("[ -n \"$PS1\" ] && PS1+=%s;\n", shellEscape(developSettings.bashPromptSuffix));
|
||||
}
|
||||
|
||||
writeFull(rcFileFd.get(), script);
|
||||
|
Loading…
Reference in New Issue
Block a user