Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use customized terminal windows Apps
I often have several terminal sessions going - a "man" page window for reading about some command that I'm trying to use in another window, a "top" window showing current processes, and perhaps an "ssh" window for connecting to another host. By default, each window has the same properties - title, background, font size and color, etc. This can make it somewhat tricky to remember which window is which.

However, Terminal has a "save" command which will let you save the changes in any given window to a file. This lets you set up customized looks for different tasks. Simply open a window, set all the properties you like, then hit Save and give it a name and location. Now, when you double-click that file in the finder, that window will open with your customzized settings. I've set custom titles, fonts, and colors for my main 'terminal' tasks (top, ssh, man, and general default) and saved them each for quick and easy access.

Since my 'top' window is always running top, wouldn't it be nice if you could just double-click the terminal file and have top come up already running? Thanks to a tip on the X4U mailing list, you can! Read the rest of the article for the details.

The hack is actually quite simple, and will work with any application you'd like to launch on window opening. This example will show you how to set the 'top' window to run automatically, but its easy to change to anything else you may want (emacs, vi, whatever).In the terminal, go to where you saved your customized terminal file. Open it with your favorite editor, and search for "Shell" (with the capital). You'll see two lines that look like this:
<key>Shell</key>
<string>/bin/tcsh</string>
All you need to do is replace /bin/tcsh with the full path (and options) for the command you want run. So in my 'top' window, I have /usr/bin/top -u on the second line. You could easily set the command to launch vi or emacs or run an alias you have stored to connect to a remote host.

Save your changes, close your terminal window, double-click the file in the Finder, and you should see the window open with your preset scheme and with top running! Thanks to Graeme H. for sending this tip to the X4U list.
    •    
  • Currently 2.38 / 5
  You rated: 3 / 5 (8 votes cast)
 
[8,790 views]  

Use customized terminal windows | 14 comments | Create New Account
Click here to return to the 'Use customized terminal windows' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Great tip
Authored by: vgz on Apr 25, '01 12:16:57PM

However why not use one of the graphical man page viewers like manopen or gman? Search versiontracker and you can find about 5 or 6 to choose from.



[ Reply to This | # ]
Great tip
Authored by: robg on Apr 25, '01 12:30:31PM

I've tried them, but since I usually want a man page when I'm in the terminal anyway, it's easier to just use a window -- no application switch, just a window switch, if you want to scroll the man page and flip back to the other terminal. But I've printed some pages using the GUI tools.

Which (yet again!) brings me back to why I find X so useful -- you can do things the UINX way, or the GUI way, so you truly get the best of both worlds!

-rob.



[ Reply to This | # ]
Other Options
Authored by: eMan-o on Apr 25, '01 06:22:43PM

You can also set options such as TerminalOpaqueness in these files. Look for these tags:
<key>TerminalOpaqueness</key>
<real>9.000000e-01</real>

The tags should be in alphabetical order, but if you've never set this option the tags might not be there. If that's the case, just paste this tag in between these:
<key>StrictEmulation</key>
<string>NO</string>
Paste it here...
<key>TextColors</key>

The only caveat is this: Opacity is stored as a real number (Scientific notation...) and not a percentage. So, 75% would be 7.500000e-01 and 100% would be 1.000000e+00.

Of course, you could do the best thing and head over to Apple's feedback page and tell them you want some "quick, dynamic way of changing the opacity of my terminal windows!"



[ Reply to This | # ]
problems using lots of terminals
Authored by: vipw on Apr 26, '01 05:13:14AM

i'm having a bit of trouble with terminals as well.
after i have more than about 6 open i lose the ability to effectively access the information within them. i'm after a way to have 20-30 terminals sanely organized. i'm using space.dock but all the terminals draw only on one desktop. using X11 on unix has gotten me pretty used to having practically unlimited and easily accessable/sortable terminals, and i'm having a pretty rough time of trying to manage on 6.

PS. please don't criticize the way i use my computer, not being able to access the terminals easily is my problem.



[ Reply to This | # ]
change the icon too ?
Authored by: robh on Apr 26, '01 08:27:40AM

I like this tip, thanks, but I can't seem to get the new terminal based application to accept a new icon by pasting it into the inspector.

Anyone had better luck ?



[ Reply to This | # ]
change the icon too ?
Authored by: Anonymous on Apr 26, '01 12:58:07PM
Nope. Haven't been able to figure this out either. Being able to set custom icons for all these saved terminal windows would be great.

Maybe logging in as root and trying it?

[ Reply to This | # ]
change the icon too ?
Authored by: MrMadnutz on Apr 27, '01 12:59:45AM

So here's what I did...
I don't know if you have to use an alias or not, but this got me a custom dock icon:

1. Make an Alias of your "app.term"
2. Rename it to what you want it to say when you mouse over it in the Dock
3. Copy and paste your desired icon to the alias
4. Drag the alias to the dock (in the file/folders section near the trash)

Note: The icon will still not show up in the finder, but WILL show up in the Dock. Dunno how it works, but it does.



[ Reply to This | # ]
change the icon too ?...problem
Authored by: MrMadnutz on Apr 28, '01 10:54:23PM

Hmmm...
First time I've rebooted in days (love OSX)...
Those icons don't seem to stay on the dock "app.term" icons after a reboot. Must have something to do with the dock. Like the way the "pin" and "orientation" attributes don't remain. I wonder if saved terminals have the same type of properties...

Ah well, if anyone can figure out a way to make any of these things more permanent, I'll bet we'd all be happy.

over and out.



[ Reply to This | # ]
Command alias?!?
Authored by: gwyd on Apr 27, '01 03:32:17PM

Hi-

You mentioned that "You could easily set the command to launch vi or emacs or run an alias you have stored to connect to a remote host." I would love to be able to open a window which logs me via a terminal session into a machine on campus I'm having to log into all the time... via ssh or telnet. What is an "alias" in this context, and how do I run it?

thanks
Gordon



[ Reply to This | # ]
re: Command alias?!?
Authored by: cichlisuite on Apr 29, '01 11:40:11PM

Hi Gordon,

to answer your question...

Open the Terminal.app (make sure you have a window open). Go to the SHELL menu and choose SAVE AS... Name this document what you like.

Open this document in a text editor (not vi, pico, etc, use a mac editor, like Pepper or BBEdit) and look for this line of text:

<key>ExecutionString</key>
<string>ssh login@servername.com
</string>

Note: put a return character after your SSH command. Upon the file being double-clicked, the Terminal will open with a new window and initiate that command. Then all you must do is enter your password.



[ Reply to This | # ]
set up an alias
Authored by: jmil on May 01, '01 10:16:27PM

go here: http://www.macosxhints.com/article.php?story=20010427210214541
and click on my last two comments "set up an alias" and "more tips" for complete instructions on setting up an alias. Hope that helps.

jmil



[ Reply to This | # ]
Terminal Startup Items
Authored by: thinkyhead on Apr 29, '01 04:04:56PM
Yeah, there's a trick or two for getting things to start up when your session begins. One is to place a script named .tcshrc in your home folder. This startup script will work if you're using tcsh as your shell (the default). Other shell startup scripts are named similarly, as in .bashrc, .cshrc, and .sshrc.

Now if you want to get things running differently for each settings (shortcut?) file then I believe there's a hack possible but someone else will have to confirm it cuz I'm away from my X machine right now. The idea is to edit the terminal shortcut file and change the line that names the shell (that's a terminal setting, right?) Add a flag to load a different startup script. A cursory glance over the man pages for tcsh indicates there's no such flag but other shells might allow for redirection using this method. The only thing in tcsh is the -f option that tells it to skip .tcsh.

It might let you use < (input redirection) to get the input from a file which should effectively behave like a shell script. The problem with this approach is that the shell will probably quit after reading the file, which ruins the reason for using it in the first place! Gee, would spawning another shell at this point just lead to infinite regress?

[ Reply to This | # ]
It's even easier that that!
Authored by: rselph on Apr 30, '01 10:46:59AM

You don't need to go editing the save file to change what the shell is. Just create a new terminal window with cmd-shift-N. This will pop up a window where you can type the name of the program you want to run-- "/usr/bin/top", "/usr/bin/ssh", "/usr/bin/telnet", or whatever.

Then just use the Inspector to change colors, scrollback or whatever, and save. Now you have a double-clickable icon to run the shell program of you choice.



[ Reply to This | # ]
Saved Terminal Sessions
Authored by: kholburn on Jan 17, '02 11:59:40PM
I have real problems with saved terminal sessions. They pick up a whole lot of default settings so if I save a session it always has defaults like "never close the window".
The advantage of the following method is that the terminal sessions created don't have a fixed location and will open in the next spot, slightly right and below the previous window.
When I get a session the way I like it, the right title and colors and command, I save it in the default location which is :
/Users/me/Library/Application Support/Terminal/
as say:
/Users/me/Library/Application Support/Terminal/bad.term
Then I open the PropertyListEditor/Developer/Applications/PropertyListEditorOpen the saved .term files by option-command dropping them on the PropertyListEditor icon in the dock. There are probably other ways to do this.
Then click the triangles till you get a list:
/Root/WindowSettings/0/
I always have to change ShellExitAction to 0 (Zero)
Then I delete these 3 keys
WinLocULY
WinLocX
WinLocY
Then save as ~/Library/Application Support/Terminal/good.term
Try it out.

[ Reply to This | # ]