Dealing with oh-so-many terminal windows

I have a problem. I have too many terminals and they tend to get lost. Emacs and vim and probably other editors are good at dealing with the problem of too many files, you just give every file a name, and then give people an easy way of finding open files by name.

I want to be able to do this with terminals.

Using screen

Screen works quite well for this: it allows you to name open terminals and then re-open these terminals by name. I’ve made this work by having an X terminal that connects to an existing instance of screen, this allows me to have a half-dozen interfaces to the same instance of screen at the same time.

However this approach has a couple of problems.

  • No completion of terminal names (it does, however, allow you to just write buffer name prefixes)
  • The default maximum number of windows isn’t high enough (the maximum of 40).
  • You end up pressing F quite, as terminals seem to get temporarily broken every time you resize.
  • Having a screen window open in two x terminals of different sizes confuses clients.

Trying to do this same in emacs

This would be a slightly nicer approach since emacs is awesome – and ido mode’s buffername completion is great.

However, some niggles in emacs have stopped me from doing this.

No curses in eshell

Emacs provides a light-weight shell (eshell). This allows you to interact will using your shell (copy and paste searching backwards etc). However it breaks curses, so no less, no mutt, no vim. This counts as unusable to me, as I tend to do things like open less on several hundred megabyte files on a remote machine.

ansi-shell to the rescue

Ansi-shell however does support curses, and vim and mutt, and beautiful colours. So this looked hopeful.

But not quite…

However, ansi-term just doesn’t quite work for the following reason:

  • mutt doesn’t work. If you resize a window while using mutt, mutt breaks and draws things in random places
  • Not fast enough! I like streaming large files with the F command in less, this can bring my terminal grounding to a halt

So yes, I’m settling with hacked version of screen for the moment.

Increasing the maximum number of screen windows

I’m not quite sure why I need more than 40 terminals but it appears that I do. I like to have a terminal for each different class of thing I’m doing (like reading though code, fixing bugs on by machine, doing things in a source tree, running tests, doing some recording to debug these tests, deploying, playing in a python shell, doing some stats in R) and then terminals logged into half a dozen machines, as well as poised to look at logs on these machine. The limit of 40 terminals poses a problem here, this is made worse by the fact that when the world catches file you often want to open a lot of new terminals – hitting up against limits exactly when you want to do things is not fun.

We can however increase screen’s window limit by rebuilding. On ubuntu we can do the following

apt-get source screen
cd screen-blah-blah
# Set default MAXWIN to something sane like 500
cd ..
dpkg -i <deb file that dpkg-buildpackage dumped in your parent directory>

This will work equally well for other debian-based builds (one presumes).


November 25, 2012 at 9:24 pm Leave a comment

Power of Habit Summary

The Power of Habit by Charles Duhigg

What is it?

Journalistic pop-science. An eclectic collection of interesting and useful facts with a loose over-riding theme. Very exciting if you don’t know most of these facts, slightly annoying if you do. Has references to relevant material.

Thesis in a paragraph

Much of people behaviour can be explained by simplified, sometimes irrational, often automatic decision-making processes rather than careful rational thought. Many of these processes can be understood formally, if not scientifically, such understanding can be applied generally to good effect.

Structure of the book

Much of the book is coached in the terms of the “habit-loop” a form of conditioning which can be observed in the brains of humans and animals.

The book starts off by investigation the evidence for this habit-loop at a physiogical level and looks at its implications. It then attempts to apply this idea rather loosely to a number of other fields: organizations, social movements and medical treatment. However, since these formally constrained ideas cannot be cleanly applied to these fields (or even individual human behaviour) it becomes more of an anecdote filled discovery of how the more general theme of automatic behaviour can be applied to these fields.

September 16, 2012 at 8:29 pm Leave a comment

One of the nice thing about reading books on kindle is your ability to take

One of the nice thing about reading books on kindle is your ability to take notes as you read in a way that doesn’t despoil a book. Another advantage of having electronic notes is that you can do interesting things with them (in my case I’m feeding them into anki).

Exporting kindle notes

The easiest way I found to export notes from a kindle (particular from a phone acting as a kindle was via the annotations website:

This unfortunately lacks the exact location of the note but is good enough for many use cases.

Better ways to export

This was good enough for me though I didn’t go further. The more paranoid impulses in me say that I should be liberating as much of my data as possible in case kindle decides to destroy it – but I decided I was happy in the knowledge that this could be done, and trust that someone will start complaining if amazon decides to stop letting you do this in good time for me to react.

In case this is the use case you are after or you have more advanced uses for your highlights then there were a couple of approaches I came across on the internet, but didn’t use:

  • There appears to be a PERL script to do this for you
  • The site looks like it would be very easy to scrape.
  • kindle readers supposedly

August 30, 2012 at 9:26 pm Leave a comment

Samsung Galaxy S2 i9100 over-heating battery symbol fix (Probably water related)

It turns out that phones don’t like water (even rain). After a particularly heavy rain shower, my phone developed a strange behavior where it would show a battery symbol together with a hot thermometer and refuse to switch on. This fixed itself after 10 minutes or so, but some time later the similar symptoms reappeared.

  • The phone ran fine when on
  • When switched off the phone refused to switch on (with aforementioned over-heating battery symbol)
  • However, when the micro-usb had a power source plugged in everything worked fine.

It seems like this is a common problem with the usb connector, and some people have fixed similar issues by buying replacement usb cards. Fortunately, I didn’t need to go so far, blowing compressed air into the micro-usb connector completely fixed this issue.

June 28, 2012 at 6:55 pm 3 comments

Ensure a bash process tidies up its children

When you have a bash process that spawns a number of background children, there is an unforunate side effect: These processes never exit. If you try to kill their parent they are happilly adopted by init.


Adding the following line at the beginning of your bash script ensure that all your children are truly dead when you yourself are killed.

trap "kill -- -$BASHPID" EXIT

The -PID argument tells bash to kill the process group with id $BASHPID, process groups have the same id as the spawning process (but the process group id remains even after processes have been reparented). The — gets kill not to interpret this as a signal :S.


The one caveat here is if someone sends you kill -9. If this happens, you don’t get to do anything before your imminent death (even murder all your children).

June 22, 2012 at 2:56 pm Leave a comment

Showing the build dependencies of an apt package

apt-cache showsrc name

March 4, 2012 at 11:39 pm Leave a comment

Turning your computer into a wireless router – easy-to-run code.

The following script adapted from this post will an ubuntu linux laptop with a wireless dongle into a wireless router:

You need to run sudo bash and sudo bash to start and stop the script, and create a local settings file to store your configuration.

November 26, 2011 at 7:17 pm Leave a comment

Older Posts

February 2019
« Nov