質問

I am not exactly a pro at BASH Scripting, but I can get by with the basics. I use MRXVT with Cygwin on my windows box (MRXVT is an RXVT Terminal with tabs. RXVT is a Standard Cygwin terminal, but with enhanced features). I found a command to change the tab names for MRXVT:

echo -ne "\e]62;New tab title\a"

It works like a charm. I'm not, however, interested in A)Changing it manually or B)Changing it to a static String

I use a lot of SSH. I'd like the tab title to be username@host[current directory] at any given time.

I'm not sure if I'm supposed to use a trap for this. Frankly, I don't understand how traps work. I guess I could create an ssh alias that pulls the first argument of the ssh command and sets the tab title to that...This would be sufficient, but not preferred.

Do you guys have any ideas?

役に立ちましたか?

解決

Found an answer. added

trap 'echo -ne "\e]62;mrxvt: $USER@${HOSTNAME}\007"' DEBUG

to the very end of my .bashrc. I decided I didn't like having the path in my tabs (or titlebar for that matter). Also, I had to add "mrxvt: " to the beginning of the string because of an AHK script that I wrote; it wouldn't work properly otherwise. The full answer to this is:

trap 'echo -ne "\e]62;$USER@${HOSTNAME}[${pwd}]\007"' DEBUG

Again, just add that line to the end of your .bashrc, and you're good to go.

Hope this helps somebody else :)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top