Skip to content

Instantly share code, notes, and snippets.

@pwood
Created February 11, 2010 12:26
Show Gist options
  • Save pwood/301467 to your computer and use it in GitHub Desktop.
Save pwood/301467 to your computer and use it in GitHub Desktop.
Stick this at the end of your .bashrc.
changetitle () {
if (( $# != 0 )); then
#echo -ne "\e]0;$* \a"
echo -ne "\033]0;$*\007"
fi
}
command_title () {
# New New sed way, easier on the eye, easier on the CPU
# newtitle=$(echo $(history 1) | sed -r -e 's/^[[:space:]]+[^[:space:]]+[[:space:]]+[^[:space:]]+[[:space:]]+[^[:space:]]+ //' | head -n 20)
newtitle=$(echo $(history 1) | sed -r -e 's/^[[:space:]]*[[:digit:]]*[[:space:]]*//')
if [ ! -z "$newtitle" ]; then
changetitle $newtitle
fi
# if [ -z "$newtitle" ]; then
# changetitle $LOGNAME@$HOSTNAME:$PWD
# else
# changetitle $newtitle
# fi
}
if [[ -z $(trap -p DEBUG) ]]; then
trap command_title DEBUG
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment