Cygwin has come a long way … A story in animated GIFs

Search is handy for adding new packages to your installation.

First of all, let me say that there is some currency to what the title and pictures imply.

Cygwin/X really has come a long way.  10 years ago, the only viable way to run Cygwin was through a DOS-style UNIX shell. The windows system Cygwin/X provided, such as it was, was  mostly TWM, a primitive window manager which  I used to use, which ran the core programs in the X-Windows distribution. Most  of what came with Cygwin,  such as Gnome or KDE, never worked for me, making me an FVWM2 fan for a long time. Along the way, I appreciated  that while FVWM2 was very stripped-down, it made up for it in flexibility and configurability. Even now, FVWM2 is quite liveable.

Postinstall scripts can be a bit of a wait.

I decided yesterday to upgrade Cygwin on one of my older computers,  and after working past some glitches in installation, found that:

  1. If you have your guard down, you may still install packages you hadn’t intended, particularly the TeX language packs for languages and alphabet systems that you know you will never use. Minutes can turn to hours with postinstall scripts running trying to configure these redundant packages.
  2. hacking_keys
    I had this idea of moving my old Cygwin installation to another drive; and it was then I discovered a thicket of permission problems that I had to untangle. This took a lot of work.

    Mate is recent addition to Cygwin, and actually works on my slow system in 2016. In fact, I am using the Midori web browser to edit this blog under Mate in Cygwin/X.

  3. GIMP was once a graphics program you had to compile; now it is intallable for Cygwin as its own package.
  4. When moving my old
    Github is the place for a lot of things to round out Cygwin. I was using it to clone source code remotely, then compile and install.

    distribution to another drive, I found a ton of permision problems which were caused by compiling the source for various downloaded code  as another user – not the owner of the directory.

  5. I now have a good system, with much more functionality than ever before. Cygwin has gone from a system that was “mostly broken” to “mostly working” in the space of 10 or so years.green_ninja

Programmatic Mathematica XVI: Patterns in Highly Composite Numbers

This article was inspired by a vlog from Numberphile, on the discussion of “5040: an anti-prime number”, or some title like that.

A contributor to the OEIS named Jean-François Alcover came up with a short bit of Mathematica code that I modified slightly:

      record = 0; n = 1, n <= 110880, n = If[n < 60, n + 1, n + 60], tau = DivisorSigma[0, n]; 
      If[tau > record, record = tau; Print[n, "\t\t", tau];
      Sow[tau]]]][[2, 1]]

This generates a list of a set of numbers with an unusually high amount of factors called “highly composite numbers” up to 110,880. The second column of the output are the number of factors.

1      1
2       2
4       3
6       4
12      6
24      8
36      9
48      10
60      12
120     16
180     18
240     20
360     24
720     30
840     32
1260        36
1680        40
2520        48
5040        60
7560        64
10080       72
15120       80
20160       84
25200       90
27720       96
45360       100
50400       108
55440       120
83160       128
110880      144

For a number like 110,880, there is no number before it that has more than 144 factors.

Highly composite numbers (HCNs) are loosely defined as a natural number which has more factors than any others that came before it. 12 is such a number, with 6 factors, as is 6 itself with 4. The number 5040 has 60 factors, and is also considered highly composite.

This works out to 60, because with 24, for example, we get the factors 2, 4, 8, and 16. With 24×32, we get 2, 3, 4, 6, 8, 9, 16, 18, 36, 72, and 144, all which evenly divide 5040. The total number of factors including 1 and 5040 itself can be had from adding 1 to each exponent and multiplying: (4+1)(2+1)(1+1)(1+1)=5×3×2×2=60.

Initially, facotorization of HCNs was done in Maple using the “ifactor()” command. But there is a publication circulating the Internet referring to a table created by Ramanujan that has these factors. A partial list of these are summarized in a table below. The top row headers are the prime numbers that can be the prime factors, from 2 to 17. The first column is the number to factorize. The numbers in the same columns below these prime numbers are the exponents on the primes, such as: 10,080=25×32×51×71. The last column are the total number of factors on these HCNs. So, by adding 1 to each exponent in the row and multiplying, we find that 10,080 has 6×3×2×2=72 factors.


As a number of factors (underneath the “# facotrs” column), We get overlapping patterns starting from 60. One of them would be the sequence: 120, 240, 360, 480, 600, and 720. But the lack of an 840 breaks that pattern. But then we get 960, then 1080 is skipped, but then we get 1200.

For numbers of factors that are powers of 2, it seems to go right off the end of the table and beyond: 64, 128, 256, 512, 1024, 2048, 4096, 8192, … . Before 5040, the pattern is completed, since 2 has 2 factors, 6 has 4 factors, 24 has 8 factors, 120 has 16 factors, and 840 has 32 factors. The HCN with 8192 factors is 3,212,537,328,000. We have to go beyond that to see if there is a number with 16,384 factors.

Multiples of 12 make their appearance as numbers of factors: 12, 24, 36, 48, 60 (which are the numbers of factors of 5040), 72, 84, 96, 108, 120, but a lack of a 132 breaks that pattern. But then we see: 144, 288, 432, 576, 720, 864, 1008, 1152, and the pattern ends with the lack of a 1296.

We also observe short runs of numbers of factors in the sequence 100, 200, 400, 800, until we reach the end of this table. But the pattern continues with the number 2,095,133,040, which has 1600 factors. Then, 3200 is skipped.

There are also multiples of 200: 200, 400, 600, 800, but the lack of a 1000 breaks that pattern. But when seen as multiples of 400, we get: 400, 800, 1200, 1600, but then 2000 is skipped.

There are also peculiarities in the HCNs themselves. Going from 5040 to as high as 41,902,660,800, only 4 of the 60 HCNs were not multiples of 5040. The rest had the remainder 2520, which is one-half of 5040.

Also beginning from the HCN 720,720, we observe a run of numbers containing 3-digit repeats: 1081080, 1441440, 2162160, 2882880, 3603600, 4324320, 6486480, 7207200, 8648640, 10810800, and 14414400.

Number 2   3   5   7   11  13  17  # of
5040    4   2   1   1               60  
7560    3   3   1   1               64  
10080   5   2   1   1               72  
15120   4   3   1   1               80  
20160   6   2   1   1               84  
25200   4   2   2   1               90  
27720   3   2   1   1   1           96  
45360   4   4   1   1               100 
50400   5   2   2   1               108 
55440   4   2   1   1   1           120 
83160   3   3   1   1   1           128 
110880  5   2   1   1   1           144 
166320  4   3   1   1   1           160 
221760  6   2   1   1   1           168 
332640  5   3   1   1   1           192 
498960  4   4   1   1   1           200 
554400  5   2   2   1   1           216 
665280  6   3   1   1   1           224 
720720  4   2   1   1   1   1       240 
1081080 3   3   1   1   1   1       256 
1441440 5   2   1   1   1   1       288 
2162160 4   3   1   1   1   1       320 
2882880 6   2   1   1   1   1       336 
3603600 4   2   2   1   1   1       360 
4324320 5   3   1   1   1   1       384 
6486480 4   4   1   1   1   1       400 
7207200 5   2   2   1   1   1       432 
8648640 6   3   1   1   1   1       448 
10810800    4   3   2   1   1   1       480 
14414400    6   2   2   1   1   1       504 
17297280    7   3   1   1   1   1       512 
21621600    5   3   2   1   1   1       576 
32432400    4   4   2   1   1   1       600 
61261200    4   2   2   1   1   1   1   720 
73513440    5   3   1   1   1   1   1   768 
110270160   4   4   1   1   1   1   1   800 
122522400   5   2   2   1   1   1   1   864 
147026880   6   3   1   1   1   1   1   896 
183783600   4   3   2   1   1   1   1   960 
245044800   6   2   2   1   1   1   1   1008    
294053760   7   3   1   1   1   1   1   1024    
367567200   5   3   2   1   1   1   1   1152    
551350800   4   4   2   1   1   1   1   1200    

After that run, we see a 4-digit overlapping repeat. The digits of the HCN 17297280 could be thought of as an overlap of 1728 and 1728 to make 1729728 as part of that number. The 3-digit run continues with: 21621600, 32432400, 61261200, and after that the pattern is broken.

Programmatic Mathematica XV: Lucas Numbers

The Lucas sequence follows the same rules for its generation as the Fibonacci sequence, except that the Lucas sequence begins with t1 = 2 and t2 =1.

Lucas numbers are found in the petal counts of flowing plants and pinecone spirals much the same as the Fibonnaci numbers. Also, like the Fibonacci numbers, successive pairs of Lucas numbers can be divided to make the Golden Ratio, \phi. The Mathematica version (10) which I am using has a way of  highlighting certain numbers that meet certain conditions. One of them is the Framed[] function, which draws a box around numbers. Framed[] can be placed into If[] statements so that an array of numbers can be fed into it (using a Table[] command).

For example, let’s frame all Lucas numbers that are prime:

In[1]:= If[PrimeQ[#], Framed[#], #] & /@ Table[L[n], {n, 0, 30}]

The If[] statement is best described as:

If[Condition[#], do_if_true[#], do_if_false[#]]

The crosshatch # is a positional parameter upon which some condition is placed by some function we are calling Condition[]. This boolean function returns True or False. In the statement we are using above, the function PrimeQ will return true if the number in the positional parameter is prime; false if 1 or composite.

The positional parameters require a source of numbers by which to make computations, so for this source, we shall look to a sequence of Lucas numbers generated by the Table command. The function which generates the numbers is a user-defined function L[n_]:

In[2]:= L[0] := 2
In[3]:= L[1] := 1
In[4]:= L[n_] := L[n-2] + L[n-1]

With that, I can generate an array with the Table[] command to get the first 31 Lucas numbers:

In[5]:= Table[L[n], {n, 0, 30}]
{2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, \
2207, 3571, 5778, 9349, 15127, 24476, 39603, 64079, 103682, 167761, \
271443, 439204, 710647, 1149851, 1860498}

This list (or “table”) of numbers is passed through the If[] statement thusly:

In[6]:= If[PrimeQ[#], Framed[#], #] & /@ Table[L[n], {n, 0, 30}]

to produce the following output:


Note that this one was an actual screenshot, to get the effect of the boxes. So, these are the first 31 Lucas numbers, with boxes around the prime numbers. The Table[] command appears to feed the Lucas numbers into the positional parameters represented by #.

There was a sequence I created. Maybe it’s already famous; I have no idea. On the other hand, maybe no one cares. But I wanted to show that with any made-up sequence that is recursive in the same way Fibonacci and Lucas numbers were, that I could show, for example, that as the numbers grow, neighbouring numbers can get closer to the Golden Ratio. The Golden Ratio is \phi = \frac{1 + \sqrt{5}}{2}. I want to show that this is not really anything special that would be attributed to Fibonacci or François Lucas. It can be shown that, for any recursive sequence involving the next term being the sum of the previous two terms, sooner or later, you will always approach the Golden Ratio in the same way. It doesn’t matter what your starting numbers are. In Lucas’s sequence, the numbers don’t even have to begin in order. So let’s say I have:

K[0] := 2
K[1] := 5

K[n_] := K[n-2] + K[n-1]

So, just for kicks, I’ll show the first 31 terms:

Table[K[n], {n, 0, 30}]
{2, 5, 7, 12, 19, 31, 50, 81, 131, 212, 343, 555, 898, 1453, 2351, \
3804, 6155, 9959, 16114, 26073, 42187, 68260, 110447, 178707, 289154, \
467861, 757015, 1224876, 1981891, 3206767, 5188658}

Now, let’s output the Golden Ratio to 15 decimals as a reference:

N[GoldenRatio, 15]

Now, let’s take the ratio of the last two numbers in my 31-member sequence:

N[K[30]/K[29], 15]

You may say that the last two digits are off, but trying against the Fibonacci sequence, the ratio of the 30th and 31st numbers yields merely: 1.61803398874820, off by 3 digits.

For Lucas: 1.61803398875159, off by 4 digits — even worse.

So, my made-up sequence is more accurate for \phi than either Lucas or Fibonacci. I have tried other made-up sequences. Some are more, and some are less accurate. If it depends on the starting numbers, I think some combinations work better, and you won’t necessarily get greater accuracy by starting and ending with larger numbers.

The HP 35s Calculator: a revised review

The HP 35s Programmable Calculator

A while ago, I wrote a blog article on a different blog regarding the HP 35s programmable calculator. Depending on where you buy it, it could cost anywhere from $55 to $98 to buy.

I have heard in other places about the plastic used to make this calculator. It is indeed cheap plastic. It certainly feels hollow when you hold it. It belies the amount of memory and the increased calculating power that lies inside. The calculator has two calculation modes: ALG mode (algebraic mode) to resemble conventional calculators, and RPN mode (reverse-Polish notation), which, for those who do long calculations, provides a way to avoid parentheses, but requires getting used to stacks.

As far as RPN mode goes, only four numbers can be pushed on to the stack at maximum for this calculator. I have read other reviews for other HP calculators where the stack can be much larger. The numbers push to the bottom of the stack as you enter new numbers, and as you enter them, the “bottom” of the stack actually moves “up” on the display. It makes it difficult to discuss how it implements this data structure because the numbers scroll in the opposite direction. The theory goes that you “push” data to the top of the stack, and you “pop” data off the top of the stack. This is a LIFO data structure (LIFO = “last in, first out”). To see the HP25s implementation, you apparently “push” data to the bottom of the stack, numbers “above” it move upward, and then you “pop” data off the bottom of the stack. It actually amounts to the same thing in the end. It is still a LIFO data structure. Pushing a fifth number on to the stack will cause the first number to disappear, so you can only work with four numbers at a time.

So, let’s say that you have the following stack:

a: 8
b: 7
c: 6
d: 5

The last two numbers entered are the numbers “6” and “5” in memory locations “c” and “d” respectively. Operations will be done on the last two numbers entered. So, if I now press the operator “+”, it will add 6 to 5 and pop both of these numbers off of the stack.

a: 0 (empty)
b: 8
c: 7
d: 11

The stack rotates down, the “bottom” (location “a”) of the stack becomes empty, and the “11”, the result of the calculation replaces both 6 and 5.

Some operators are unary, so pressing the square root will perform an operation on only the last number (location “d”), and replace the result back into location “d”, eliminating the number 11.

a: 0 (empty)
b: 8
c: 7
d: 3.31662479036

Well, there is also the programmability of the calculator. There are many commands available, and one pet peeve is how you are only allowed to assign a single letter to name a program.

Latex editors: a comparison

If you are using Lyx or Texmacs, this book is still an absolute must. It is THE bible for this language.

Latex is a math typesetting markup language which has been around for about 30 years. It is about as old as HTML, and runs on pretty much any kind of computer that can support a Latex compiler. I have written many term papers in it, and continue to use it to write documents. Its best feature is its ability to handle mathematical and scientific notation. It is also the official typesetting language of the American Mathematical Society. A Stanford professor named Dr. Donald Knuth invented a lower-level markup language called Tex as far back as 1976, and Latex, designed in 1985 by Leslie Lamport, was and is just a bunch of Tex macros, sophisticated enough in itself to amount to a higher-level language. You can edit complete documents and even entire books with only a background in Latex. Latex is therefore robust enough that that is all I ever use for math and science documents.

Latex documents are known for their distinctive roman font, and its clean presentation of even the most complicated formulae. The WordPress editor used in making this blog article can show formulae using the distinctive Latex fonts: m = \frac{m_0}{\sqrt{1-\frac{v^2}{c^2}}} is the way Einstein’s relative mass formula is presented on my editor. This is identical to how it would appear in a Latex paper document. Unfortunately, this editor only displays inline math, so I can’t show you how it would display “presentation-style” math, where the fonts would be larger.

Over the decades, there have been editors in existence that mimic Latex in presentation of fonts and formulae. Two that I have encountered are Lyx and Texmacs.

Both Lyx and Texmacs try to distance themselves from being just WYSIWYG wrappers for the Tex/Latex language. While the metafonts displayed are the distinctive fonts known to exist in Latex are those displayed by default in these editors, saving the files saves to the format native to these separate editors. If you want Latex, you have to export your work into Latex format.

Examples of output from Texmacs. Not bad for math, (especially if you know the Latex math codes) but not so easy to use when not in math mode.

First I’ll discuss Texmacs, since my experience with it is the most recent. I discovered Texmacs by surprise when browsing through my Cygwin menus on my laptop. While one would think that going by the name, Texmacs must have some combination of Tex and Emacs, it has dependence on neither. The editor has no resemblance to Emacs (neither in the user interface nor the keystrokes), and a selection of document options appear on the toolbar and in the menus that appear to be in line with Latex document and font options. Texmacs produces its own Texmacs code by default, and while Latex can be exported, the document in Latex may not end up looking the same. I have found that many font changes were lost, for instance.

For one who has worked with Latex for close to 30 years, I can say that nearly all of the resemblance to Latex as well as its ease of use lie in the editor’s use of math commands, although there is more dependence on the GUI. One finds that you can’t enter “\frac{3}{4}” to get \frac{3}{4}, but there is a Texmacs icon you can click that handles that.  Its weakness lay in its handling of the rest of the document. Tables were not well implemented. It appears incapable of inserting gridlines forming the borders for the table cells, for instance, even though the command for it appears to be there in the GUI. I found I needed to export the Latex code, bail out of Texmacs and edit the Latex code directly in a text editor. Another drawback of Texmacs is that while the icons cover nearly anything you would like to do in math, the fact remains that your choices of math expressions are largely limited to the buttons provided. If you are going to do something more complicated, you are going to find reason to edit the Latex code directly by hand again in a text editor. And once you do, importing the *.tex file back into Texmacs to continue editing will not guarantee that your new Latex code will be understood the way you want it. One thing that Texmacs does rather well is change fonts. Latex/Tex has ways of changing fonts internal to its language, but you are limited to only a small number of standard Tex fonts, unless you know your way around the preamble, or header part of the code. Texmacs leaves you more open to alternative installed fonts, allowing you to take advantage of the diversity of Tex fonts of which there are hundreds, created over the last 10 or more years. In fact Texmacs is the only way I know of to take advantage of alternative fonts outside of the Roman/Helvetica/monospace fonts that are at the core of Tex in a way that is even remotely as easy as a word processor. Texmacs documents will have a Latex look and feel, with greater flexibility in font choices, but as said earlier, all this is great as long as you are sticking largely to simple math or math in the toolbars, or as long as you avoid typesetting constructs outside of the math markup, such as tables.

An older version of the Lyx editor.

Lyx is, I believe a much older editor. It claims to use Latex for its typesetting, but my experience with it (although admittedly years ago) was that for serious math applications, you have to export Latex code and edit it by hand if you want to get what you want. Make sure you have Leslie Lamport’s Latex book beside you at the time. After decades of working on and off with Latex, I can never completely get the language and all its nuances in my head, and need the constant assistance of Lamport’s Latex book at my side. This also ends up being the case for Texmacs, since even basic formatting has to be changed under that editor.

In the end, these editors can save a lot of time to get the basic look and feel down for your document, but in the end you need to, at some point, hunker down and edit Latex code directly, using a text editor. I use vi, where I constantly need to bail out and compile the code and run xdvi on the compiled *.dvi file to see what it looks like and what Latex code I need to tweak next.

Both Texmacs and Lyx are on the GPL.
Texmacs source code:
Lyx source code:

Eterm on Windowmaker

This is Eterm, running under X-Windows in Cygwin. The root desktop image is an image of an Emacs Quick Reference, made for the desktop. Nice reason to have a transparency feature on a terminal window.
This is Eterm, running under X-Windows in Cygwin. The root desktop image is an image of an Emacs Quick Reference, made for the desktop. Nice reason to have a transparency feature on a terminal window.

There is always something to have to consider when bringing an app into Cygwin that is not part of the Cygwin distro. I wish to make note of this here in case anyone else has this problem.

Modern window managers are configurable, but only through windows and dialogs. I prefer to configure a bit closer to the metal, so I prefer to edit scripts. The chosen X-window manager was WindowMaker, which is somewhat “modern” while still being nicely configurable, through scripts you can edit under ~/GNUstep/Library/WindowMaker along with graphics files for things such as background images and border tiles. It was nice that WindowMaker still comes with Cygwin, along with FVWM2, another favourite window manager of mine.

I noticed that Cygwin lacked a transparent terminal. You might be thinking that I forgot “mintty”, but I didn’t, since it actually runs as a process directly under Windows, not under Cygwin. Even if I execute mintty from an xterm, the terminal that comes up is not a child of X-Windows, it is a child of MS-Windows, and thus cannot be managed under X-windows.

So, Eterm at first could not compile under Cygwin, and for hours I was racking my brain as to what the problem might be, and looking through the output of the command “configure --help“, I found what solved my problem. What seemed to stop compilation were references to “utmp” and associated header files. The configure script allowed for compilation without utmp support. Utmp is used for access to system logs. This was considered not a big deal in Cygwin, since MS-Windows still has such logs. So my configure command for Eterm was:

./configure --enable-trans=yes --enable-utmp=no

From then I was able to successfully compile Eterm with the eye candy that one associates with the Enlightenment window manager, but under WindowMaker.

Mathematica: Piecewise functions and shortcuts

I work with piecewise functions a lot in the courses I teach, and sometimes to do a quick reality check I would enter a piecewise function on Mathematica. Mathematica (the old version 5 I have) can do piecewise functions by declaring a function beginning with a replaceable parameter:


After this, I press <ESC>pw<ESC><CTRL+ENTER> and I get:

piece_startwith four placeholders for math expressions and their restrictions, which can be added by pressing CTRL+ENTER. I can add more by pressing CTRL+ENTER again. If I want an exponent, I type the base, then CTRL+6 then my exponent. Mathematica 5 makes it only partially clear what keyboard shortcuts to use for math expressions so that you don’t have to go to the pallette each time, but they are there.

Also the hints are not always there if you glide your mouse on the palette, so you will need to look for “keyboard shortcuts” in the documentation.

Here is a table of some shortcuts you might frequently use:

Character Keypress Comments
x3 Ctrl+6 Superscript or exponent
Ctrl+/ Fraction
square root Ctrl+2
x3 Ctrl+_ Subscript
Ctrl+Spacebar Moves cursor out of a formula by 1 level
Ctrl+Enter Adds another matrix row or creates a 2×2 if one does not exist
α ESC+a+ESC Greek alpha
β ESC+b+ESC Greek beta
π ESC+pi+ESC Greek pi
ESC+\infty+ESC One of many TEX-style ways of getting special characters
Δ ESC+D+ESC Greek capital delta

The World Wide Web, as it once was seen
Tim-Berners-Lee’s 1989 vision of the World-Wide Web, as seen through a green-screen terminal such as a Cybernex XL-87.

You can see the first version of the World-Wide Web at the CERN website. They simulate the experience as if you were looking at the pages through a green-screen terminal such as one of the old Cybernex XL87s. Illustrated is part of a screenshot, but clicking on the graphic will actually bring you there.

CERN is a research facility in Europe having more to do with physics than with computers. They set up web pages back then to communicate with other physicists and provide links to their graphics files, which they had to download and view some other way, often through an 8-bit color screen if they had one available. In the late 1980s, graphical user interfaces (GUIs) were just emerging, with the first X-Windows installations available on university machines such as a Sun Microsystems computer. Apple soon came up with the first GUI for mass market, soon followed by Microsoft Windows.

In those days, the World-Wide Web ran alongside Gopher, which also ran on a text-based terminal. Gopher is pretty dead these days, having been bested by the promise of the hypertext protocol. What passed for search engines were called Archie, Jughead and Veronica. Archie was an FTP search service, while Jughead did searches within a single server. Veronica allowed you to search nearly any link available on the Gopher network.

And what was Gopher? Gopher was a text-only system of what can be best called links, which led to text documents, binary files, or other resources.

WAIS, the Wide-Area Information Servers, were also available and allowed for text searches for widely distributed documents on many servers, similar to Gopher and Veronica. All of these protocols gave way to HTTP and the world-wide web in the early 1990s.

YALD (yet another linux distro) Knoppix 7.4.2

Linux Pro Magazine, featuring GIMP in its Winter 2015 Edition.

To add to the distros I have already reviewed in terms of their suitability for running on the Hewlett-Packard TX2 or TM2 tablets, I had not said anything about the Knoppix distribution specifically. I saw one sold in a special edition of Linux Pro Magazine, and in a fit of irrational impulse purchasing, ponied up my 20 bucks with tax, and tried it on my laptop.

Linux Pro Magazine was using the Knoppix CD to actually showcase GIMP, but with pretty close to the most recent versions of GIMP installed on all my windows and Linux installations (I do run a blog after all), I do not need to be sold on GIMP. It’s a great free open-source package for editing and manipulating photos, in the way of Photoshop. It would have been nice if they could have an article on how to write your own scripts for the script-fu feature in GIMP. This ever elusive and mysterious feature remains largely shrouded in secrecy except for the few websites to post a page or so on it.

But I wanted to see how the latest Knoppix ran on my laptop. Indeed, version 7.4.2 of Knoppix is the latest version, according to the website. Knoppix is the Linux distribution that is known for having a live operating system on it, so if you want to try Knoppix, there is no installation needed. My HP TM2, in the grand tradition of “modern” computers having fewer and fewer media inputs than ever before, comes without a built-in DVD-R drive. So, I plugged a USB2 one in (the TX2 has no USB3 inputs, not that it would matter for a DVD-R anyway) and booted into Knoppix.

And I was pleasantly surprised to find that just about everything seemed to work. It recognized my wi-fi, and I found I could use pen, mouse, and screen touch without any lag. I was able to see and hear videos on YouTube. And of course, GIMP ran. On a live DVD, GIMP took about 40 seconds to start (starting from an installation on my hard disk on my PC took under 5 seconds in Ubuntu Studio).

Back to Knoppix. As expected, the screen rotation key is not mapped. However, I can see no Linux program that does this. Postings to many fora on the topic go unanswered. There was one discussion on rotation with the Nvidia chipset, but the TM2 uses Intel for video, so I was out of luck. Since I need to rotate the screen frequently in my work, this has been the one limitation that has stopped me from using Linux on my laptops.

BASH prompts: Box-drawing characters

An xterm session with BASH prompts containing box-drawing characters. The rest of the screen is the output of repeated fortune commands.

I used to be a big user of xterm’s box drawing characters. I hadn’t been aware that they could be used in prompts.

But I recently heard a (probably dated) discussion on how box drawing characters could be used in a command prompt.

I think that’s a great idea, however, the big problem I found was to do it in a way that correctly turn off the drawing so that you could display text again. Otherwise a lot of text ends up looking garbled.

First, let me say that I used a “twtty” example code at Giles Orr’s BASH prompt website which I modified to allow actual box prompts. A clue was provided in the HOWTO here, where they showed, in a very brief way, the entire “catalogue” of “high-bit” ANSI characters, which I pasted into an xterm:

echo -e "�33(0abcdefghijklmnopqrstuvwxyz�33(B"

The high-bit characters are whatever you type in lowercase after you output the ANSI escape sequence “�33(0“, I needed the echo command (echo -e) to get that to work. The output of echo -e can be stored in a string like this:

local box1=`echo -e "�33(0qqqqqqqqqqqqqqqq�33(B"

�33(0 turns on ANSI escapes, while �33(B turns it off. The string “qqqq”… are the characters used to draw a horizontal line. There were some other tweaks I did to his code to become more complete in box characters for a two-line prompt, but it had the side effect of not going all the way across the screen like the original. Adding six characters fixed it, albeit in a kludgy kind of way:

ESC_IN=`echo -e "�33(0"`  # turn on box-drawing
ESC_OUT=`echo -e "�33(B"` # turn off box-drawing

function prompt_command {
    #   Find the width of the prompt:

    #   Add all the accessories below ...
    local l="${ESC_IN}l${ESC_OUT}"
    local m="${ESC_IN}m${ESC_OUT}"
    local temp="${l}-(${usernam}@${hostnam}:${cur_tty})---(${PWD})--"

    let fillsize=${TERMWIDTH}-${#temp}+6

What I mean by “kludgy” is that I simply added a “6” on the last line above which controls the number of characters required for the first line of the prompt to go across the screen. It’s unlikely that the terminal width will ever need to be less than 6.

I added two variables which are occasionally useful: $ESC_IN for turning on the ANSI feature, and $ESC_OUT for turning it off. Inside the function prompt_command, I added variables $l and $m since his code uses dashes and I wanted the ANSI horizontal lines instead. $l is for the ANSI output for the letter “l”; while $m is for the letter “m” in ANSI. These generate two corners of the box which occur on the far left of the prompt. And they do join up. The $l is used in the next statement below in the form of ${l} to begin making the string $temp. I could have done something with the dashes in this string such as use “${ESC_IN}qqq${ESC_OUT}” in place of “—“, but there were problems if I was too overzealous, so some dashes were left as is.

The main problem was to get a horizontal line in place of the string “——————————————————” which went on indefinitely. Those were replaced by lowercase “q” letters without the ANSI escapes. These were better placed in a statement nearby:

if [ "$fillsize" -gt "0" ]
    #   It's theoretically possible someone could need more 
    #   dashes than above, but very unlikely!  HOWTO users, 
    #   the above should be ONE LINE, it may not cut and
    #   paste properly

where $ESC_IN and $ESC_OUT were used in the next statement below the comments. You can’t put them inside the first $fill assignment, because the second assignment cuts off the end including $ESC_OUT should you attempt to do it that way.