GNU bug report logs - #60365
[PATCH 0/4] Rationalize 'PS1' handling in home, system, and shell

Previous Next

Package: guix-patches;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Tue, 27 Dec 2022 21:25:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 60365 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: 60365 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH 2/4] system: Define default 'PS1' in /etc/bashrc rather than
 ~/.bashrc.
Date: Tue, 27 Dec 2022 22:26:16 +0100
Users can override 'PS1' in ~/.bashrc if they wish.

Previously, on Guix Home, the "default" 'PS1' would be set in ~/.bashrc
when 'home-bash-configuration-guix-defaults?' is true, preventing users
from overriding it via the 'environment-variables' field of
'home-bash-extension'.

* gnu/system/shadow.scm (%default-bashrc): Remove 'PS1' setting.
* gnu/system.scm (operating-system-etc-service): Define PS1 in
/etc/bashrc.
---
 gnu/system.scm        | 3 +++
 gnu/system/shadow.scm | 7 -------
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index 62c8e0c2b6..d67f9a615b 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -1047,6 +1047,9 @@ (define* (operating-system-etc-service os)
         (bashrc    (plain-file "bashrc" "\
 # Bash-specific initialization.
 
+# Provide a default prompt.  The user's ~/.bashrc can override it.
+PS1='\\u@\\h \\w${GUIX_ENVIRONMENT:+ [env]}\\$ '
+
 # The 'bash-completion' package.
 if [ -f /run/current-system/profile/etc/profile.d/bash_completion.sh ]
 then
diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index 4360a5ebd1..2e87928368 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -142,13 +142,6 @@ (define %default-bashrc
 # Source the system-wide file.
 [ -f /etc/bashrc ] && source /etc/bashrc
 
-# Adjust the prompt depending on whether we're in 'guix environment'.
-if [ -n \"$GUIX_ENVIRONMENT\" ]
-then
-    PS1='\\u@\\h \\w [env]\\$ '
-else
-    PS1='\\u@\\h \\w\\$ '
-fi
 alias ls='ls -p --color=auto'
 alias ll='ls -l'
 alias grep='grep --color=auto'\n"))
-- 
2.38.1





This bug report was last modified 2 years and 140 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.