I have the following as my $PROMPT_COMMAND in .bashrc:
Code:
PROMPT_COMMAND='
if [ $TERM = "screen" ]; then
MYPWD="${PWD/#$HOME/~}"
[ ${#MYPWD} -gt 20 ] && MYPWD=..${MYPWD:${#MYPWD}-18}
echo -n -e "\033k$MYPWD\033\\"
fi
'
I am trying to append items to my PROMPT_COMMAND in another script/on command line. If I do the following:
Code:
export PROMPT_COMMAND="$PROMPT_COMMAND && ls"
bash has a syntax error and complains of unexpected token near &&.
But if I change the following in .bashrc
Code:
PROMPT_COMMAND='
if [ $TERM = "screen" ]; then
MYPWD="${PWD/#$HOME/~}"
[ ${#MYPWD} -gt 20 ] && MYPWD=..${MYPWD:${#MYPWD}-18}
echo -n -e "\033k$MYPWD\033\\"
fi && ls
'
I get no error.
I've echoed the value of $PROMPT_COMMAND in both cases and their output is exactly the same.
Any tips? Thanks.