]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
profile: replace default bash prompt with more informative one
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 6 Aug 2025 05:49:43 +0000 (14:49 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 6 Aug 2025 13:24:19 +0000 (14:24 +0100)
The default bash PS1 provides mostly no information.
Let's replace it.

Before:
```
[watanabe@thinkpad-x280:~] $ run0
🦸 bash-5.2# echo $PS1
🦸 \s-\v\$
```

After:
```
[watanabe@thinkpad-x280:~] $ run0
🦸 [root@thinkpad-x280 watanabe]# echo $PS1
🦸 [\u@\h \W]\$
```

Fixes #38494.

profile.d/70-systemd-shell-extra.sh

index dae77e4bc76941077b73e6698ae2a6cd1d0ee0d0..46dd82d9ce1b32731662ee5a7f2a58f522718858 100644 (file)
 # are propagated into these environment variables by pam_systemd(8).
 
 if [ -n "${SHELL_PROMPT_PREFIX-}" ]; then
+    if [ -n "${BASH_VERSION-}" ] && [ "$PS1" = "\\s-\\v\\\$ " ]; then
+        PS1="[\u@\h \W]\\$ "
+    fi
     PS1="$SHELL_PROMPT_PREFIX$PS1"
 fi
 
 if [ -n "${SHELL_PROMPT_SUFFIX-}" ]; then
+    if [ -n "${BASH_VERSION-}" ] && [ "$PS1" = "\\s-\\v\\\$ " ]; then
+        PS1="[\u@\h \W]\\$ "
+    fi
     PS1="$PS1$SHELL_PROMPT_SUFFIX"
 fi