Using the OSX clipboard from the command line

The OSX pbcopy terminal command, which adds “stuff” to the clipboard to be pasted later, is really useful. For example, to download some webpage and put the HTML source in the clipboard:

curl -s | pbcopy

Here’s a WordPress example; want to get some fresh API salts and keys for a wp-config.php? Try this:

curl -s | pbcopy

Want to be notified when the download and copy are complete? Add the say command, like this:

curl -s | pbcopy; say 'Ready to paste';

I use DTerm, which is an excellent little “popup terminal” which inherits the current context, and these commands are super handy here.

Speeding myself up on the commandline

I tend to find myself in the on my Mac more often than not, SSHing into servers, checking whois, host, and any number of other things. My most frequent incantation is searching the command history so I don’t have to re-type a previous command, something like this:

grep curl ~/.bash_history

I’ll then copy and paste the command and hit return. It’s pretty quick, and I’ve got the muscle memory right down now… but there’s got to be more elegant commands, right? Or course there are. Continue reading Speeding myself up on the commandline

Exporting from MySQL to CSV

Everytime I need to do this I go into at least five minutes of Googling for a decent solution. The problem is that a lot of people don’t have access to the commandline, so the solutions all reference PHPMyAdmin which is, you know, OK, but I don’t use it or want to install it just to export some quick reports. Other solutions are similarly indirect.

Continue reading Exporting from MySQL to CSV