Posts Tagged “shell”

  • OS X shell tricks: speaking in tongues

    I have an always-on Mac mini that sits in the corner of my office. It toils away running staging servers for media, web development, and home automation. It also runs a lot of scheduled scripts.…

  • Shell tricks: sort a Bash array by length

    I'm certain there's a more elegant way to do this, but I couldn't find it. I needed to sort a Bash array of strings by the length of each element without getting too verbose. Here's what I came out with:…

  • Shell trick: printf rules

    This post is about a simple trick for printing a horizontal rule in the Terminal, but I would like to start by saying that the headline is not entirely an attempt at humor. I spent a long time working with the limitations of echo`, with its `-e` annoyances and `-n` inconsistencies between shells. Then I started using `printf more, and it's made string formatting and terminal output so much simpler. Check out the man page (and some more info on format strings)if you're not already familiar with…

  • sizeup: tidy filesize information in Terminal

    alias sizes="du -sh * | sort -n" That outputs all of the file and folder sizes in the current directory, sorted by size, and lists them in human-readable format. Of course, I wanted to make it a more painful endeavor.…

  • Preview the OS X clipboard in Terminal

    I apologize for being a little slow on posting for a bit now. Here's a quick one for the Shell Tricks series, though.…

  • Safer command line paste in iTerm 2

    If you've ever copied a shell command from somewhere and accidentally included a trailing newline, you know that hitting paste in your terminal can run the command before you have a chance to edit it. There are a few ways around this, but here's a quick tip for iTerm 2 users.…

  • The "Shell Tricks" video course

    It's $11.99 for the full course, and covers tricks for working with files and directories on the command line, clever git tricks, web design tools, and more fun on the command line.…

  • Shell tricks: A time to kill

    I detailed the open command in the last Shell Tricks post, so I thought I'd go over some tricks for doing the opposite next: closing and quitting apps.…

  • Shell tricks: the OS X open command

    You may already be familiar with the open command in Darwin (OS X's flavor of Unix). It allows you to open files and URLs in their default app or one that you specify. In its simplest form:…

  • Shell Tricks: One Git Alias to Rule Them All

    Continuing the Shell Tricks series, here's a handy Git trick. I'll be moving away from the Git tips soon, so don't lose heart if you love the command line but aren't a big Git fan.…

  • Shell tricks: Changelogs with Git

    I've been collecting some shell tricks. The list got long enough to warrant a few posts, so this is part one of a few. I'm going to add them to the "Bash Fun" series rather than creating a new one, so that's the place if you want to track them.…

  • Automating dynamic date math in TextExpander

    Here's a TextExpander trick for automating dynamic portions of snippets. It's a way to allow the power of shell scripting inside of regular text snippets, avoiding extra fill-ins or running two snippets. First, a short backstory.…

  • Easily save that wicked awesome shell command

    This isn't a brand new trick. It's based on a Bash function for "alias last" that I've seen in a few places. The original version uses history to get the last command you ran and turn it into a temporary alias. I expanded it a little with some escaping for quotes and trimming whitespace, but it's the same function.…

  • Bash image tools for web designers

    Here are a couple of my Bash functions for people who work with images in CSS or HTML. Nothing elaborate, just things that supplement my typical workflow.…

  • Quick Tip: Checking for modifier keys in shell scripts

    Yesterday I found a handy little command line utility for checking whether a modifier key is held down. It's great for scripting of all kinds. The solution came from this post on the Apple Mailing List:…

  • Quick Tip: Quickly clear stuck Growl notifications

    Quick tips are random posts regarding something I discovered on my way to something bigger. They usually get longer than "quick" would imply, for which I refuse to apologize.…

  • Automated HTML5 video encoding revisited

    A little while ago I approached the subject of scripting automated encoding for HTML5 video formats. I started using the process regularly as I built the Blogsmith Bundle video site. Pretty soon I got some help from friend and TUAW editor Mike Rose, and working together we refined the script and improved the speed tremendously. It was built for use on Mac OS X, but with just a few lines modified, it should work on any *NIX system.…

  • TextMate drag command for Base64 encoding images

    Just a quick hit on this one... when hacking away at the styles of things one probably shouldn't be hacking away at, embedding images right in the CSS is a handy trick. It's done by Base64 encoding the image, removing line breaks from the resulting string, and using it to set the background property for the CSS rule.…

  • A System Service for to. url shortening

    I'm fascinated by http://to. It's a url shortener with no TLD. Some browsers, and apparently some DNS setups, don't like the urls it creates (they want a .com or .org or anything at the end), so it's not exactly in heavy usage. Still, I wish they had an API. In lieu of that, here's a quick Ruby script that will run on a stock OS X install as a System Service. It's so simple that I'm not even going to package it up... It'll be a good chance to show the steps for creating your own utilities using…

  • fk: redux

    Just a quick change to my post on the bash function fk` that I've been using. A small modification has greatly improved its usability: make the cancel option always be first in the menu. Just move "Cancel" before the `$(fp $1) bit. It's a little odd that I didn't do that to begin with...…