diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-10-26 14:24:25 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-10-26 14:24:25 +0100 |
commit | dc7d1322efbaa176bff38b1ad15eab6e11c83340 (patch) | |
tree | 6f0578ca668b9c78f7d64d682c26ff909d65c94e /src/nix/develop.cc | |
parent | ac0e24f21b162f99c8e9437c710797820345a7a2 (diff) |
Make the prompt used in development shells configurable
Diffstat (limited to 'src/nix/develop.cc')
-rw-r--r-- | src/nix/develop.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nix/develop.cc b/src/nix/develop.cc index d3c4761a7..8fea7ee9c 100644 --- a/src/nix/develop.cc +++ b/src/nix/develop.cc @@ -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); |