Live data from Hacker News

OS X Command Line Utilities

mitchchn.me

81–90 of 243 posts

Re: OS X Command Line Utilities

#81

no love for macport?

My understanding is that macports is a lot more finicky and hacky, especially when it comes to built-in dependencies. homebrew is specifically designed to avoid such problems.

Can you be more specific? macports works wonderfully for me.

Re: OS X Command Line Utilities

#82
post #29

These are awesome. I didn't know about many of them. One tiny thing though, at the bottom it says > Recall that OS X apps are not true executables, but actually special directories (bundles) with the extension .app. open is the only way to launch these programs from the command line. Actually, you can launch them in other ways. Example /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir=/Us…

Although this technically works, in some cases it may lead to strange bits of misbehavior. (Depending on where you do it, the app may end up in the wrong audit session or mach namespace, and it may also be missing some environment variables that it was expecting). The open command does allow you to specify command-line arguments to pass to the application (via --args), which is generally a safer way to do things.

Some apps will break entirely.

Re: OS X Command Line Utilities

#83

The one utility I can't live without is caffeinate, which prevents a Mac from sleeping. It's super useful for keeping long running tasks running.

Why not just disable sleep? I only ever sleep my Macs manually (if ever).

Re: OS X Command Line Utilities

#84
After years of living on the command line, OS X specifically, and learning its quirks and tricks, I am actually ready to move on.

Right now I am more interested in creating simple visual interfaces on top of UNIX-y tools, for my own personal use cases. The main benefit of this is the ability to better experiment with and optimize my workflows for different properties as needed through different combinations of single responsibility interfaces and single responsibility programs.

I am sensing that there is great promise in seeing much higher APMs (actions per minute) for many tasks, even compared to the all-powerful command line. Also, there are lots of interesting possibilities for better visual representations of data to improve comprehension and usability.

Re: OS X Command Line Utilities

#85

This was supposed to be few lines of remarks. It expanded quickly in relation with my enthusiasm for this topic. I've been investing some time in the command line on my Mac. I am moving from a dilettante going to the shell on a per-need basis to a more seasoned terminal native. It pays off handesomely! It's hard to convey how nice it to have to have a keyboard-based unified environment instead of a series of disjoine…

> - Install iterm2. The main reason to use it >instead of the default Terminal application is that It just works©. What's wrong with the default Terminal application? I use it daily and have been for close to a decade. I never found myself wishing it did anything than what it already does. > -Use tmux. Meh. For most people screen works just as well. Perhaps more importantly, you can rely on screen being available pre…

I encountered some problems with command-line emacs control sequences not being captured correctly, though the last time I tried was a while ago.

Re: OS X Command Line Utilities

#86
post #29

These are awesome. I didn't know about many of them. One tiny thing though, at the bottom it says > Recall that OS X apps are not true executables, but actually special directories (bundles) with the extension .app. open is the only way to launch these programs from the command line. Actually, you can launch them in other ways. Example /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir=/Us…

Although this technically works, in some cases it may lead to strange bits of misbehavior. (Depending on where you do it, the app may end up in the wrong audit session or mach namespace, and it may also be missing some environment variables that it was expecting). The open command does allow you to specify command-line arguments to pass to the application (via --args), which is generally a safer way to do things.

But the open command doesn't allow you to pass the environment, and Apple seems hellbent on breaking every workaround they've implemented over the years (e.g. ~/.MacOSX/environment.plist).

So, doing Foo.app/Contents/MacOS/Foo is often the only way to launch a GUI app while inheriting the full environment that you have on the command line.

I often have to do this to launch various developer tools, and have them be able to inherent important environment variables, e.g. database credentials or secrets,

Re: OS X Command Line Utilities

#87

This was supposed to be few lines of remarks. It expanded quickly in relation with my enthusiasm for this topic. I've been investing some time in the command line on my Mac. I am moving from a dilettante going to the shell on a per-need basis to a more seasoned terminal native. It pays off handesomely! It's hard to convey how nice it to have to have a keyboard-based unified environment instead of a series of disjoine…

Another trick I learned from an older HN comment is to create a .marks directory in your home directory and then add the following to your .zshrc

  export MARKPATH=$HOME/.marks

  function jump {
      cd -P $MARKPATH/$1 2>/dev/null || echo "No such mark: $1"
  }

  function mark {
      mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1
  }

  function unmark {
      rm -if "$MARKPATH/$1"
  }

  function marks {
      ls -l $MARKPATH | sed 's/  / /g' | cut -d' ' -f9- | sed 's/ -/ -/g' && echo
  }

  function _marks {
      reply=($(ls $MARKPATH))
  }

  compctl -K _marks jump
  compctl -K _marks unmark
Now to remember a directory you type

  % mark 
and to jump to that directory you type

  % jump 
To list all your shortcuts

  % marks
Depending on the version of ls you might have to change the -f9 parameter to -f8 for marks functions

Re: OS X Command Line Utilities

#89
post #73

This was supposed to be few lines of remarks. It expanded quickly in relation with my enthusiasm for this topic. I've been investing some time in the command line on my Mac. I am moving from a dilettante going to the shell on a per-need basis to a more seasoned terminal native. It pays off handesomely! It's hard to convey how nice it to have to have a keyboard-based unified environment instead of a series of disjoine…

Don't need symlinks. Just set the CDPATH environment variable! Also set up case insensitive completion, saves the extra shift press for all those Mac paths.

You sir just changed my life. I never knew about CDPATH..

Re: OS X Command Line Utilities

#90

This was supposed to be few lines of remarks. It expanded quickly in relation with my enthusiasm for this topic. I've been investing some time in the command line on my Mac. I am moving from a dilettante going to the shell on a per-need basis to a more seasoned terminal native. It pays off handesomely! It's hard to convey how nice it to have to have a keyboard-based unified environment instead of a series of disjoine…

> Go fullscreen. Not so much for the real estate but for the mental switch. Fullscreen mode is a way to immerse yourself into your productive development world. No browser, no mail, no application notification. Only code. This is an excellent point and one that's not nearly as appreciated as it should be. Fullscreen mode was written off in Lion as an example of Apple dumbing down the platform and making it more like…

I use sizeup[1] to maximize the terminal (or any other app) with a keystroke, instead of native full screen. It works across all applications that allow window resizing, and has handy shortcuts for "half" full screen, which is great to position, say, a browser and editor next to each other across the whole screen.

Which reminds me, I really will go and pay my 13 bucks for it now, it's more than worth it. But the free version is fully functional with just an occasional nag screen.

[1] https://www.irradiatedsoftware.com/sizeup/

Post reply on HN