Leopard Terminal.app: naming tabs, selecting paths and few other tips

Terminal.app that we had in Tiger had few very big “defects” so for terminal access in Tiger I used iTerm or Konsole . Leopard introduced tabs in Terminal 2, so I decided to give it a shot. With few tricks, now it works really decently – I didn’t have a need for any other terminal for a while now. So, here are the problems and tricks:

Tabs can’t be renamed. I could not believe it at first, but there really is no [documented] way to rename tabs – they only show your last locally executed command. So if you’re using lots of tabs all connected to different servers – finding the right one may be really challenging as you will have tab menu full of “ssh”. Here’s a solution for those who need to see servers they’re connected to in tab menu:

Create a folder ~/bin/ssh, add it to your PATH, and add following lines to your ~/.profile:

tabssh () {
  if ! [ -f ~/bin/ssh/$1 ]; then
    ln /usr/bin/ssh ~/bin/ssh/$1
    ~/bin/ssh/$1 $1 $2 $3 $4
  else
    ~/bin/ssh/$1 $1 $2 $3 $4
  fi
}

alias ssh=tabssh

For every new connection, this will create a hard link to /usr/bin/ssh in your ~/bin/ssh folder and then it will call the hardlink as a command, so tabs will have the connection name. Good commands to run are: ssh username@server, or ssh server but using something like ssh -l username server you would end up having “-l” as a tab name. Do not forget to run source ~/.profile or restart Terminal.app after editing ~/.profile.

Selecting paths and other connected strings with double-click. It’s simple – you have to use Command+Shift+Click instead of Option+Click as you used to in Tiger. I would still expect to have this configurable (something like “Symbols considered part of the word” that we have in iTerm), but we don’t have much choice here.

Home, End, Pg Up, Pg Down. If you use only OS X terminal or only FreeBSD terminals, this should not bother you. But if you are connecting to Linux servers usually, in order to have your Home/End and Page Up/Down keys working correctly, just go to: Terminal -> Preferences -> Settings, pick your theme (I use slightly modified Novel) -> Keyboard. Now, change actions for these keys:

Key: end, Action: send string to shell: \033[4~
Key: home, Action: send string to shell: \033[1~
Key: page-down, Action: send string to shell: \033[6~
Key: page-up, Action: send string to shell: \033[5~
Key: shift-end, Action: scroll to end of buffer
Key: shift-home, Action: scroll to start of buffer
Key: shift-page-down, Action: scroll to next page in buffer
Key: shift-page-up, Action: scroll to previous page in buffer

One more thing – if you want to have correctly functioning home/end keys in your local OS X Terminal – create ~/.inputrc and fill it with:

"\e[1~": beginning-of-line
"\e[4~": end-of-line

and restart your Terminal to get the full functionality ;)

5 comments ↓

#1 Markus Iturriaga on 12.11.07 at 15:44

Hey – I found this post by doing a search on how to rename terminal.app’s tabs. The idea with the hard links is great. Thanks for posting this. Apple REALLY needs to fix this. I had been an iTerm user, but I’ve noticed some text and scrolling issues in 10.5. so I thought I’d give the new Terminal a try and the tabs naming would have been a deal breaker. Thanks!

#2 Eric Anderson on 03.04.08 at 09:21

Hey, just wanted to get the word out that I have a SIMBL plugin for Terminal.app that lets you name your tabs.

Its only alpha, but you should really check out Terminal.app Tab Namer

#3 dewey hylton on 01.16.09 at 15:58

nice tip. just a quick suggestion; instead of having to deal with $1 $2 $3 and such and possibly limiting yourself to a small number of arguments, you may instead use $@ to represent all arguments at the same time.

#4 Aurimas on 01.16.09 at 16:18

dewey,

indeed – I learned that in the end. Though I’m actually using Terminal.app Tab Namer quite successfully ever since Eric wrote it.

#5 Aurimas on 10.12.09 at 23:53

Mind that the Tab Namer no longer works with snow leopard nor it is needed (or the solution I mentioned). You can just edit the title (Shift-Cmd-I). Mind that you don’t have to press return to verify, just enter the name and press [escape].

Leave a Comment