
Show HN: Swiss Army Knife for Mac OS X - rgcr
https://github.com/rgcr/m-cli
======
koenigdavidmj
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.

~~~
paxswill
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.

~~~
therealmarv
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.

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

~~~
therealmarv
Good to know!

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

~~~
ralfd
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](https://news.ycombinator.com/item?id=11977162)

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

~~~
rgcr
I think @koenigdavidmj has the answer :)

------
donretag
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.

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

~~~
bigboat
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/](https://pqrs.org/osx/karabiner/)

------
legulere
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.

~~~
Scarbutt
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.

~~~
SG-
which airport

/usr/local/bin/airport

~~~
danbee
Tried that on my Mac

$ which airport

airport not found

~~~
Alphasite_
It's not linked by default.

------
javajosh
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. :)

------
stereo
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.

~~~
JadeNB
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)

------
64bitbrain
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](https://github.com/rgcr/m-cli.git)

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

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

------
JustSomeNobody
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.

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

~~~
arnarbi
Are you less nervous running a binary installer?

~~~
beachstartup
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.

~~~
seanwilson
> 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.

~~~
pjmlp
> 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.

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

------
bubbleRefuge
m dir tree returns:

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

------
miles
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.

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

~~~
miles
Here are the previous submissions:

[https://news.ycombinator.com/submitted?id=rgcr](https://news.ycombinator.com/submitted?id=rgcr)

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

------
jfb
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.

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

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

