open file with file with default app, linux.

ln -s /usr/bin/xdg-open /usr/local/bin/open
source ~/.zshrc
open index.html

will open index.html in your default browser

source: http://stackoverflow.com/questions/264395/linux-equivalent-of-the-mac-os-x-open-command

terminal in my emacs

I’ve recently switched from using terminator as my go-to terminal app, to running a terminal inside an Emacs buffer. 

This is what I did to get and in the exceed my previous workflow.

First off Emacs has a couple choices when it comes to terminal emulators. Others have gone into greater detail about the pros and cons of the various options. In the end I chose ansi-term because it can run pretty much all my regular terminal apps without a problem.

In terminator I often ran multiple tabs, with multiple windows open in each tab. Now one can do a similar thing in Emacs by running ansi-term in multiple buffers. In practice I found that quite bulky on Emacs, so I decided to give screen a try.

I found Matt Cutts blog post extremely useful for getting started with screen, it gives a good overview of how screen works and how one would use it professionally.

Screen does have one fatally flawed default, especially as an Emacs user, C-a is the default initialiser for screen. Not to worry this is easily changed by adding a .screenrc file with the following:

escape ^Qq

I chose to move it to C-q but feel free to move it to a key binding of your choice.

Some other useful short-cuts:

  • C-a 1-9 - Change shell
  • C-a C-a - toggle current and previous shell
  • C-a d - detach session
  • C-a " - ls current shells
  • C-a c - new shell

That’s it, I now have a full functional shell right inside my Emacs, from with I can ssh into servers and run my usual commands.

Take a screenshot with Poltergeist

page.driver.render("#{File.dirname(__FILE__)}/poltergeist_screenshot_#{rand(100)}.png", :full => true)