Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to create a shell script to take an argument and use it to name a terminal tab. So if the script's name is tabnm, tabnm "test" should rename the current tab "test"

This is my code:

echo -ne "\e]1;$1\a"

but when i run it I get this output:

robin@icarus $ sh test
-ne \e]1;test

If I just run echo -ne "\e]1;Test\a" straight in the shell, the tab is renamed.

share|improve this question
Is /bin/sh a symlink to /bin/bash on your system? – Kirk Jun 21 '11 at 16:55
up vote 3 down vote accepted

That would be the difference between echo in /bin/sh vs. your interactive shell. I suggest using printf instead, and see The UNIX and the echo.

share|improve this answer

The problem is that your shell recognizes different escape codes than your /bin/sh.

/bin/sh probably doesn't recognize \e as the escape character. Try \033 instead.

You can also replace \a by the equivalent code\007 and see if that works.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .