Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Swiss Army Knife for Mac OS X (github.com/rgcr)
388 points by rgcr on July 14, 2016 | hide | past | favorite | 62 comments



The last one of these that popped up on HN replaced a lot of the common UNIX commands, and a lot of people here rightly asked 'why would I run "mac tar:extract" when I could just run "tar xf"?'

This one seems to get the balance a lot more right, with a lot of things that the average OS X admin wouldn't know off the top of their head.

- 'm lock': That's a lot better than whichever arcane key combination does it by default (my laptop stays closed most of the time, so the power button isn't an option).

- 'm nosleep': I would have to look that one up.

- 'm finder showhiddenfiles': It beats Googling for the proper 'defaults write' invocation.


The basic command for keeping the machine awake is `caffeinate`, and has a few other nice options like changing what kind of sleep is prevented (disk, display, system) and also waiting on a PID (looks like that was added in 10.10).

Related to that is `pmset -g assertions` which will list all the various things that are keeping your machine from sleeping.


strange, I always used `pmset noidle` instead of `caffeinate`. But seems it does the same. I somehow assumed `caffeinate` is the same as this app store thing called Caffeine.


Using `pmset noidle` is now deprecated in favor of `caffeinate` according to the pmset man page.


Good to know!


I think if you go to the Keychain, you can configure it to put an icon in the top right tray that you can click on to lock your computer. I often find myself accidentally moving my mouse to the top right corner of my Windows and Linux machines to lock them now.


That is exactly what I do. I think that the combo I would normally try (Cmd+L) logs you out. I remember at one point trying to find the correct key combination, and the primary results were to put the lock icon up. That works find enough for me.


Defining a hot corner in the bottom left in trackpad prefs has been my go to for years. It works fast and is rarely activated by accident.


My first impression was _gaah!_ just RTFM! But after calming down, I realized this is not significantly different from a command line version of TinkerTool. Not necessarily something I would use, but I could see an audience for it.


There's a more popular but similar project. https://github.com/guarinogabriel/mac-cli Has anyone used both?


I find that mac-cli is too unfocused with functions like ssh, tar, magento support, mysql support which are not really needed and common between platforms.

I like the exclusive focus of this tool to only mac administration tasks which are specific to mac OS X and that I would not know off the top of my head.


It literally says on the github page of OP submission, that Mac-CLI was inspiration.

HNews discussion about it 3 weeks ago:

https://news.ycombinator.com/item?id=11977162

But I too wonder why I should use this instead of Mac-CLI?


I think @koenigdavidmj has the answer :)


I like how each function is contained in an individual plugin file. I can install (create a local script) which plugins I want without needing to install them all. Even if you do not want to install any of the code, it shows you the command line needed in OS X.

The volume plugin has a more fine-grained control for adjusting the volume. The keyboard based function keys will increase/decrease the volume by 6/7. Now I can increase by smaller increments. Excellent.


You can use Alt+Shift+VolumeUp/Down to change volume by quarters of an increment.


Karabiner allows you to change the default behavior of the volume keys to use quarter steps with the "Fine grained volume controls" option (it simply adds the alt+shift for you). Very useful with headphones that are too sensitive. https://pqrs.org/osx/karabiner/


As an aside, holding down the option key on your Mac while adjusting the volume will do it in much smaller increments.


That something like this exists shows some problems with the unix shell: No standardized commands exist for many common actions (sleep, wifi, etc). The syntax is different across commands even on a single system.

It's really nice, but I'd like to see something like that as a standard in shells.


I don't know, CLI commands in os x are much worse than in linux, want to display wifi info?

$/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I

lots of useful commands like that are not in your path by default, that said, at least os x lets you modify almost any part of the system with shell commands.


which airport

/usr/local/bin/airport


Tried that on my Mac

$ which airport

airport not found


It's not linked by default.


I like it! I wish it had some features for making a screenshot, taking a photo, and recording video or sound for n seconds. A packet capture for n seconds might be nice, too (although that would certainly be more involved). Might as well add keyboard/mouse logging for n seconds. :)


It’s not really clean, how it asks for /usr/local/m-cli to be added to $PATH but then litters that directory with other scripts.


It does mention that you can put it elsewhere:

    INSTALL_DIR=$HOME/.m-cli sh <(curl -fsSL https://raw.githubusercontent.com/rgcr/m-cli/master/install.sh)


Does it need to be ran as root?

Downloading m-cli from git to /usr/local fatal: could not create work tree dir '/usr/local/m-cli': Permission denied Failed to clone => https://github.com/rgcr/m-cli.git

Off course it won't be able to access the /usr/local/


Most people using this probably have homebrew installed, which makes /usr/local writable for the main user.


The README addresses this (with the somewhat elliptical "You need privileges"), and points out a work-around:

> You can also install it in a different path

    INSTALL_DIR=$HOME/.m-cli sh <(curl -fsSL https://raw.githubusercontent.com/rgcr/m-cli/master/install.sh)
> Note: You need privileges


As opposed to alias in bashrc for the commands you use most often?

This and the other one that was on HN a short while back, I just don't get the point. Learn the command line, already. Yes, some are hard to remember, but that's why history exists. And if you rarely use one, keep it in a simple, greppable text file.


Not sure I like the install method. I'm nervous of anything that asks me to pipe curl to shell.


Are you less nervous running a binary installer?


i'm not. all of it makes me nervous. even package managers with supposedly cryptographically secure verification make me nervous.

but, you gotta do what you gotta do to actually do stuff.

i sure as hell ain't going back to the days of compiling everything from source.


> i'm not. all of it makes me nervous. even package managers with supposedly cryptographically secure verification make me nervous.

Android and Chrome for example are really ahead of this in my opinion. Apps are sandboxed and you know uninstall clears up traces of them. Obviously it's not perfect but it's miles ahead of installation scripts and binary installers which can do anything they want with your system and might be hard to get rid of.


That is what Mac App Store is for. However, all of these sandboxed environments come with their own sets of problems and make making especially these kind of tools quite difficult if not impossible.


> Apps are sandboxed and you know uninstall clears up traces of them.

Not in all versions of Android, if they write stuff on the SD card.


They might be able to write some files that sit around but not code that runs on startup and spies on you for example.


So how would you go about packaging this m-cli tool into a sandboxed app?


Okay - I'm curious. What is wrong with:

  ./configure
  make
  make install
I do that a lot, and 90+% of the time, it's that simple.


uh yeah, it's the other 10% that's the problem.

not to mention the tracking of installed files and library dependencies that slowly develop into an accumulated spiderweb shitstorm of runtime conflicts.

have you tried maintaining multiple versions of a shared object libraries by hand? do you remember the 'make install' wrappers that never worked right? pepperidge farm remembers.


the best way to get rid off the discomfort is to first check the shell script: curl -fsSL https://raw.githubusercontent.com/rgcr/m-cli/master/install.... | pbcopy

Then you can paste it in a text editor and if it is not too long you can verify the script.

And as this one is on github you can take a look directly.


Just pipe the script to a file so you can read it without having to copy-paste. :)

curl -fsSL https://raw.githubusercontent.com/rgcr/m-cli/master/install..... > install.sh


Or use curl's built-in options:

  curl -O ...
or

  curl -o install.sh ...


Or pbpaste | sh


Also not to like about the install method: The install.sh stores INSTALL_DIR in a variable but does not allow that variable to be overridden by the environment. So you're forced to install into /usr/local despite then being asked to add /usr/local/m-cli to your path. It would be better to allow /usr/local to be overridden so that installation doesn't require sudo. It's just as easy to add ~/.m-cli to your path.


> The install.sh stores INSTALL_DIR in a variable but does not allow that variable to be overridden by the environment.

Really? The documentation explicitly says that it does:

    INSTALL_DIR=$HOME/.m-cli sh <(curl -fsSL https://raw.githubusercontent.com/rgcr/m-cli/master/install.sh)


You can always pull and build - but of course that's risky too, roughly in proportion to the size of the working copy.


The thing is, in this case you can easily inspect the shell script that they're running with that curl command.


m dir tree returns:

/usr/local/m-cli/plugins/dir: line 3: /lib/functions.sh: No such file or directory


Thanks for crafting and sharing this.

I must admit to flagging this particular submission, as it is the fifth time it has been posted in as many days, with no other contributions (whether of comments or stories) to speak of. Forgive me if this seems harsh, but just to keep submitting the same item over and over without any other activity (including responding to comments made in the prior submissions) does not seem in alignment with HN.


I read HN every day and this is the first time I've seen this submission...


Here are the previous submissions:

https://news.ycombinator.com/submitted?id=rgcr


Super curious as to why you're getting downvotes... :/


Same here.


I've been pretty active on HN the last few days, and this is the first I've seen of it. Is redundancy sufficient for flagging? I always thought flagging was only for abusive or off-topic content, and redundant submissions were a moderator thing.


> Is redundancy sufficient for flagging? I always thought flagging was only for abusive or off-topic content, and redundant submissions were a moderator thing.

It looks like the same person was submitting the same thing, daily, to try and make it stick (without any other apparent engagement with the site in terms of submissions or comments). So I think @miles is considering that abusive behavior?

I believe when the mods ask people to resubmit something, they only ask for 1 resubmission (at least that's how it went when I was asked to resubmit something: a second shot, and it didn't get picked up, so that's that).


I don't know. I mean on one hand I get it but on the other I go plenty of times when people submit awesome stuff it's just bad timing. So I don't care.


Wow! It really pays to go fishing on HN. That's what I see.


I"m curious about why it's written in sh, given that it's OS X only and OS X includes by default many languages significantly less crappy than Borne Shell.


Presumably because most of the commands are just shortcuts for other shell commands. Probably the right tool for the job in this case.


Yeah, fair enough. Not everybody hates the shell as much as I do.


Someone would ask why not write it in sh, if it was written in Python, Ruby, Perl, or Tcl. I prefer stuff like this in sh.


I like to challenge myself to write little things like this as shell-scripts, too. But I am surprised they didn't at least choose use Bash instead of Bourne shell.




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

Search: