News for hackers. Stuff that matters.
Re:Terminal Tips and Tricks For Mac OS X by rmaccloy on Tuesday July 06, 2010 @03:14PM (#1492032)
One of the commenters mentions the `say` command, which is super-useful, but they use it like so: `scp file some-host:~; say 'copy done'`, which will notify you even if the command fails. You should use && so the notification only happens on success, or conditionally say something else.

I use this constantly in deploy, etc, scripts so I can run my compile + rsync + deploy command in a terminal, background it, and go work on something else until the process finishes. I'd say it's generally useful for anything that takes longer than 10 seconds but less than an hour (after an hour you tend to forget what's going on; might as well just email yourself.)

Festival (http://www.cstr.ed.ac.uk/projects/festival/) is something similar for *NIX users.

Re:Terminal Tips and Tricks For Mac OS X by mhansen on Tuesday July 06, 2010 @05:34PM (#1492461)
If you can't get festival to work (it wouldn't for me), 'espeak' worked great on my Ubuntu box.
Re:Terminal Tips and Tricks For Mac OS X by PidGin128 on Tuesday July 06, 2010 @11:56PM (#1493261)
I remember issues arising due to weird default permissions when I tried to use beep, or bell (don't remember if it was the command or character [ctrl+g]). I think festival or the command used to play the startup sound in ubuntu where the easiest alternatives, as getting beep/bell to work is weird.

Pre-Edit: /usr/bin/canberra-gtk-play , according to my Ubuntu's startup applications preferences.

Re:Terminal Tips and Tricks For Mac OS X by tel on Tuesday July 06, 2010 @10:30PM (#1493122)
My favorite trick is using DTerm[1] to hybridize graphical and textual interactions. More of a meta-Terminal trick, with a keyboard command it brings up a floating input for terminal entry with some intelligence to the context you initialize it from.

Common uses include starting up Terminal with a command instead of just carte blanche, using a globbed rm to clean a folder I'm viewing in Finder, using ls/grep to find files in a current Finder window, &c. &c.

[1]http://www.decimus.net/dterm.php

Re:Terminal Tips and Tricks For Mac OS X by jackowayed on Tuesday July 06, 2010 @10:47AM (#1491111)
Full emacs keybindings:

A lot of key emacs bindings--C-a, C-e, C-n, C-p, C-f, C-b--work in any text field (even, say, the Hacker News comment box). But M-f and M-b (which are really useful since they get you forward/backwards a word instead of just a letter or a whole line) don't work. When I try to type option and then a letter, I get weird symbols:

Here's option-b: ∫

Here's option-f: ƒ

To get make M-f and M-b work, go to Preferences->Settings->Keyboard and check the "Use option as meta key" box.

See http://skitch.com/jackowayed/dme91/terminal-fix-keybindings if you can't find it.

Re:Terminal Tips and Tricks For Mac OS X by JadeNB on Tuesday July 06, 2010 @12:14PM (#1491410)
It has nothing to do with Terminal.app, but I consider the ease of making those symbols one of the nice things about text entry on a Mac—I miss it sorely on Ubuntu (where I'm sure the equivalent exists, but (1) I don't know it and (2) it likely requires memorising code points). You can see which keystrokes will produce which funny symbols by turning on Keyboard Viewer (under Input Menu, which itself can be turned on from the International tab under System Preferences.app; or there's probably some way to invoke it directly).
Re:Terminal Tips and Tricks For Mac OS X by mhd on Tuesday July 06, 2010 @12:41PM (#1491498)
http://www.hermit.org/Linux/ComposeKeys.html

The list is a bit old, but maybe it helps with some odd keys. Now that unicode is pretty common, I try to stick to the ellipsis for example… I have to say that the compose position for dieresis is a bit more logical (compose-" as opposed to macs alt-u), which is quite useful if I don't want to switch keyboard layouts when typing a bit of German (or write a lot about Motörhead and Queensrÿche).

X11 also has "level 3" support, which is straight-forward additional characters when pressing a certain key, as opposed to combining multiple key presses. Mac's alt key basically does both to a certain degree. The fact that it's turned on by default and the keyboard viewer makes it a lot more common usage in my experience.

Re:Terminal Tips and Tricks For Mac OS X by JadeNB on Wednesday July 07, 2010 @12:04AM (#1493275)
Heh, all the time I had a Sparc in my office I looked at the 'Compose' key and wondered "Now, what does that do?" Thanks! I'll give this a try.
Re:Terminal Tips and Tricks For Mac OS X by ostso on Tuesday July 06, 2010 @01:01PM (#1491562)
Some methods:

1. Change your layout from "USA" to "USA International (AltGr dead keys)". Then use right-alt+key to make various special characters (you can look at what each character does at "Show Current Layout").

2. Enable the "compose key" -- I use the Menu key for this -- which is described at http://sivers.org/compose-key (it's simple to enable: Keyboard Preferences→Layouts→Options→Compose Key Position). Both of these are customizable, so you can add your own combinations if you want.

There are some other ways:

3. Ctrl-Shift-U in a GTK+ text input to enter a code point, as you said.

4. Alternative input methods that let you type special characters in in various other ways, such as LaTeX names, if you prefer that.

Re:Terminal Tips and Tricks For Mac OS X by JadeNB on Wednesday July 07, 2010 @12:03AM (#1493273)
> 4. Alternative input methods that let you type special characters in in various other ways, such as LaTeX names, if you prefer that.

Yes, please! This would be extraordinary! How do I do it?

Re:Terminal Tips and Tricks For Mac OS X by nfg on Tuesday July 06, 2010 @11:18AM (#1491209)
And of course for standard moving around:

←/→ move left or right one character.

⌥ + ←/→ move left or right one word.

⌘ + ←/→ move to start or end of line

Re:Terminal Tips and Tricks For Mac OS X by meese_ on Tuesday July 06, 2010 @03:24PM (#1492066)
What's even better is that these can be customized: http://news.ycombinator.com/item?id=448218
Re:Terminal Tips and Tricks For Mac OS X by rsl7 on Tuesday July 06, 2010 @03:57PM (#1492169)
and while holding down shift, the selection is extended in those ways as well.
Re:Terminal Tips and Tricks For Mac OS X by dilap on Tuesday July 06, 2010 @12:45PM (#1491513)
That gets you half-way there, but you're still stuck using the option key as meta, rather than the much more natural command key.

To swap the command and option keys, but just in the terminal, you can use: http://github.com/aim-stuff/cmd-key-happy

Re:Terminal Tips and Tricks For Mac OS X by randallsquared on Tuesday July 06, 2010 @10:58AM (#1491142)
I use Visor, which is a quake-style dropdown terminal plugin for Terminal. It takes up a Terminal window, but doesn't interfere with other such windows.

There's a plugin for Terminal that implements copy-on-select, which I like, but Visor has it bundled, so I'm not sure what it's called, offhand.

Re:Terminal Tips and Tricks For Mac OS X by frou_dh on Tuesday July 06, 2010 @10:25AM (#1491037)
I love "mdfind" for near-instant file searching.

"mdfind -name AppName" is a good start for a poor man's uninstaller on OS X.

Re:Terminal Tips and Tricks For Mac OS X by chousuke on Wednesday July 07, 2010 @06:34AM (#1493850)
For uninstalling things, pkgutil is a useful tool to know about. You can list all installed packages with pkgutil --pkgs and uninstall them by doing pkgutil --unlink pkgid

I wondered for a long time how to uninstall packages from OS X until I discovered pkgutil.

Re:Terminal Tips and Tricks For Mac OS X by jherdman on Tuesday July 06, 2010 @09:23AM (#1490868)
Well, since I can't comment on that convoluted site, a quick gotcha with 'pbpaste' and 'pbcopy': they don't work with screen.

EDIT: This issue no longer exists. Kindly ignore my comment.

Re:Terminal Tips and Tricks For Mac OS X by jcromartie on Tuesday July 06, 2010 @09:26AM (#1490877)
I always use screen and I use pbcopy/pbpaste all the time. What about them doesn't work?
Re:Terminal Tips and Tricks For Mac OS X by jherdman on Tuesday July 06, 2010 @09:51AM (#1490938)
You've made me second guess myself. I was getting bit by this bug http://trac.macports.org/ticket/18235. It does not persist any more. Apologies.
Re:Terminal Tips and Tricks For Mac OS X by shabble on Tuesday July 06, 2010 @09:42AM (#1490917)
my latest nifty screen trick (borrowed from a similar variant for xclip) goes:

    bindkey -m > eval "stuff ' '" writebuf "exec sh -c 'pbcopy < /tmp/screen-exchange'"
then when you've made a selection in screen Copy Mode, just terminate it with '>' to stick it onto the system paste buffer.
Re:Terminal Tips and Tricks For Mac OS X by laktek on Tuesday July 06, 2010 @07:11PM (#1492734)
Anyone know how to open a new tab in OS X Terminal to have the same path as the previous tab?

This is sort of a default behavior in Linux OSs and it's really annoying when you have to `cd` to the working path every time you open a new tab.

Re:Terminal Tips and Tricks For Mac OS X by amichail on Tuesday July 06, 2010 @10:58AM (#1491143)
fish should come as the default shell in OS X:

http://fishshell.org/screenshots.html

It's more user friendly and interactive.

Re:Terminal Tips and Tricks For Mac OS X by Dobbs on Tuesday July 06, 2010 @11:33AM (#1491257)
Possibly but at the same time most people who will be using the terminal at all on Mac are the same people who have been using the terminal on linux. For people that have been using the terminal on linux Bash is more user friendly (it is what they already know).
Re:Terminal Tips and Tricks For Mac OS X by div on Tuesday July 06, 2010 @07:05PM (#1492722)
By that logic, windows is more user friendly then OSX because it is what people already know.

Most of the stuff you would use in bash just works in fish as well, except that fish gives you nice help information when tabcompleting, a better command history that you can use filters on, colour feedback (red = invalid command, green is a-okay) and lots more.

Sure, some people will always stick to what they know, but that does not say as much about user friendliness as it does about resistance to change.

Re:Terminal Tips and Tricks For Mac OS X by div on Tuesday July 06, 2010 @07:12PM (#1492736)
An interesting github project I recently discovered on github has some nice fish extensions, it's called fish-nuggets and you can find it here: http://github.com/zmalltalker/fish-nuggets/

Here's a pic of it showing branch@revision status for svn repositories: http://tweetphoto.com/29802557

It does the same for git repositories as well and some other nice stuff.

Re:Terminal Tips and Tricks For Mac OS X by kree10 on Tuesday July 06, 2010 @09:46PM (#1493035)
See also zsh, another great shell that gets little attention.

Recent versions of zsh (though not the version that ships with OS X) have a feature called vcs_info that will pull information from git, svn, cvs, hg, darcs, bzr (& more) for use in your prompt.

http://www.zsh.org/mla/users/2008/msg00842.html

Re:Terminal Tips and Tricks For Mac OS X by JadeNB on Tuesday July 06, 2010 @12:11PM (#1491400)
http://superuser.com/questions/52483/terminal-tips-and-trick... doesn't work for me; it seems I can hold ESC for arbitrarily long without evoking Terminal's interest. I'm using the Vi keymappings (set -o vi), so I guess that's no surprise; but is there a Vi equivalent?
Re:Terminal Tips and Tricks For Mac OS X by nuxi on Tuesday July 06, 2010 @01:25PM (#1491635)
If you're using bash as your shell, <TAB><TAB> should do the trick.
Re:Terminal Tips and Tricks For Mac OS X by JadeNB on Monday July 12, 2010 @05:50PM (#1509564)
Ah, silly me. Somehow I read “only built-ins” instead of “including built-ins”, and so thought that it was something more than (or at least different from) ordinary tab-completion.
Re:Terminal Tips and Tricks For Mac OS X by deweller on Tuesday July 06, 2010 @11:49AM (#1491322)
Re:Terminal Tips and Tricks For Mac OS X by juliend2 on Tuesday July 06, 2010 @09:13AM (#1490848)
I just wrote this in the Terminal when my girlfriend was there :

say "I love you"

She was impressed :)