How to Fix tclsh Line Editing Problem

The problem

One sentence: command line editing sucks in Linux and Mac. On Windows, you can use the up and down arrows, among other things, to recall last lines and edit. On Linux and Mac OS X, these keys don’t work, making line editing difficult.

The Solutions

In my previous article, I mentioned using tkcon to get around this limitation. Today, I am going to talk about a different mechanism: tclreadline. This is a Tcl package which makes use of GNU readline. To install this package on Debian-family of Linux, which includes Debian, Ubuntu, Kbuntu, Xubuntu, and Linuxmint, issue the following command line from the terminal:

sudo apt-get install tclreadline

Next, follow the instruction in the usage section from the tclreadline page. Now, every time you start tclsh, you can use up/down errors, tab-completion, and many other features that GNU readline provides.


3 thoughts on “How to Fix tclsh Line Editing Problem

  1. pmarin

    I think the easiest solution is to use any readline wrapper like rlwrap or rlfe. I use them even for bc(1).

  2. Hai Post author

    @pmarin: Never mind, to use it, just invoke rlwrap tclsh. However, tab-completion does not work. Am I missing something?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s