[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/07: system: Define default 'PS1' in /etc/bashrc rather than ~/.bashrc
From: |
guix-commits |
Subject: |
04/07: system: Define default 'PS1' in /etc/bashrc rather than ~/.bashrc. |
Date: |
Thu, 5 Jan 2023 09:17:50 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit 086df6ef213d44d4b75c263033552eef6b2bd868
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Dec 27 21:52:59 2022 +0100
system: Define default 'PS1' in /etc/bashrc rather than ~/.bashrc.
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/home/services/shells.scm (add-bash-configuration): When
'home-bash-configuration-guix-defaults?' is true, add a default 'PS1' to
~/.bash_profile.
---
gnu/home/services/shells.scm | 9 +++++++++
gnu/system.scm | 3 +++
gnu/system/shadow.scm | 7 -------
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm
index d7dd579293..3326eb37f4 100644
--- a/gnu/home/services/shells.scm
+++ b/gnu/home/services/shells.scm
@@ -407,6 +407,15 @@ if [ -f ~/.profile ]; then source ~/.profile; fi
# Honor per-interactive-shell startup file
if [ -f ~/.bashrc ]; then source ~/.bashrc; fi
"
+
+ ;; The host distro might provide a bad 'PS1' default--e.g., not taking
+ ;; $GUIX_ENVIRONMENT into account. Provide a good default here when
+ ;; asked to. The default can be overridden below via
+ ;; 'environment-variables'.
+ (if (home-bash-configuration-guix-defaults? config)
+ "PS1='\\u@\\h \\w${GUIX_ENVIRONMENT:+ [env]}\\$ '\n"
+ "")
+
(serialize-field 'bash-profile)
(serialize-field 'environment-variables)))
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 @@ fi
(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 @@ fi
# 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"))
- branch master updated (dc7eb6f07a -> 80902fc210), guix-commits, 2023/01/05
- 02/07: home: services: environment-variables: Add support for literal strings., guix-commits, 2023/01/05
- 04/07: system: Define default 'PS1' in /etc/bashrc rather than ~/.bashrc.,
guix-commits <=
- 06/07: environment: Avoid false positive on 'PS1' check., guix-commits, 2023/01/05
- 07/07: gnu: guile-avahi: Fix cross-compilation., guix-commits, 2023/01/05
- 05/07: environment: Simplify 'PS1' suggestion on '--check'., guix-commits, 2023/01/05
- 01/07: home: '--version' really says "guix home"., guix-commits, 2023/01/05
- 03/07: system, home: Factorize default '.bashrc'., guix-commits, 2023/01/05