home icon contact icon rss icon

Textmode

tools I use

Mailbox sidebar for Mutt

I always found the default mailbox handling of mutt a little complicated, since it was missing an overview of folders on the main screen.

Mutt-Ng solved this by introducing a sidebar to list all your mailboxes, including a new/old mail count. However this didn’t last very long and the mutt-ng development stopped unfortunately.

I didn’t look at the possibilities regarding this issue for quite a while, since I had a mailbox status list included in my Windowmanager, however, I tried to integrate it into mutt again last week.

Fortunately the sidebar has been extracted and is now available as a patch: Mutt sidebar (folder list) patch

And for all the lazy people, there is also a debian package called mutt-patched which includes the sidebar among other useul additions.

Now I’m using the following, very nice, setup:

Shell: Deleting files with exclusion

How do you delete a bunch of files, while excluding specific matches?

For example, all files that are no jpeg images.

General way


ls -I "*.jpg"|xargs rm

ZSH, negate the pattern:


setopt extended_glob
rm ^*.jpg

Frustriation with Linux Console Newsreaders

Okay, currently I’m using Snownews as my main newsreader for RSS feeds. Yes, RSS, not Atom because Snownews is one of the rare feedreaders that does not support Atom feeds.

Although people keep saying that this is no problem because there is a cool extension named atom2rss I have to ask myself a question:

This extension exists for quite a while, why don’t they simply integrate support for Atom Feeds?

Besides that, I tried using this extension, which is in fact a filter based on xsltproc (...) which still fails. I know most people might argue that this is Open Source Software, which is of course right, but that doesn’t mean I’ve got the time to finish every piece of incomplete, non-functioning software I come across.

This will probably lead most people to something like “you don’t have to use it, do you?”. And that’s right, I’m using it because it’s the only textbased feedreader for linux I know that has the following features:

  • VIM Keybindings (or configurable keybindings)
  • Category Support
  • and as mentioned, is no X11 application

But I’m frustrated by the missing atom support, and it obviously often misinterpretes the date in a feed.

I don’t want a discussion wether or not this critique is appropriate, or is based on some bugged version, my question is:

Can anyone suggest a textbased feedreader with the above features that supports Atom AND RSS?

I tried raggle, canto and nrss, but they didn’t not satisfy me, so I’m still using snownews for rss, and canto for atom – which sucks.

Edit: Using canto now, which is now almost perfect for my needs.

Selecting Text (Copy/Paste) in Elinks

Just a quick note, since I came across some articles with statements like ”... unfortunately Elinks does not support text selection, or copy and paste...” which is simply wrong.

Elinks does support text selection, you just have to press the Shift key when selecting.

Another common question is: Is it possible to select text without a mouse in elinks, using the keyboard?

The answer is, elinks does not handle that, it depends on your terminal emulator, which in most cases does not support it, afaik. You have to use the mouse (gdm if you’re not running X)

Printing multiple pages on one page with Evince - Linux PDF tools

Right now there seems to be a bug in evince, that doesn’t allow the correct printing of multiple pages per sheet in evince.

I have a PDF containing single sites in landscape format.

The result I expected are sheets like this:

1…3

2…4

However, the result I’m getting, however I mix parameters is:

2…4

1…3

Solution

I used two handy little tools to solve this, the first thing I had to do is merge some single PDF Documents, then create a PDF with multiple pages per sheet.

PDFtk

From the man page:

.bq If PDF is electronic paper, then pdftk is an electronic staple-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses. Pdftk is a simple tool for doing every‐day things with PDF documents.

PDFtk helps us with the following features:

  • Merge PDF Documents
  • Split PDF Pages into a New Document
  • Decrypt Input as Necessary (Password Required)
  • Encrypt Output as Desired
  • Fill PDF Forms with FDF Data and/or Flatten Forms
  • Apply a Background Watermark
  • Report on PDF Metrics such as Metadata, Bookmarks, and Page Labels
  • Update PDF Metadata
  • Attach Files to PDF Pages or the PDF Document
  • Unpack PDF Attachments
  • Burst a PDF Document into Single Pages
  • Uncompress and Re-Compress Page Streams
  • Repair Corrupted PDF (Where Possible)

PDFJam

PDFJam is a collection of scripts:

  • pdfnup puts multiple document pages together on one physical page at a reduced size
  • pdfjoin concatenate multiple PDFs
  • pdf90 rotate PDF pages

Solution

As you can see, to merge PDFs you can either use PDFtk or pdfjoin. Here is the PDFtk way:


pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf

To get a PDF with multiple pages per physical page, we use pdfnup like this:


pdfnup --nup 2x2 --column true joined.pdf

Nmap does Network Topology Maps with Zenmap

Nmap:http://nmap.org, the open source port scanner supports the generation of network topology maps with it’s latest release.

The integration of radialmap allows the generation of network maps through the nmap frontent Zenmap

Different Symbols represent:

  • Routers
  • Switches
  • Wifi access points
  • Firewalls
  • Hosts with filtered ports
  • Regular Hosts represented by differenz sized circles based on open ports

The grey circles represent distance, and the colored lines are different types of connections.

I always missed this feature in nmap, it’s quite handy on large networks. Can’t wait to test it in our university :)

ext3undel: Recover deleted files on ext2/ext3 filesystems

About 2 years ago I tested various tools for file recovery which seemed quite good, and since I could not recover all the files I wanted, I kept that harddrive.

Today I gave it another try, and came across a tool called ext3undel

ext3undel is a collection of scripts that wrap the steps for recovering files from ext2 and ext3 filesystems into much easier procedures.

It has two basic modes:

  • gabi, get all back imedeately
  • ralf, recover a lost file

gabi saves you a lot of work: it can be used to recover whole partitions, it uses the recovery tools photorec/testdisk and foremost.

The ralf mode on the other hand uses Sleuthkit to look for specific blocks which are then processed by photorec/testdisk.

Looks like ext3undel is quite handy, still couldn’t find my desired file though :/

Note: If you delete a file with rm or lose your inode table in some other way, files can be recovered because the actual data still exists on the harddisk, you can of course not recover files that have already been overwritten.

NCDU - Disk usage Explorer

I think most uf us are frequently looking for a shell one-liner to list largest files on a system, either do clean up because the harddisk is to small, or just find out what’s using the most disk space.

ncdu to the rescue.

If you open up this nice tool, it recursively calculates the disk usage of a specified directory, and provides a neat interface to browse this directory.

It’s very basic, though has some useful options:

  • sort by name, size
  • delete specific files
  • percentages, graphs
  • unit powers of either 1000 or 1024

and more

The only thing I miss are VIM keybindings :)

Filemanager and Imageviewer with Vim Keybindings

As I’m using vim all the time, and almost every app I use has vim keybindings, I’m missing two things:

  • a good Filemanager with vim keybindings
  • an image viewer with vim keybindings

Filemanager

There is a built in filebrowser (:explore), and vim plugins like VimExplorer or VimCommander

However, both are not really what I needed.

I like Midnight Commander, but the fact that you can’t configure keybindings, makes it unusable for me.

The best vim-like filemanager I found so far is definitely vifm it has really cool features and is clean and simple. That’s exactly what I was looking for – unfortunately the project seems to be inactive :(

Edit: It’s alive, yay :)

Imageviewer

I did not find a good imageviewer with vim like keybindings :(

Edit: As daftago mentioned in the comments, xzgv looks pretty good.

If anyone knows good filemanagers, imageviewers or other applications with vim keybinding support, PLEASE comment!

Edit: Check Vimperator for Opera

github.vim a vim plugin for github

Recently drnic showed me his textmate bundle for github and I was really impressed.

It let’s you do the following:

  • select some lines of code in Textmate, and open the same section (including selection hilighting) on the corresponding public github url
  • go to a specific line of code, hit a key, and get directly to the github page of that commit and file, ready to post a comment

I didn’t even know about those possibilites github offers.. and I thought, wow I need this in my editor (vim) too.

So i created a little plugin, my first vim plugin, wrapping the – fortunately very modular – scripts drnic wrote.

There are 2 branches:

  • Master – a standalone version without the github-tmbundle dependency
  • TMB – a shorter version that depends on the scripts included in github-tmbundle

Both are available on my github repository as github-vim

The latter is easier to maintain since I only have to write calls to the existing methods, so I will update it with all new features in the tmbundle as soon as possible. But I will try to keep the standalone version as current as possible.

As mentioned this is my first vim plugin, therefore any suggestions, corrections and requests are very welcome.

Ack-Grep, a grep replacement

Ack-Grep is a replacement for grep written in perl.

It’s basic usage is ack fubar, which is about the same as grep -r fubar

It’s a very fast tool since it excludes a lot of files you don’t really want to search (like repository information, temporary files, backup files etc.) And furthermore it let’s you define and specify specific filetypes.

For example, I often want to search only .dryml files (I’ll mention in a future post what this is all about). To define such a custom simple define it in your ˜/ackrc like this:


--type-set=dryml=.dryml

This enables commands like


ack --dryml fubar

searching only files ending in .dryml

Furthermore the option ack-grep -f let’s you list the files only, without actually searching them, this can be useful, although good shells provide similar functionality. It’s nice to simply use something like


ack -f --dryml

You can even print the matching parts with perls special variables like $&.

Give it a try, you will like it! Note: The Debian package name is ack-grep, not ack.

Data synchronization with Rsync and Unison

I often have to switch from my main desktop machine to my laptop so I need a way to synchronize both (my home directory which contains all important files).

In my scenario the desktop machine is the Master and my laptop is a Slave, there are times when I just want to copy the files 1:1 from my Master, and delete all other files from Slave, thats why I like rsync, since it is perfect for this one-way operation.

On the other hand unison is awesome to synchronize in both directions, and it’s much simpler to handle than rsync for this.

Basically I have 3 tasks:

  • 1. Master -> Slave, delete additional files on slave
  • 2. Slave -> Master, just add, don’t delete
  • 3. Synchronize Master and Slave

And here is how I do this:

1. Master -> Slave, pull a complete update from Master:


EXCLUDEFILE = ~/etc/rsync_excludes
rsync --delete -T ~/tmp -azvv --exclude-from=$EXCLUDEFILE master:~/ /home/solars

EXCLUDEFILE is just a list of directories that I don’t want to be transferred, like tmp/ and similar.

The options mean:

  • —delete deletes all the extra files from the target
  • -T ˜/tmp is just the directory for tempory files
  • -azzv is a shortcut for -rlptgoD meaning—archive, which does recursion, preserving almost everything like times, permissions, links etc. uses compressions (-z) and is verbose (-v)
  • —exclude-from=$EXCLUDEFILE excludes every path in EXCLUDEFILE
  • master:˜/ source, the master
  • /home/solars and my home directory as target

2. Slave -> Master, pull from master, keep additional and newer files:


EXCLUDEFILE = ~/etc/rsync_excludes
rsync -u -T ~/tmp -azvv --exclude-from=$EXCLUDEFILE slave:~/ /home/solars

  • -u keeps files that are newer on master

Note: the important difference is that there is no—delete option here

3. Synchronizing in both directions using unison:

Unison allows you to create profiles for different tasks, in this example I want to synchronize my opera configuration:

A profiles goes into a file ending in .prf in the ˜/.unison directory, for example ˜/unison/opera.prf:


prefer = newer

root = /home/solars/.opera
root = ssh://slave//home/solars/.opera

ignore = Path images*
ignore = Path *cache*
ignore = Path mail*

  • prefer = newer means newer files should always be preferred
  • root = lines indicate the directories to synchronize (note the SSH path)
  • ignore = Path .. ignores the given path

Now you can run it simply with unison opera.

As you can see these are very basic and easy ways to synchronize machines in different ways, of course both tools have much more options like the above mentioned, this is just an introduction of basic usage.

Feel free to suggest your ways and tips to synchronize data.

ClusterSSH, SSH to multiple servers (Rails Deployment)

If you have a cluster of similar machines, for example Ruby on Rails deployment hosts, you often need to run the same configuration or monitoring tasks on all of them.

Much like capistrano, ClusterSSH provides you a way to execute commands in multiple hosts at once.

The setup of ClusterSSH is very easy, just install it and run:


sudo cssh -u > /etc/csshrc

This will generate the basic, system-wide configuration file, which let’s you configure a lot of options.

Now, to add your hosts I created the file ~/.csshrc in my Home directory, containing for example:


host1 = example1.com:2300
host2 = example2.com
hosts3 = example3.com user@example4.com
group1 = host1 host2
all = host1 host2 hosts3

I think thats pretty straight forward.

Now if you type in cssh group1 at your command prompt, you will get one main control terminal to issue commands, which are then executed in the additional server terminals.

Multiple SMTP accounts using mSMTP and Mutt

Using sSMTP for a long time now, I had to say goodbye today. The reason is that I wanted to integrate multiple SMTP accounts, for example my GMail account, and sSMTP doesn’t support this.

I found mSMTP which looks very nice. It is lightweight like sSMTP and supports multiple accounts.

Below is my example configuration (stripped down to the basics) for msmtp and mutt.

This goes into msmtprc:


account default
host tachium.at
... tls fu ...
from cb@tachium.at
user cb@tachium.at
password XXX

account gmail
host smtp.gmail.com
from ch.blank@gmail.com
... tls fu ...
user ch.blank@gmail.com
password XXX
port 587 

As you can see the first account is the default one (if I do not select a specific account when invoking mSMTP).

For the account selection, use something like this in your muttrc:


set sendmail="/usr/bin/msmtp" 
set envelope_from=yes

macro generic "<esc>1" ":set from=cb@tachium.at" 
macro generic "<esc>2" ":set from=ch.blank@gmail.com" 

Now, if you send a mail mSMTP looks at the sender address and tries to find a corresponding ‘from’ entry in it’s configuration, or uses the default account if it cannot find one.

Note: You can select the account in different ways, eg. explicitly from the command line, the docs are a good starting point :)

Wmii Windowmanager

A week ago I switched from Fluxbox to the Wmii Windowmanager and I have to say it’s the best WM I ever had.

It currently looks like this:

Which looks basically like every other WM except that Wmii uses some Magic which makes it really dynamic. As you can see it is tiled and fully manageable without a mouse, but supports floating windows aswell.

The important terms Wmii consists of:

  • Clients, a single application window
  • Columns, (vertical) containing a set of clients
  • Tags, identifiers (like the tags you know form tag clouds) for clients
  • Views, a set of clients with a specific tag (like Workspaces)

The main thing thats different from the other Windowmanagers are tags. The point is that a client can have multiple tags and thus can be on multiple Views (which are basically workspaces) at the same time.

For example in the screenshot above I have views called bar and web, and I usually read my emails on bar. Sometimes I need to write about something contained on a webpage, so with Wmii I just have to give my mail window the additional tag web, and it appears on my web view too. Since it is on both views the layout on bar doesn’t change, and I can even use completely different dimensions of the same window on each view.

Another very cool thing is that each column can have one of 3 different modes to display its clients:

  • Equal size
  • Stacked, only one client fully visible, like Tabbing
  • Maximized, current client is maximized

Clients inside a column can be resized and moved between columns freely.

What makes Wmii even more dynamic is that it provides a virtual filesystem for the configuration and current state (like procfs), based on 9P. This enables you to script Wmii in almost any language.

Wmii contains an executable, wmiir, to interact with the core, and a shellscript for the basic configuration on startup.

There is also a ruby based implementation of the 9P2000 protocol, Ruby-ixp for Wmii, which is a bit faster than wmiir.

I found two Ruby projects that provide a nice interface for Wmii scripting in Ruby:

Note: The rumai page is currently in progress, and the script is about to be updated for the new Wmii release. Although ruby-wmii has a lot of features, rumai provides some additional, and really nice methods. So be sure to check out both.

Update: Since a lot of people are asking, I added my config files. Not sure if they are up to date, I changed some lines in standard-plugin, they are marked with the word CHANGE.

wmiirc-config standard-plugin