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 »


Advanced Dynamic DNS with ddclient

February 4, 2011

If you need remote access to a computer whose IP changes dynamically, ddclient may be the tool for you. Check out this previous article for how to set up ddclient using a free service like DynDNS. Once set up, you will be able to connect to your box using a pretty name like mybox123.dyndns.org, rather than having to keep track of the changing IP. I should mention that there are many other free DNS services besides dyndns.com, and that many home routers can take care of Dynamic DNS for you (i.e., you can set it up on the router, rather than on your computer).

Today, however, we have a more complicated task. This article will teach you how to:

  • make ddclient update multiple host names
  • make ddclient update the IP of multiple interface (e.g., your ethernet and your wireless lan)
  • set up ddclient so that it updates correctly regardless of whether you are on a wired or wireless connection
  • make ddclient use either your interface address (may be local, e.g. 192.168.1.15) or the address that is visible from the internet.

Read the rest of this entry »