By Peter Bell

Advice for a Pain Free Command Line Experience on a Mac?

I find myself using terminal a fair bit on the mac. From "sudo apachectl restart" to restart apache to running MySQL commands (I have GUI too, but some stuff is easier in terminal), cmhod'ing files and directories and a bunch of other little bits and pieces.

My question is where is the smart replacement for terminal? I'm looking for text shortcut tools, code complete/context sensitive help, all the stuff that you'd expect in a Java IDE so I can type less, remember less and do more on the command line as an occasional user.

Any thoughts on a starting point?

Comments
iTerm (http://iterm.sourceforge.net) is the replacement I've been using for years. It offers some app-level scriptability , a degree of integration in finder (Open iTerm from a folder selection) and a tabbed Panel UI.
# Posted By Scott Geiger | 3/11/07 11:40 PM
yeah, there's iterm, and there's...well that's about it. check here: http://www.macupdate.com/search.php?arch=ppc&k...
# Posted By flashape | 3/12/07 12:37 AM
not sure if iTerminal will do any tricks for you. I switched to mac about 2 months ago and I've stayed with Terminal.app. Perhaps you need some general bash tricks, not just "Mac Command Line" tricks. I assume you're using the default shell - bash. In terminal enter this command `echo $SHELL`. You should get back `/bin/bash`

Here are few that I commonly use - sorry if you already knew some of them. Also, as I'm not an expert myself, this is *not* a complete list... just the ones I've found over the time
- `cd ~` - ~ is an alias for current user's home dir. You can use it wherever you might be at the moment. If you have multiple users you can `cd ~username`.
- in you home dir type `cd Do` and then press TAB key... it should turn into `cd Documents`, if Documents is the only dir/file starting with Do. If there are multiple matches press the TAB key twice (quickly, just like "double-click" - or "double-tab" in this case :) ) to get a list of matches.
- tab completion also works for commands, unfortunatelly it won't work for commands typed after sudo, but, for example, you can type `sud[TAB]` :) (of course it's useless for this example.
- Aliases: type in terminal `alias qq='sudo apachectl restart'` and then type qq on command line (you can use tab completion for aliases too). You can have as many aliases as you wish. That alias exists only until you close that terminal window. To have aliases available when you open a terminal window you must write them in ~/.profile - one per line, of course. Remember, that file is only read when starting a new shell (opening a new terminal window).
- CTRL+A will get you to the beginning of a line, CTRL+E to the end. There are other CTRL+smth commands, but I only use these two
- goto Terminal->Window settings, select Keyboard from the dropdown and check "use option key as a meta key" (and optionally "Use settings as default". After that you can delete a word by pressing backspace while keeping down alt. Most likely there are other ALT+smth too, but I only use this one...

That's pretty much it, and it's been enough for me for all the years I've been using command line... well, again, I'm not an expert, I never tried to improve it more than this... I'll post again if I remember anything else.
# Posted By eels | 3/12/07 3:06 AM
Hi,
Just saw this post on O'Reilly in my feeds this morning:

http://www.oreillynet.com/mac/blog/2007/03/bashful...
# Posted By Rick Curran | 3/12/07 4:31 AM
I got tired of typing out the string to start up mysql, so I just added this to .profile:

alias startmysql="mysql -u mysqluser -p"

You can shorten the alias name even further if speedy typing is what you're concerned about.
# Posted By Lola Lee Beno | 3/12/07 7:07 AM
Shell aliases (not to be confused with symlinks, etc.) are the best. I use tcsh and my .tcshrc file is full of them. Tab completion is useful as hell, too. So is the "complete" keyword (not sure the bash equivalent) to provide auto-completion for other common commands.

I use iTerm as well - mostly because of the tabbed sessions - but I don't know of any non-shell-based shortcuts to reduce typing.
# Posted By Rob Wilkerson | 3/12/07 8:36 AM
Thanks everyone for all the advice. Looks like the answer is iTerm, some smart key strokes plus a bunch of aliases. Thanks for the pointers!
# Posted By Peter Bell | 3/13/07 5:50 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.005.