From 759a59f67bfcb7cf1fb11f289d04398eb78de908 Mon Sep 17 00:00:00 2001 From: Benoit Mortgat Date: Mon, 18 Jun 2012 14:19:12 +0200 Subject: [PATCH] Bash PS1: Correctly enclose nonprintable sections `\[` and `\]` are used for enclosing nonprinting characters in bash PS1. Enclosing printable characters inside those bracket pairs results in bad behaviour when the PWD contains characters from an extended character set (not strictly in ASCII). Therefore, instead of enclosing big chunks of PS1 inside `\[`...`\]` pairs, we only put them around the small, non-printable character parts. Signed-off-by: Benoit Mortgat --- etc/profile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/etc/profile b/etc/profile index 3acf9660..c406ad29 100644 --- a/etc/profile +++ b/etc/profile @@ -153,19 +153,20 @@ esac . /git/contrib/completion/git-completion.bash -PS1='\[\033]0;' # VT100 compat: reset all colors +# non-printable characters must be enclosed inside \[ and \] +PS1='\[\033[0m\]' # VT100 compat: reset all colors PS1="$PS1"'$MSYSTEM:\w' # e.g. MINGW32:/path/to/cwd -PS1="$PS1"'\007' # Ascii character BEL +PS1="$PS1"'\[\007\]' # Ascii character BEL PS1="$PS1"'\n' # new line -PS1="$PS1"'\033[32m\]' # change color +PS1="$PS1"'\[\033[32m\]' # change color PS1="$PS1"'\u@\h ' # user@host -PS1="$PS1"'\[\033[33m' # change color +PS1="$PS1"'\[\033[33m\]' # change color PS1="$PS1"'\w' # current working directory if test -z "$WINELOADERNOEXEC" then PS1="$PS1"'$(__git_ps1)' # bash function fi -PS1="$PS1"'\033[0m\]' # change color +PS1="$PS1"'\[\033[0m\]' # change color PS1="$PS1"'\n' # new line PS1="$PS1"'$ ' # prompt: always $ -- 2.11.4.GIT