Article:
  bash on Mac OS X
Subject:   if only ...
Date:   2004-02-25 08:54:46
From:   blalor
Response to: if only ...

But you can!


if [ "${TERM#xterm}" != "${TERM}" ] && [ "${EMACS}" != "t" ]; then
# Set prompt to "[$USER@$HOSTNAME `pwd` ]> "
prompt_command () {
# Display my current machine and directory in the title bar!
title="${LOGNAME}@$(hostname -s):[$(dirs)]"
echo -n "ESC]1;$title^G"
echo -n "ESC]2;$title^G"
}


export PROMPT_COMMAND=prompt_command
else
unset PROMPT_COMMAND
fi


(the ESC and ^G are actually control characters I entered in with Emacs; \033 and \007 would probably work, too.)
That gives you a prompt like [blalor@Animal ~]> and a window title like blalor@Animal:[~]

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • if only ...
    2004-02-28 04:29:31  hysterion [View]

    This does the precmd part. OTOH there is no bash equivalent for the postcmd part (used here to put the last command executed in the title bar).

    This can be done in tcsh and zsh, but in bash there is simply no way unless you patch it.
  • if only ...
    2004-02-27 04:04:25  henksmets [View]

    Great, thanks a lot, I looked a long time for this

    I'm also looking for a way to colorize my different ssh-connections, with the same color for each host. I found some tips but someway it doesn't work. Are bash solutions?

    http://www.macosxhints.com/article.php?story=20030625043920144

    http://www.macosxhints.com/article.php?story=20030213071650891