Hacker News new | past | comments | ask | show | jobs | submit login
Tell HN: Best OS X Utility for programmers who use the command line
108 points by weaksauce on Mar 1, 2010 | hide | past | web | favorite | 58 comments
I don't know how I have lived without it for so long: http://www.decimus.net/dterm.php

Fast access to the shell that defaults to the working directory of the currently used file from say xcode and you can paste in the current working file(s) as arguments to whatever you want to run. There is an option to run the command in the overlay app or in terminal.

I recently found out about it because I was looking for xcode git integration and this makes accessing the shell git stuff quick. It's free too.




I'm going to be slightly flippant and say the the bundled tools and little one liners built with them. A few examples from my .profile follow:

Eject a volume:

  alias eject='hdiutil eject'
Copy the working dir to the clipboard:

  alias cpwd='pwd|xargs echo -n|pbcopy'
Show current airport status:

  apinfo='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I'

Use spotlight to search for a file:

  spotlightfile() {
      mdfind "kMDItemDisplayName == '$@'wc";
  }
Use spotlight to search file contents:

  spotlightcontent() {
      mdfind -interpret "$@";
  }
Display a man page in Preview:

  pdfman () {
     man -t $1 | open -a /Applications/Preview.app -f
  }
I've a few others but they're less generic than the above. Also although the above were sitting in my .profile I probably yanked them from random parts of the inter-webs; in other words, I take no credit for them.

EDIT: One more generic one I use fairly regularly:

  google() {
      python -c "import sys, webbrowser, urllib;   webbrowser.open('http://www.google.com/search?' + urllib.urlencode({'q': ' '.join(sys.argv[1:]) }))" $@
  }


pbcopy is a great little utility

another neat trick is dragging and dropping a file to the terminal and having the filename pasted to the terminal


That's not really flippant as those are useful by themselves. All the utility I am advocating does it make the oneliners a bit easier to get to and have context(i.e. changing the working directory to what you are actually working on) readily available. I would say that a programmer without a decent list of aliases saved up is not the best programmer.


Not really a command line utility, but rather a programming utility used through the command line:

http://github.com/mxcl/homebrew

I've replaced my MacPorts install with Homebrew and have been pretty happy with it. It's relatively new so not everything is in there yet.


There is something written on the linked page that has always bothered me: "Using sudo all the time is annoying, but far worse — it conditions you to type in your root password without thinking about it." That quote implies a misunderstanding of sudo, and has made me less confident about installing Homebrew. Unix permissions and installation procedures should be well understood by a developer of package management software.

It's probably good software, for all that. He probably understands Unix better than I do, but it still bothers me.


The author (of Homebrew) is well intentioned but I've gotten a few hints that he doesn't really come from a *nix background (the /usr/local thing, the aggressive Gentoo-esque "optimization", etc).


[edit: http://news.ycombinator.com/item?id=872072 for some clarification on a few Homebrew vs MacPorts misconceptions.]

I used Homebrew for a bit, even submitted some recipes, but I've since switched back to MacPorts, in short because:

* MacPorts was once as simple as Homebrew, it's not now for good reasons. Eg, the reason MacPorts uses it's own python is beucase Apple is slow to update their own python, and when they do it happens outside of your own setup so you won't necessarily know you need to rebuild X, Y and Z.

* Homebrew did some silly things like aggressive stripping (which seemed to just be commands pulled from the Gentoo wiki without any real justification) which caused problems a few times when I tried to install things outside of Homebrew (eg, easy_install of MySQLdb didn't work out-of-the-box with the Homebrew mysql libs).


If they didn't have those insane installation instructions that said:

  sudo chown -R `whoami` /usr/local
I'd check this out. But I just can't bring myself to do it when they still have that as their default install instructions.


A lot of developers have no idea how UNIX permissions and mode bits work. I've witnessed this countless times, when a developer can't figure out why his code won't run, and just tells me to "chmod -R 777 /programdir/*"

I've had to sit a few developers down and teach them how to use commands like strace and truss to show them exactly which file they are trying to f_open and why it fails (usually trying to open a file in read/write mode that is not owned by them and 644 permissions).

Shouldn't this stuff be taught in basic CS101 courses?


Why would stuff about a particular OS's filesytem be taught in a beginning computer science class?


It's akin to "here's where the computer lab is" rather than in the "this is what a stack is"


Because CS101 should teach you about basic programming techniques, like how to open a file for reading or writing. In order to understand how to open a file, you need to have a basic understanding of how permissions work. In order to understand how permissions work, you need to understand how mode bits work.

This is really basic stuff, but I'm not surprised that most developers think it is beneath them. "That's sysadmin stuff; I don't need to learn that." These are usually the same developers that think chmod 777 is a fix.


I don't get why this is bad. The stuff in /usr/local is supposed to belong all to me unless I have to share my computer with other users and then I guess I'd use a group. I also like the point the brew README makes about how using sudo a lot conditions you to use it without thinking.


Uh, so don't do that. On my macbook, I stuck homebrew in ~/homebrew and everything is great.


I think the point is more that the general instructions tell you to do it without any justification (which a lot of experienced *nix users seem to think it needs, myself included), it makes you wonder what kind of code is sitting in there without real justification.


I'm just waiting to get a new MBP to setup everything via homebrew. Building myself vs choosing MacPorts has never been an easy choice. Inevitably over the years the choice one way or another has caused me a lot of pain. Homebrew seems to be the best of both worlds, and allows you to confine everything to your home directory which is a nice bonus in my case.

My only fear with homebrew is the lack of robust dependency resolution, but in practice I tend to be installing a limited set of devtools, so it doesn't rise to the same dependency hell that gave rise to the modern crop of unix package managers.


I feel like this is a common argument against homebrew, but have yet to encounter a situation where this was actually an issue.


I've found that the dependancy resolution is pretty decent. Heck, it can install ImageMagick just fine.


Why isn't there a binary package system, like apt, for OSX?



There is also [the possibly out of date?] Rudix (http://rudix.org/), which is basically standard OSX packages (.pkg) of typical unix tools. Their summary:

> Rudix features a world class collection of pre-compiled and ready to use Unix compatible software which are not available from a fresh installation of Mac OS X but are popular among other Unix environments. Here you can find utilities, programming languages, libraries and tools delivered as standard Mac OS X packages.

I haven't used this, though it may appeal to some.


MacPorts isn't binary. I didn't know Fink was, but that's cool, and I'm switching right away.


"Dependency resolution and updates are basic or not working yet."


pretty cool, a tool I have been using for quite some time that I find incredible useful is http://visor.binaryage.com/ . Not quite the same thing, but still awesome.


hey I'm also working on TotalFinder. in 0.9 I plan to add Terminal+Finder cooperation mode: when you press hotkey you may slide both Visor Terminal down and Visor Finder Up. You may tab between terminal and finder as it would be one app and their views will stay synced. You get the idea ...


Huge visor fan, couldn't live without it. I have a fullscreen terminal a control-tilde away at all times.


Thanks for that link! I hadn't realized the source had forked away from the Blacktree original and now I find I am running a rather old version of visor.


I like that tool too. I could see them being complementary.


That's really awesome, thanks for the link.

One of my best finds so far would be butler: http://www.petermaurer.de/butler/

It's basically quicksilver but with less obscure configuration dialogs and without the crashes (quicksilver would crash a lot on me).


Is Butler being maintained? Is there a bug tracker? It doesn't look like there's been a release since 2008, but I can't tell because I can't find a dated changelog for the project.


I use Butler to remap Home and End keys to have PC-like behavior. Can't live without it!


Does your mapping work well across most/all applications? I've tried mapping via keybindings file and messed up my account (this is snowlepord)


I had to exclude iTerm (you can exclude apps in Butler), everything else (Firefox, Eclipse, Parallels, TextWrangler, Thunderbird) works fine.

Obviously, Shift-Home and Shift-End should be remapped as well so selection would work.


command + (left|right) arrow would do the same on a mac.


This is exactly what Home and End are remapped to.



That solves one half of the terminal/GUI interaction disconnect, but I'd really like something to do the opposite too... keep a Finder window synced to my current working directory, preferably that floats above everything else* .

Why? There's a few things that you can't do with a Terminal, such as seeing and easily editing all the info from Get Info at once, or most things involving the use of a contextual menu - especially seeing what programs are in the Open With list (there may be a launch services related command, but you still can't pick one without typing another command (open -a Application file). Multi-file drag and drop is easier than multi-file cp, especially if you don't need a particularly named group of files that you can use a wildcard with - it's easier to shift-click or command-click than to type each one out individually, even if you can use tab completion.

* aliasing cd to end with an open . won't do, because that brings Finder to the front (which you can work around in bash), along with all the other open Finder windows (which you can't), and worse, it opens a new window every time instead of reusing the same one (another can't work around). The last two are because you can't, as far as I know, get a handle on a particular Finder window. I wonder if an AppleScript can get the job done. Hmm...


I use quicksilver [http://github.com/andreberg/blacktree-alchemy/downloads], more than anything else. (still like it better than launchbar, even with it being not updated in a few years).


http://www.macupdate.com/info.php/id/14831/quicksilver

The "stealth" release of QuickSilver beta 57, from November 2009. It's not perfect, but it crashes far less than other builds in 10.6.2 (for me at least).

I have no idea why it's not on the blacktree site.


I'd given up on QS and gone to google search box (or whatever it was called) - I happily am back on QS with this stealth release - much faster and don't remember the last time it crashed


I am a quicksilver user too. Though the index updating seemed to beachball my computer on the regular. After changing the prefs to only update once a day they have gone away.


I used to be a quicksilver user, I now use this http://www.google.com/quicksearchbox/ basically the same idea.


Actually, the main developer of QSB is also the creator of Quicksilver, whom made it an open source project once Google hired him.

That's why Quicksilver has no official site, by the way.


Yeah I tried it, but it's not as featureful as quicksilver, still. Maybe once it matures a bit.


I use LaunchBar more than I use the Dock: http://www.obdev.at/products/launchbar/index.html


DTerm is awesome, and since it went free there is no reason not to try it out even if you're a Quicksilver/LaunchBar user – you probably will find it serves you better in many scenarios.

And here's a nice tidbit – TextMate comes with `mate`, a proxy utility you can call with DTerm like so: `mate ./new_file_here`. But XCode doesn't, and won't create a file for you if one doesn't exist. So for XCode I have an function/proxy in my `~/.profile`:

   function edit { touch "$1"; open -a Xcode "$1"; }
Bash can be very usefully augmented, for instance you can have a git repo status in your prompt, like so:

   function wgit_dirty {
      git diff --quiet HEAD &>/dev/null
      [[ $? == 1 ]] && echo "◆"
   }
   function wgit_branch {
      REF=$(git symbolic-ref HEAD 2> /dev/null) || return
      echo :${REF#refs/heads/}$(wgit_dirty)
   }
   export PS1='\u \W$(wgit_branch)\$ '


For anyone interested in having Git, SVN and VirtualEnv status in your prompt: http://pastebin.com/f79a9af51


you may like __git_ps1 :)


I have to say this tool made me consider getting a mac for a second. Still wont but it has done more good for the argument than any other I've sen before.


Interesting. What sold me on OS X almost 10 years ago now was the simple combination of a first-class UNIX OS w/ support for the major consumer and professional creative apps.


I must say that the biggest selling point on the mac to me was that it had a POSIX shell readily available and I didn't need "putty" to do anything interesting. I have been and still am responsible for many windows boxes but I cannot stand it for my main machine.

I really love the fact that all the power of UNIX is hidden behind a nice GUI(though there are some things that I would like them to fix regarding finder)


Slightly different and finder only: http://code.google.com/p/cdto/

'Open a terminal window here'


OnMyCommand is a UNIX shell script and AppleScript executor. You can build your own Contextual Menu Item or GUI application. Sweet. http://free.abracode.com/cmworkshop/on_my_command.html


Semi command line, icalBuddy + GeekTool for displaying calendar items and to do's on the desktop is awesome.

http://www.makeuseof.com/tag/how-to-show-ical-tasks-events-o...


Not really a commandline tool, but when I am writing code or on terminal I heavily use MegaZoomer - http://osx.iusethis.com/app/megazoomer

Gives total real estate for the terminal (works in other apps too)

DTerm is a great tool.


Rupa's 'z' makes working in a command line so much nicer: http://github.com/rupa/z


dterm, eh? That looks awesome... gotta give it a try now.


Awesome. I can't believe I lived without this.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: