Live data from Hacker News

OS X Command Line Utilities

mitchchn.me

141–150 of 210 posts

Re: OS X Command Line Utilities

#141
post #93

What's with all the buzzfeed-level headlines making HN frontpage the past few days? Not to say this isn't a useful list (for OSX users that is), but I can't possibly be the only one weirded out by this.

> buzzfeed-level headlines making HN frontpage the past few days This is most likely random fluctuation a.k.a. sample bias, but if you know of any that didn't get corrected, please email them to us at hn@ycombinator.com so we can figure out why. People post such titles all the time but we change them systematically. For example, we changed this one shortly after your comment. Normally we'd have replied to your commen…

Thanks - no, they all got corrected, you guys do great work :)

I think it's sample bias as well, just struck me because I rarely ever saw it before. Probably because they all get corrected very quickly.

Re: OS X Command Line Utilities

#143
post #75

Great list, not a big fan of homebrew personally, or its creator who seems to be full of himself. I'd recommend pkg_src from joyent[0]. homebrew seems to have a lot of the hip webdev packages, but pkg_src and joyent's repository is the real deal when it comes to hardcore UNIX package management. Some friends have a nice bootstrap for pkg_src on OS X called saveosx[1], too. [0]: https://pkgsrc.joyent.com/install-on-os…

FWIW, I have no issues with homebrew, but I have used macports for many years and never had any issue. Especially now that it supports binary packages, I find it perfect for my usage.

Re: OS X Command Line Utilities

#144
post #36

pbpaste and pbcopy never really occur in ambiguous situations, so I wrote the following shell script: function clip { [ -t 0 ] && pbpaste || pbcopy } This is easier to type and allows for the following: % echo hello | clip % clip hello

> function clip { [ -t 0 ] && pbpaste || pbcopy }

That's great! Would you please explain why that works? Are there any cases you know of where that doesn't work as expected?

Edit: btw you need a semicolon after pbcopy to make that function valid on one line.

Re: OS X Command Line Utilities

#145
post #144
post #36

pbpaste and pbcopy never really occur in ambiguous situations, so I wrote the following shell script: function clip { [ -t 0 ] && pbpaste || pbcopy } This is easier to type and allows for the following: % echo hello | clip % clip hello

> function clip { [ -t 0 ] && pbpaste || pbcopy } That's great! Would you please explain why that works? Are there any cases you know of where that doesn't work as expected? Edit: btw you need a semicolon after pbcopy to make that function valid on one line.

I'm not the OP, but I'll give it a go.

`[` is a Bash built-in command also known as `test`. The `-t` parameter tells it to test if a file descriptor is open for `0`, which is also known as `STDIN`.

So if you're piping something into `STDIN` it will do `pbcopy`. If not -- it will do `pbpaste`.

Re: OS X Command Line Utilities

#146
post #66
post #55

This is a great intro. Here's my favorite OS X Terminal trick: ⌘. (command period) is a hotkey not defined in the menu for sending BREAK. This is automatically equivalent to ctrl+c in shells, ctrl+g in emacs and ESC in Vim. Similarly, ⌘K is short for clearing the screen. These are much more ergonomic than the standards on Mac laptops and wireless keyboards.

How is cmd + K different from cmd + R and/or $ clear?

$ clear is six characters, and you have to be on a new prompt first. ⌘R is a reset command, meaning it's for restoring a garbled terminal. ⌘K will keep your input on the line but clear other output, same as ⌃L but more pinky-friendly.

Re: OS X Command Line Utilities

#147

Earlier quoted context omitted.

I do the same so I aliased it to just "chrome", "firefox", etc.

I aliased Sublime to `sub`. Without args it opens the current folder as a project; with args it opens the file[s].

The officially-supported name is `subl`, by the way:

https://www.sublimetext.com/docs/2/osx_command_line.html

Re: OS X Command Line Utilities

#148
post #35

Does anybody know of a good alternative to "at" on OS X? I know it's there but not enabled by default, I went through the paces required to activate it long ago but it something in Yosemite seems to have broken atrun and I can't find anything about it anywhere online.

Works for me. I would do an unload then load to see if it got messed up in the upgrade Yosemite.

  sudo launchctl unload -F /System/Library/LaunchDaemons/com.apple.atrun.plist

  sudo launchctl load -F /System/Library/LaunchDaemons/com.apple.atrun.plist
[edit: maybe check /var/at/at.allow]

Re: OS X Command Line Utilities

#149

Earlier quoted context omitted.

> Is China or someone else trying to steal your trade secrets? Or more prosaically, do you have any semi-confidential e-mail on your machine, that a coworker might fancy reading?

If you can't trust your coworkers not to go snooping on your machine while you're not there, then you should find a better job. Threat models balloon in complexity when you can't use tools like zones of trust and choke points.

I'd argue that the coworkers that are the most dangerous are the ones you do trust. :)

Re: OS X Command Line Utilities

#150
post #144
post #36

pbpaste and pbcopy never really occur in ambiguous situations, so I wrote the following shell script: function clip { [ -t 0 ] && pbpaste || pbcopy } This is easier to type and allows for the following: % echo hello | clip % clip hello

> function clip { [ -t 0 ] && pbpaste || pbcopy } That's great! Would you please explain why that works? Are there any cases you know of where that doesn't work as expected? Edit: btw you need a semicolon after pbcopy to make that function valid on one line.

from `man test`:

   -t FD  file descriptor FD is opened on a terminal
FD 0 is stdin I'd guess. Pretty clever!
Post reply on HN