Saturday, February 28, 2009

Merging PDF documents

Having its origins in the GNU community over 20 years ago, Ghostscript (gs) was designed as a free interpreter for Adobe PostScript with an intention of saving trees and named as a play of words on that. Along with providing tools for raster image processing and converting between different document formats, it also comes with a peculiar pdf/ps viewer called Ghostview (gv), which I am not sure of ever using over good old evince.

Nevertheless, I find some command line gs utils incredibly powerful. Lets say you wanted to merge two pdf files. Just say:

$ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=output.pdf file1.pdf file2.pdf

The options are somewhat involved and long to explain here, but you can read through the documentation. If you want to save the typing, add

$ alias mrg='$ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=output.pdf'

to your .bash_profile and then use

$ mrg file1.pdf file2.pdf

to get a merged output.pdf. Pure GNU.

Sunday, February 22, 2009

Automatic mail notification from gmail

On Ubuntu or any gnome desktop that you're using, simply put the command "mail-notification" in your .bash_profile and sync it up with your gmail/yahoo mailboxes. Every time a new message comes, you can see a small popup on the right. No new tools to install for each website, no thousands of things to consider.

If you want to just give it a try, go via Applications->Internet->Mail Notification and give it a shot.

Friday, February 20, 2009

Enabling backspace in gVim on Windows

I found it really annoying for a few days that my backspace key wouldn't work on my gVim on windows, but it would work fine on linux. I found a pretty nice explanation somewhere after googling, but here is the short answer: put this in your _vimrc in C:\Documents and Settings\\_vimrc --
set bs=2

Yeah yeah... we all know, we need twice the bs ;) From the open or current vim session, of course, you type :set bs=2 (i.e. the same thing with a colon before).

Thursday, February 19, 2009

Command Spell Correction in Bash

If you tend to make mistakes while typing, bash can be a a little less than helpful; just spitting out a "No such file or directory." One small hack which helps towards this is the automatic spell correction built into bash. This will correct small typing errors made with the cd command as follows.

user@host:~ $ cd /ect
/etc
user@host:/etc$

It can be enabled for the current shell by

$ shopt -s cdspell

As before, you can make the effect more permanent by echoing the command into .bash_profile.

Wednesday, February 18, 2009

Case-insensitive Tab Completion in bash

Tab-completion is one of the major things which makes the command-line so powerfully fast to use. It has apparently been around for decades and its preliminary versions would even predate Unix. IMO, bash does it just right while the shells in Windows mess it up. However, many initial bash users find the shell too rigid and less suggestive. Here are a couple of ways I found which makes bash a bit more easy to use.

Most hardened Unix hackers tend to name all their files and directories in the lower case (to save on hitting shift), while less hardened users, especially those using GUI interfaces to browse their files use proper case. So if you are on the command-line and are not sure if the directory is Coursework or coursework, here's a hack for you. Just say:

$ set completion-ignore-case on

If you want to do this across sessions add this line to /etc/inputrc. You might want to do that as root as below.

# echo set completion-ignore-case on >> /etc/inputrc

about:blog

hello, world!

-- A small blog about the little hacks which make life easy and fun.

Actually, a little more than that. Over the years, I have collected/found/conjured up many little hacks & tricks which make life a little more exciting. This blog is sort of a "log" of these for myself.