-
(I’m always looking out for good resources to refer people to when they find they
needwant to learn usingvim
, feel free to add your own favourites as comments.) Dabblet is an interactive playground for quickly testing snippets of CSS and HTML code.
Shorts
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.
Meta
Subscribe to feeds
Pages
Latest Posts
- Overland from Finland to London: Epilogue
- Overland from Finland to London: Days 3 and 4
- Overland from Finland to London: Day 2
- Overland from Finland to London: Day 1
- Overland from London to Finland: Day 5
- Overland from London to Finland: Day 4
- Overland from London to Finland: Day 3
- Overland from London to Finland: Day 2
- Overland from London to Finland: The Beginning
- The day the .dev gTLD died
Latest comments
- nikc on Managing scrollTop in your Backbone single-page app: Richard, you’re right, you can store...
- Richard Hunter on Managing scrollTop in your Backbone single-page app: Unfortunately, pop state wont help you...
- nikc on Managing scrollTop in your Backbone single-page app: Richard, Thank you. You’re right, scroll position...
- Richard Hunter on Managing scrollTop in your Backbone single-page app: This is a clever solution- however...
- llaurén on Better tools for procrastination: Yer welcome!
- nikc on Better tools for procrastination: Well, after evaluating both, I find...
- nikc on Better tools for procrastination: Having taken a closer look at...
- nikc on Better tools for procrastination: One Tab looks nice, too. But...
- llaurén on Better tools for procrastination: Nice catch! I use One Tab to...
- nikc on How to turn your smartphone (nearly) useless in one simple step: Wow, I’d love for the EU...