OS X Command Line Utilities
mitchchn.me
mitchchn.me
So you can do
say -v Samantha Help, I'm trapped in this castle!
or say -v Princess Help, I'm trapped in this castle!
But wait, it gets even better: The Mac comes with a number of voices for other languages, such as French, Hebrew, Chinese, and Arabic. And it turns out that the voices will work in English as well, using that country's accent. I just tried it with a few different languages, and was amazed by how well this worked, within reason: say -v Sin-ji "Hello, I am Chinese. What do you want to eat?"
say -v Thomas "Hello, I am French. What do you want to eat?"
say -v Carmit "Hello, I am Israeli. What do you want to eat?"
And yes, I should get back to work...That is, typing
say -v Milena "Здравствуйте, меня зовут Milena.
Actually says, "Zdravstvuyte...", while typing say -v Bruce "Здравствуйте, меня зовут Milena.
Results in "Cyrillic capital letter 'Z'. Cyrillic small leter 'd'.", etc.I don't think that Apple has created the World's Best Accent Impersonator here, but it's good for a few laughs.
1, the pedantic: technically none of them know how to speak English, or any other language - there's just a rule set for making phonemes based on characters out of waveforms.
2. Ignoring the pedantic response, I still don't think that's true - if that were the case, then Milena wouldn't be able to speak an English sentence!
say -v Milena "Hello, I am Milena"
If they only speak their own language, then Milena should be saying "Прописная буква Х, строчная буква и", etc. say -v Anna 'über allen Wipfeln ist Ruh'
say -v Anna '[[lang fr_FR]] que restet-il de nos amours'
say -v Anna '[[lang it_IT]] chi nasce asino non muore cavallo'
say -v Anna '[[lang es_SP]] nosotros tenemos mas influencia con sus hijos que su tiene'
say -v Anna '[[lang en_UK]] are we having fun yet?' say -v Xander "Ik houdt van appeltaart met slagroom in Scheveningen op zondag."I like a good prank. Leave your screen unlocked? You deserve the abuse you get. :) But accessing my laptop in this way is just creepy.
Disclaimer: I have managed tech teams before. It is better to forgive then have knee jerk managerial reactions.
Sorry, I get office pranks but there's no reason to be doing anything on an end-user's workstation without their permission or consent that isn't maintenance or security related. I guess I lack a sense of humor, but I've also seen too many instances where a prank on someone's machine resulted in severely unintended consequences and breaches of trust that rippled through the team.
Just not worth it, IMO.
That said, I don't really find the whole "recursihoffing unlocked laptops" thing all that funny either, but it doesn't bother me as much.
Honest question, why the need to apologize for being a former Windows admin?
Please don't. This comment would be fine with just the first sentence.
It's a British expression made popular by a movie. He is not calling out the guy by his first name.
People do this kind of thing in online comments all the time, to make the other person look bad and rub in a little extra insult. Any one comment isn't much, of course, but they compound into a degraded discourse, and all of it goes against the civility we try to practice here.
Which is rather lovely, because someone in Apple HQ has decided that the (London) band Saint Etienne must be French, and so Thomas faithfully reports that the current track is "Leek a Motorweh".
If it were open source you could probably get better results by hacking it up to parse in the "right" language and then only realizing the phonology in the "wrong" language, instead of both parsing and speaking in the "wrong" language.
say -v cellos dum dum dum dum dum dum dum he he he ho ho ho fa lah lah lah lah lah lah fa lah full hoo hoo hoo
Edit: 'In the Hall of the Mountain King' if anyone is curious.There is also 'Pomp and Circumstance':
say -v Good dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum
and Chopin's 'Funeral March': say -v Bad dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum say --voice='?' | perl -lane 'my $v = $F[0]; system("say -v $v \"Hi $ENV{'USER'}\"")' for voice in `say --voice="?" | awk '{print $1}'`; do say -v $voice "Hello $USER, I'm $voice"; donehttp://greggman.github.io/text2speech/
There's also some singing like voices.
say -vjun "[[inpt TUNE]] h {D 100; P 233.08:0 233.08:100} OW {D 200; P 233.08:0 233.08:100} l {D 100; P 220:0 220:100} IY {D 200; P 220:0 220:100} f {D 100; P 233.08:0 233.08:100} AA {D 500; P 233.08:0 233.08:100} k {D 100; P 174.61:0 174.61:100} IY {D 500; P 174.61:0 174.61:100} n {D 50; P 174.61:0 174.61:100} g {D 50; P 174.61:0 174.61:100} S {D 100; P 155.56:0 155.56:100} IH {D 400; P 155.56:0 155.56:100} t {D 100; P 155.56:0 155.56:100} IH {D 200; P 233.08:0 233.08:100} t {D 100; P 233.08:0 233.08:100} s {D 100; P 233.08:0 233.08:100} AA {D 200; P 220:0 220:100} d {D 100; P 233.08:0 233.08:100} AY {D 500; P 233.08:0 233.08:100} n {D 100; P 174.61:0 174.61:100} OW {D 400; P 174.61:0 174.61:100} s {D 200; P 155.56:0 155.56:100} OW {D 500; P 155.56:0 155.56:100} r {D 200; P 155.56:0 155.56:100}" function clip { [ -t 0 ] && pbpaste || pbcopy }
This is easier to type and allows for the following: % echo hello | clip
% clip
hellofunction clip() { [ -t 0 ] && pbpaste || pbcopy }
clip() { [ -t 0 ] && pbpaste || pbcopy;}
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.
`[` 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`.
-t FD file descriptor FD is opened on a terminal
FD 0 is stdin I'd guess. Pretty clever! function clip
if not tty >/dev/null
pbcopy
else
pbpaste
end
endThere are a number of utilities that handle copy/paste, but `xclip` is probably the most widely used.
Screenshots can also be done a number of ways, but `scrot` is my favorite. The two most useful flags to pass with it are `-s` and `-d`.
As for `launchctl`, `systemctl` is what you want to use to do the same things.
Note that these equivalents all address the same functionality, but the syntax may be different.
I'm sure some desktop distros do ship xclip by default though. Knowing the typical variety of Linux distros I expect there's probably even an Xclipbuntu, dedicated solely to showing off the latest xclip release (the users of which have a decade long feud with Xseldora).
textutil is a general purpose front end to the core text engine and is one of the cleanest docx-to-html converters I've run across, with a bunch of file formats supported and charset encoding translations, metadata manipulation commands, and assorted juicy goodness for people who have to mess with word-processed text.
Ironically the only common-on-Apple document format it can't do anything with is that of Apple's Pages word processor ...
(I was surprised by the lack of support for Pages, too.)
I use this all the time, it's the GUI version presumably.
I don't think so. For whatever reason Caffeine doesn't take a power assertion, as show by `pmset -g assertions`, whereas caffeinate does.
This is what prompted me to write Theine (https://github.com/lvillani/theine) to use the proper API for this task, since Caffeine would behave erratically with the lock screen active.
I still set my display to sleep, however. Am I missing something?
I created a gist that says a random starwars quote in each of the systems supported voices.
sleep 240 && say "tea done"
so I don't over steep my tea⌘. (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.
I find this useful before printing text that I want to search using ⌘+F.
pbpaste | grep ago | wc -l
In this case there are easier (and more accurate) ways, but in other situations you can use it to find the length of a list on the web where it would otherwise be harder.
is 0.3% faster and 1.7% more correct :-)
alias pbclean='pbpaste | pbcopy'Also, (though not, I think, relevant to OS X), binding a key to move content between PRIMARY and CLIPBOARD on X Windows has been very nice.
Also, a tip: an easier way to change the icon of any app/folder/anything:
1. Right click it -> Get Info.
2. Drag an app that has the icon you want onto the icon in top-left of the Info window. (e.g. drag the Terminal.app into the Info window and drop it on the icon: that script will now have the same icon as the Terminal.)
If you aren't on OSX you can try the following for a simple 'say' alternative. It has some great robotic/singing voices, too.
Great list!
:)
I have a little local deploy script that runs this if it fails a smoke test:
say -v Bad "Deployment failed, server gave a bad response"
open -a Safari 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]One question: What's wrong with "locate"? It is really fast because the file system contents are indexed. As long as you understand that it's not going to pick up the latest new files without running "updatedb" (sudo/usr/libexec/locate.updatedb" in os x) first, it's much better than find if you're doing a quick search.
However, I didn't know spotlight has a CLI. Cool.
That said, mdfind is terrific -- it's index is, as you suggested, always upto date, and it doesn't just index file names, but also content.
Fortunately, pbpaste takes a -pboard flag for selecting a different buffer. So cmd-e some text to put it on the find pasteboard, then 'pbpaste | fgrep --color -i "`pbpaste -pboard find`"'
I usually have this aliased to 'pbg'
opendiff file1 file2
will invoke the merge tool.Having said that, I wouldn't reformat your boot drive to be case-sensitive because this isn't a common configuration and I'd expect 3rd-party apps to have problems.
What you can do is use Disk Utility to create a case-sensitive file system on a disk image, which gives you case-sensitive behavior when you really want it (and limited to activities on that disk).
Rather, that it gives you instructions for getting it to work. How's a Linux power user getting by without following such instructions to turn on one of their favorite utilities?
It will open up the screen sharing app and connect for you :)
I don't know if it would be worth the effort to enforce a more complete set of title guidelines, but having better titles would be nice.
say 'ay ay. ay ay. smoke weed. every day.' yes "lock your computer, numbskull" | xargs say
Just repeats the phrase in a monotone computer voice over their headphones. I only do this to engineers, tried it on a PM once, never again.If so, I would hope the responsibility for setting opsec policy isn't resting in one sysadmin.
Or more prosaically, do you have any semi-confidential e-mail on your machine, that a coworker might fancy reading?
With that said, I always lock my computer out of habit.
It's all a series of defenses, the last one you should ever rely on is piecing together what happened by video camera... what happens when they install a root user, or ssh authorized key on your system and then do whatever they want at some other time?
This is a fire-able offense where I work.
Barring myself from working at an company with more than ~150 people (Dunbar's number) because I'm too pompous to lock my laptop doesn't seem like a metric one would be wise to follow.
This is like bricking up all your windows against thieves when you live in sleepy, low-crime suburbia.
Site security needs to have a balance between paranoia and practicality. For public-facing code, history has shown us that it's impossible to be too paranoid. If you work in national security, or your industry is known to be a target for industrial espionage, then certainly strong precautions are in order.
But if you're just building social media sites or whatever, and you're firing people because they failed to stand ever vigilant against the possibility that Bob the visiting vendor rep might stalk the corridors waiting for you to take a bathroom break so he can rifle through your code for exploits to sell to teh haxxorz, you are being absurd.
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.
Both examples of community driven man pages with examples
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 comment then; probably the moderator didn't see it.
Users not in North American time zones do see more baity titles, though. We cover as broad a span of hours as we can, but it isn't 24.
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.
I must disagree with your assessment that Homebrew is focused primarily on webdev. There is rarely any package (webdev-related or not) that I haven't been able to install with it. I'd venture to say that not once over the past 12 months have I had a single problem installing anything.
I'm also curious what pkg_src offers over Homebrew (and vice versa).
A coworker was on it doing the rare at the time Safari testing - usually only on client request. I sshed into it and ran 'say "Help, I'm stuck in the computer"'. My coworker was very very confused and I was cackling to myself. He still talks about it to this day.
More power.
However, I'm not a fan of the soft recommendation for Homebrew. I understand Homebrew places everything in `/usr/local` but software installs on Mac should generally conform to dragging and dropping bundles inside `/Applications`.
In my experience, requirements to install packages using Homebrew could be circumvented by searching for .dmg or .pkg equivalents. The benefit is that software so installed is much easier for intermediate users to track and maintain.
The vast majority of Homebrew packages are not available as .dmg or .pkg ; installing that way also is a huge PITA when dealing with a myriad of small developer tools that require dependencies, whereas brew manages all of that for you, including upgrades.
The pkg manager does track all the files it installs, so it's a trivial script to go "uninstall" them. Anyway, good reason to stick with Homebrew.
I guess you mean BSD and GNU extensions to POSIX.
POSIX IEEE Std 1003.1, 2013 Edition defines sh as the shell.
There is no git in POSIX IEEE Std 1003.1, 2013 Edition.
The people that are likely to use advanced features would also hopefully be aware of Bash's fragility/compatibility issues between minor versions, and thus wouldn't rely on it for anything like shell scripts.
So we're left with people who want to use advanced features and are doing so purely on machines they control.. So what stops them from either compiling their own bash, or using one of the third party package managers to install it?
But I have less of an interest in that than in discouraging jerkish pedantry.
I still hate homebrew, of course, because it doesn't handle dependencies well at all, but I'm not 100% ready to switch to nix. Maybe that can be my project for the week, actually.
I've thought about starting a project (possibly with some support from my company, which focuses on Linux packaging) to provide a) a tool to download and install .pkg files, and b) a toolchain for more easily building .pkg files for the things that aren't available.