Unix Tip: Make ‘less’ more friendly

February 11, 2011

You probably know about less: it is a standard tool that allows scrolling up and down in documents that do not fit on a single screen. Less has a very handy feature, which can be turned on by invoking it with the -i flag. This causes less to ignore case when searching. For example, ‘udf’ will find ‘udf’, ‘UDF’, ‘UdF’, and any other combination of upper-case and lower-case. If you’re used to searching in a web browser, this is probably what you want. But less is even more clever than that. If your search pattern contains upper-case letters, the ignore-case feature will be disabled. So if you’re looking for ‘QXml’, you will not be bothered by matches for the lower-case ‘qxml’. (This is equivalent to ignorecase + smartcase in vim.)

So how do we take this useful feature and make it permanent, so that we don’t have to remember to type less -i every time? We could create an alias less='less -i'. But there are tools (such as git-log) that invoke less on their own, and they will not know about the ignore-case option. It would be better if we could tell less that we always want that feature on, regardless of startup flags. This article will teach you how to do that.

Read the rest of this entry »

Advertisements

Shortcut: Delete an Entire Word

May 27, 2008

Before I began using VIM I didn’t care much that my typing habits were very inefficient, but now I’m looking everywhere for possible optimizations

There are two simple shortcuts that work on KDE, Gnome and (AFAIK) even Windows, and that will probably become second nature once you start using them. Perhaps they are regarded as common knowledge, but I’ve only stumbled across them this year.

Ctrl+Backspace deletes the last word.

Ctrl+Delete deletes the next word.

And of course Ctrl+W in bash (as in VIM) is very useful when the length of your command gets out of control.


Linux Tip: fsck Progress Indicator

January 2, 2008

Linux does a great job of checking the local file systems every once in a while to make sure there is no corruption. Unfortunately, this luxury does not extend to removable drives. It will give you a warning (file system unchecked for so many days), but will do nothing about it. That is why I recommend doing a manual check on your external drives from time to time.

If you run fsck with the default options, it will not display any indication of progress, and that can get annoying if you have a large drive and don’t know how much longer you’ll have to wait. But there is a simple solution to this, I only wish I had taken the time to read the man page earlier:

fsck -C /dev/sda5

that will display a nice progress indicator while scanning (works only for ext2/ext3).