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

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 »


Quick Linux Tip: Remap “Back” Key to Win Key

January 22, 2010

Thinkpad keyboards are the best laptop keyboards I’ve seen. The function keys are placed in groups of four, with gaps, like on a full-size keyboard. The arrow keys are located lower than the rest of the keys, for easy tactile identification. And best of all, the Insert, Delete, Home, End, and Page Up/Down keys are grouped in the familiar 2×3 box pattern one would expect to see on a desktop keyboard.

The only thing I’m missing is a right Windows key (technically a Super key). A lot of handy Amarok shortcuts use the Win key, such as Win+O for displaying the OSD, or Win+P for firing up the playlist. I’ve also set Win+Plus and Win+Minus to change the volume. With only a left Win key, all of the above-mentioned shortcuts require two hands. So what can I do?

I can remap the “back” key (XF86Back) located above the left arrow key to act as a right Win key. (The back key itself is not that useful — in most sensible applications, one can use Backspace for that purpose.)

First, I open up xev and press the key to find its keycode: 166. Then I use xmodmap to test the changes live:

xmodmap -e “keycode 166 = Super_R”

Finally, I save the setting in my ~/.Xmodmap:

keycode 166 = Super_R

Mission accomplished.


Why Open Source Rocks (and the music industry does not)

August 9, 2009

If you ever looked for song lyrics online, you know how most lyrics sites are. Plenty of ads, popups, silly scrolling flash gadgets, bad punctuation, and no easy way to send in corrections. Why not apply to lyrics the same community-driven editing model that has made Wikipedia so successful?

LyricWiki.org has done exactly that, and more. They have provided an API, making it easy for media players to query the database and fetch the lyrics for a specific song. To get an idea of this project’s success, check out these stats. At the time of this writing, LyricWiki is the fifth largest MediaWiki in existence, and the largest wiki that is not a Wikipedia or Wiktionary. What an inspiring example of a community built around the ideals of improving content and making information available. What could go wrong?

Read the rest of this entry »


Slow KDE / Plasma on Intel Integrated Graphics?

June 25, 2009

Got a laptop with an Intel GMA? Is Alt+Tab slower than you would like? Does Plasma take forever to move or resize an applet? Maybe you didn’t think it could get better?

Try playing with the options in xorg.conf. This is a good starting place.

In my case lspci shows ‘Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller [8086:2a42]’, and putting

Option  “AccelMethod”   “UXA”

in /etc/X11/xorg.conf has improved things significantly. UXA acceleration has been disabled by default in Ubuntu because it caused problems for some people, but in my case enabling it has made everything snappier, and also gotten rid of the drawing artifacts I used to see.

It also caused suspend to stop working (assert in X upon waking), but a recent fix to xserver-xorg-video-intel takes care of that. Distros might have released an update by now, but if you’re using Kubuntu and can’t wait, you can grab the packages from this ppa.

Snappy plasma, working suspend, happy user.

Update: Here is a post with another trick, using the -graphicssystem raster option of Qt programs. It makes switching tabs in Konsole faster, and it does wonders for long lines in Kate!


Two OpenOffice.org Writer Tricks

February 16, 2009

Trick #1: Stop AutoText from switching to Times New Roman

I often edit files in fonts other than Times New Roman, just because that font is so ubiquitous. And I sometimes use AutoText to insert frequently used phrases, or Romanian words in an English text (so that I don’t have to switch languages constantly). One thing that has always annoyed me is that after invoking an AutoText completion (F3), the next characters will always be in Times New Roman (even if the AutoText itself is in another font).

As it turns out, this happens because Times New Roman is the font of the Default paragraph style. So hit F11 and modify your style to use the desired font. In fact (and this is a topic for another day), styles should be used in most cases and formatting a selection of text (bold, italic, font, font size, paragraph indentation) should rarely be done by hand. This is very unintuitive to people who have been using text editors before the GUI era.

Trick #2: Insert Formula without switching into formula-edit mode

Read the rest of this entry »


pv: Progress Bar for md5sum et al.

February 4, 2009

Tools that know they will take a long time often come with a built-in progress indicator, but there are other utilities on Linux that often leave the user frustratedly tapping their fingers, wondering how much longer they will have to wait.

Luckily, there is a nifty little tool called pv that will donate a progress bar to any program that can read from standard input or a pipe. pv probably stands for pipe viewer.

1. Simple example: figure out how long an md5sum will take:

pv eternal.avi |md5sum

will display something like

96.5MB 0:00:05 [25.3MB/s] [=======>                                    ]  9% ETA 0:00:48

Read the rest of this entry »