I have been working on some ideas to try to get Bash shells on my AWS server to take a specific title such as “EC2 CLI” or “EC2 PostgreSQL log”. The convenience would be in having clearly labeled tabs so I can figure out the source of the 10-15 things I have open at times.
I was able to set a tab name in Terminal (OS X) quite easily. In ~/.bash_profile, I set a default tab name via:
DISABLE_AUTO_TITLE="true"echo -en '\033]2;EC2 CLI\007'
So far so good, but as soon as I did a sudo su, I was back to dynamic window titling. To now, I have not been able to get a root window (Amazon Linux 2) to accept a window title change, even from the command prompt. But here's where it got interesting...
I moved onto another project and was trying to rsync with a long-established alias when this happened.
clark:rsync -v -r -z --delete -e ssh /Library/Webserver/Documents/simplexable/ ec2-user@simplexable.com:/var/www/html/simplexable/protocol version mismatch -- is your shell clean?
(see the rsync man page for an explanation)
rsync error: protocol incompatibility (code 2) at (...)
It turned out that I had left an echo command on the AWS server in ~/.bashrc which was a variation of the above echo -en '\033]2;EC2 CLI\007' when I was working on stopping dynamic titling. Here's how I found out this was the conflict.
In this post, "Azendale" posts the following test:
“This is commonly caused by your shell's login stuff outputting stuff on a non-interactive shell. You can test if this is the case by doing:
ssh username@host "/bin/true" >̄testfile
ls -l testfileIf testfile is NOT 0 bytes, then the trouble is that your shell is outputting something. Check /etc/profile, .profile, .bashrc, .cshrc, etc. If it is, you can change it to check if your terminal is interactive and only output text by using the following code in a bashrc.”
This was exactly my problem as shown here:
clark:ssh ec2-user@simplexable.com "/bin/true" > testfile; ls -l testfile
-rw-r--r-- 1 clark staff 20 Jan 29 12:24 testfile
clark:cat testfile
At first I could not see anything, so I opened it in nano and got \033]2;EC2 CLI\007 which was leftover from my window titling experiments earlier on.
This was a really strange problem, and I thought the solution was worth sharing. If you use escape characters in your bash setup, confine them to files outside the main .bashrc, and you should be ok.