/dev/nikc/blog

Kuolleiden purjehduskenkien seura

Shorts

Jan 4th 2012

Sublime Text 2 and the command line

15:15

Since about half a year ago I migrated from Textmate to Sublime Text 2, simply because it's awesome. Of course, as with all software, it has its shortcomings, but nothing I can't live with.

But one thing which really bothered me and occasionally made me return to Textmate was Sublime's lack of a command line companion tool. I spend a lot (most) of my time on the command line and the lack of a command line helper was a real drag. But as I like both the command line and Sublime Text 2, and not willing to give up either, I simply wouldn't believe the situation couldn't be remedied and embarked on a mission to find a solution.

If all you need is a shortcut for opening files and folders, a simple alias is enough:

alias slt='open -a "Sublime Text 2"'

But this doesn't allow for creating new files or the use of pipes. Both of which are frequent use cases for me. To accomplish this, a bit more code in the form of a bash function comes to the resque:

function slt() {
    if [ -z "$1" -a -t 0 ]; then
        echo "slt file [...]"
        return 0
    fi

    if [ -z "$1" ]; then
        open -a "Sublime Text 2" -f
    else
        for arg in $*; do
            [ ! -f "$arg" -a ! -d "$arg" ] && touch $arg
        done
        open -a "Sublime Text 2" $*
    fi

    return 0
}

And voila! Copy and paste into your .bashrc and your new best friend can now be used to edit new files and read stdin1 from the command line.

Disclaimer: This script hasn't been tested on anything other than OS X 10.6.8. Most likely if you're on Linux you won't need any of this extra malarkey, and if you're on Windows, well, you have my sympathies.

1 There is one shortcoming; only piped content works, not redirected input. If you can fix this, you're welcome to leave a comment, but I'm not losing any sleep because of this.

Shorts

Mar 2nd 2011

I pity the fool (who tries to lure me into creating a user account)

22:57

A while back, Jeff Atwood wrote about the proverbial Internet Driver's license. I liked the article and agreed wholeheartedly. Lately even more so.

Nowadays, hardly a month passes when a new service or interesting site doesn't pop up, that one simply "must" check out to keep on top of the game - especially being part of the industry, but mostly due to curiosity or peer pressure. Often, this site or service will offer a higher level of service if you register as a member. In my case, I tend to create user accounts just to take the alias I use off the market. Or, rather, I used to do so.

Lately I've noticed that I mostly shun away from sites that require me to create a new user account. It'll have to be something pretty damn special for me to care. Despite the fact that I've given up on managing my credentials mentally and handed over the task to 1Password. I just don't want Yet Another User Account, when there are existing established solutions available which will let me identify myself using one that I already have.

So stop asking me to register and let me use the identity provider of my own choice.

Jan 28th 2011

Impressive service

08:36

Approximately 24 and a half hours ago I placed an order on Amazon.com. During the night a shipment confirmation had arrived in my inbox. Five minutes ago, UPS Finland phoned me up to inform me my shipment is arriving next week and that they'll be taking care of all the customs mumbo jumbo for me.

Wow.

These guys have their act together. Big time.

Shorts

Meta

Pages

Search blog

Latest comments