update terminal title from standard output of long running command?

Posted by Sam Hasler on Super User See other posts from Super User or by Sam Hasler
Published on 2012-11-14T10:33:12Z Indexed on 2012/11/23 17:09 UTC
Read the original article Hit count: 257

Filed under:
|
|

I'd like to change the title of a terminal window during a long running command (for example: git svn fetch) with values greped from the output, whilst still writing to standard output.

Is this possible using named pipes or tee and xargs?

I'm thinking something like

git svn fetch | sed "s/^\(r\d*\).*$/ \"\\\033]0;\"\1\"\\\007\"/" | xargs -l1 echo -ne

based on: http://tldp.org/HOWTO/Xterm-Title-3.html


Update:

getting this to work would be enough:

(echo "r9" ; echo "r10") | sed "s/^\(r\d*\).*$/ \"\\\033]0;\"\1\"\\\007\"/" | xargs -l1 echo -ne

Update 2:

This almost does what I want. I see r10, but not r9:

(echo "r9" ; sleep 1 ; echo "r10") | sed "s/^\(r[0-9]*\)\.*$/\\\033]0;\1\\\007/" | xargs -0 echo -ne

© Super User or respective owner

Related posts about shell-script

Related posts about tee