basic prompt: PROMPT_COMMAND="echo -ne \"\033]0;${USER}@${HOSTNAME} `tty` ${PWD/$HOME/~}\007\"" test: (( history | tail -2 | head -1 | grep \"vim\|less\" )) doesn't work because of \" for grep... and the final thing that needs to be modified till it works :D : PROMPT_COMMAND="(( history | tail -2 | head -1 | grep \"vim\|less\" )) || 'echo -ne \"\033]0;${USER}@${HOSTNAME} `tty` ${PWD/$HOME/~}\007\"' && 'echo -ne \"\033]0;${USER}@${HOSTNAME} `tty` $_ {PWD/$HOME/~}\007\"'"