Avoid double semicolon in the PROMPT_COMMAND

The direnv bash hook already add a semicolon to the PROMPT_COMMAND and this
plugin will add another one if direnv is installed. This commit will check if
the PROMPT_COMMAND ends with semicolon to avoid have double ones.
pull/1222/head
Enze Chi 2018-08-02 21:46:20 +10:00
parent 812a5d411b
commit f847371447
1 changed files with 1 additions and 1 deletions

View File

@ -5,7 +5,7 @@ about-plugin 'osx-specific functions'
if [ $(uname) = "Darwin" ]; then
if type update_terminal_cwd > /dev/null 2>&1 ; then
if ! [[ $PROMPT_COMMAND =~ (^|;)update_terminal_cwd($|;) ]] ; then
PROMPT_COMMAND="$PROMPT_COMMAND;update_terminal_cwd"
PROMPT_COMMAND="${PROMPT_COMMAND%;};update_terminal_cwd"
declared="$(declare -p PROMPT_COMMAND)"
[[ "$declared" =~ \ -[aAilrtu]*x[aAilrtu]*\ ]] 2>/dev/null
[[ $? -eq 0 ]] && export PROMPT_COMMAND