Skip to content

Commit f391f29

Browse files
authored
Update xx-bash-prompt-command.sh
`fix: mark non-printable characters in bash prompt` from secureblue PR: https://github.com/secureblue/secureblue/pull/1296/files
1 parent 1837391 commit f391f29

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed
Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
# Taken from secureblue
2-
# https://github.com/secureblue/secureblue/blob/live/files/system/etc/profile.d/xx-bash-prompt-command.sh
31
#!/usr/bin/bash
42
# Filename needs to be alphabetically later than vte.sh
53
if [ -n "${BASH_VERSION:-}" ]; then
6-
export PROMPT_COMMAND='__bash_prompt_command 2>/dev/null'
7-
8-
__bash_prompt_command() {
9-
local prev_status="$?"
10-
if [ "$prev_status" != 0 ]; then
11-
# Print nonzero exit code in bold red text inside square brackets
12-
printf '\033[31m[\033[1m%s\033[22m]\033[39m' "$prev_status"
13-
fi
14-
# Default prompt taken from /etc/bashrc
15-
printf '\033]0;%s@%s:%s\007' "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"
16-
}
4+
# Print nonzero exit codes in bold red text inside square brackets at beginning of prompt
5+
export PS1='$(code=${?#0};echo -n "${code:+\[\e[31m\][\[\e[1m\]${code}\[\e[22m\]]\[\e[39m\]}")'"${PS1}"
176
fi

0 commit comments

Comments
 (0)