Quantcast
Channel: Hacker News 50
Viewing all articles
Browse latest Browse all 9433

A multi-purpose EDITOR variable - BrettTerpstra.com

$
0
0

Comments:"A multi-purpose EDITOR variable - BrettTerpstra.com"

URL:http://brettterpstra.com/2013/03/30/a-multi-purpose-editor-variable/


A multi-purpose EDITOR variable Mar 30th, 2013[Tweet : ADN]

Here’s a quick trick I’ve been using to load different editors from the command line based on the type of file. It can be extended to whatever file types you want to handle and use whichever editor you prefer.

I use Vim to edit git messages, MultiMarkdown Composer (via the mmdc command available from the website) for text and Markdown files, and Sublime Text 2 for just about everything else.

First, I created an editor.sh file in my scripts folder:

Then I just make it executable (chmod a+x ~/scripts/editor.sh) and point my EDITOR variable to it in my .bash_profile:

export EDITOR="$HOME/scripts/editor.sh"

Now if I run a git merge and need to enter a message, it pops up Vim right in the terminal I’m working in. If I edit a Markdown file, it automatically opens it in MultiMarkdown composer. Anything else gets sent to Sublime Text 2. Like I said, it’s easy to customize with more file types and editors, but I thought I’d share the idea for anyone who’d find it helpful.

Follow the author on Twitter and App.net.

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.

Topics: bash, quicktip, scripting This post is part of "Bash Fun…" A multi-purpose EDITOR variable Mar 30th, 2013 More command line handiness Mar 14th, 2013 Quick Tip: Jumping to the Finder location in Terminal Feb 9th, 2013 Matrix(ish): a bash script with no practical application Sep 15th, 2012 Overthinking it: fast bundle ID retrieval for Mac apps Jul 31st, 2012 A warm, fuzzy, file-finding feeling Jul 7th, 2012 A simple but handy Bash function: console Dec 28th, 2011 na: per-project todos in Terminal Dec 24th, 2011 oft: Bash function for opening a specific filetype Jul 7th, 2011 A Bash function for Markdown bloggers Jun 24th, 2011 Address Book search and Skype from the command line Apr 13th, 2011 fk: redux Mar 6th, 2010 fk: a useful bash function Nov 14th, 2009 Related posts:

Viewing all articles
Browse latest Browse all 9433

Trending Articles