Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
850 views
in Technique[技术] by (71.8m points)

bash - Set screen-title from shellscript

Is it possible to set the Screen Title using a shell script?

I thought about something like sending the key commands ctrl+A shift-A Name enter

I searched for about an hour on how to emulate keystrokes in an shell script, but didn't find the answer.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can set the screen / xterm title using the following lines:

#!/bin/bash

mytitle="Some title"
echo -e '33k'$mytitle'33\'

[UPDATE] - by request I'm also including the solution proposed by @Espo below:

Depending on your xterm version or your linux distribution the line above may or may not work and you can try the xterm-defaults:

#!/bin/bash

mytitle="Some title"
echo -e '33]2;'$mytitle'07'

For more on the details see: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#s3 or refer to the answer by @Espo below.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...