Harry Seldon's blog

Fractals, Chaos, and Control Systems on Rails


How to have home and end keys working in xterm and in the Matlab command line.

Posted by Harry Seldon on August 08, 2009

My home, end and delete keys were not working in my unix terminal (xterm) or in my Matlab console. For instance in the Matlab console (Matlab run in –nodesktop mode), all I was getting after pressing the home or end key was 4~ or 5~, same was going on for the terminal (xterm and csh). As most shells recognize the ctrl+a, ctrl+e, ctr+d shortcuts for home (beginning of line), end (end of line) and delete and as Matlab too recognizes these shortcuts, the simplest solution is to have your keys sending these shortcuts when in a terminal. You probably do not want to completely reconfigure your keys as they might be working fine in text editors.

To configure your keys simply add this to your /home/user/.Xdefaults file:

*VT100*Translations:       #override  \
  <Key>Home: string(0x01)\n\
  <Key>End:  string(0x05)\n\
  <Key>BackSpace: string(0x08)\n\
  <Key>Delete:   string(0x04)\n\
  ~@Num_Lock<Key>KP_Home:      string(0x01)\n\
  ~@Num_Lock<Key>KP_End:       string(0x05)

“string(0x01)” means to send the code 0x01 which is the ASCII code for ctrl+a. “string(0x02)” would mean ctrl+b, “string(0x05)” indeed means ctrl+e etc.
A list of ASCII control code can be found here : http://www.phanderson.com/C/ascii.html
(Btw, If someone can explain me why the fist ASCII code is ctrl+a and not simply a I would be impressed).

How to test the configuration
To load the .Xdefaults file enter:

xrdb -merge ~/.Xdefaults

To check the state of your X configuration:

xrdb -query

To test your configuration, it is also often useful to check which code a key sends. To do this, in a terminal, just press ctrl+v then press the key. The code sent by the key should appear, for instance ^a (=ctrl+a) if you pressed the home key or directly ctrl+a.
[Edit] Also it is important that you know which terminal and shell you are using. To know this:

echo $SHELL
echo $TERM

As a bonus here are a few more configurations:
To be able to use page up, page down to scroll in xterm:

*VT100*Translations:       #override  \
  <Key>Prior: scroll-back(1,halfpage) \n\
  <Key>Next: scroll-forw(1,halfpage)

To be able to use the wheel mouse to scroll in xterm:

*VT100*Translations:       #override  \
  <Btn4Down>,<Btn4Up>: scroll-back(1,halfpage) \n\
  <Btn5Down>,<Btn5Up>: scroll-forw(1,halfpage)

To configure your function keys for often used commands:

*VT100*Translations:       #override  \
  <Key>F1: string("ls") string(0x0d) \n\
  <Key>F2: string("ll") string(0x0d) \n\
  <Key>F3: string("ps") string(0x0d) \n\
  Shift<Key>F1: string("ls -lg") string(0x0d) \n\
  Shift<Key>F2: string("pwd") string(0x0d) \n\
  Shift<Key>F3: string("ps -ax") string(0x0d) 

Notice that 0x0d is nothing else than the ASCII code of carriage return.

To get autocompletion thanks to your history in the command line. That is you press a few characters then you press up and it will complete the line with the last command with the same beginning in your history. With this, it is useful to have a long history and the same history file for all your opened terminals.
If you use tcsh, put this in your ~/.cshrc file:

# 5000 last commands are saved
set   history = 5000
# All terminals merge their history in one file 
set   savehist=(5000 merge)
if ( $?tcsh ) then
       bindkey -k up history-search-backward
       bindkey -k down history-search-forward
       # inser to backward-delete-word       
       bindkey ^[[2~ backward-delete-word 
       # Prompt with the current path
       set prompt="%~>"

“if ( $?tcsh )” checks that the current shell is tcsh.

If you use bash add this in ~/.bashrc (or /etc/inputrc):

# up & down arrow keys

\e means escape key. Escape key also sometimes appear as ^[. So if you press ctrl+v then up arrow you will get ^[[A.

Notice that once you have correctly set up the home, end keys and the up, down keys for history you will have the same configuration between xterm and Matlab.

All this should pretty much work under UNIX or LINUX. However, with all the configurations around (Linux,Unix,HP-UX,Unix through exceed/csh tcsh/gnome,KDE,CDE,etc.) a few things might not work in your configuration. So good luck!

Posted in | 6 comments | Tags , , , , , , , , , , | atom

Checking Chrome on Linux

Posted by Harry Seldon on August 06, 2009


Chrome for Linux has recently been released in an unstable version. As I have been looking forward to it for a year now, I cannot wait more. So I am going to have a look at that beta version (

In case you wonder, I am OK with Firefox but not completely satisfied. Mainly for the reason that sometimes when an applet on a website crashes it just crashes all Firefox. I am not counting the number of times I have had to reboot FF. Yes it might be also due to flash on 64 bits. But even though, the whole internet experience on Linux 64 bits is just not amazing. So from the beginning I was curious to see what Google could bring in.

Get chrome (unstable) for Linux.

This test cannot be very thorough for the main reason that Chrome For Linux does not support Flash yet.
[Edit] Thx to Ben. Flash is not activated out of the box. However, you can activate it fairly easily. See the paragraph about Flash below.

Chrome is supposed to make the net “faster, safer, easier”. Let’s see.

There is definitely a feeling of fastness. Pages load smoothly and rapidly. There is no freeze (unlike in my FF) which is appreciable. However, when I used a beta version of FF without plugins* and without flash support, I also had this impression. So future will tell if it keeps being fast when loaded with plugins.

The incognito window is pretty useful when you want to look for things that can become nasty for instance “chrome 64 bits beta”. However, as told by Chrome, there is no such window where you could surf anonymously on the web.

Here is what Chrome says when you open an incognito window:
You’ve gone incognito. Pages you view in this window won’t appear in your browser history or search history, and they won’t leave other traces, like cookies, on your computer after you close the incognito window. Any files you download or bookmarks you create will be preserved, however.

Going incognito doesn’t affect the behavior of other people, servers, or software. Be wary of: Websites that collect or share information about you

  • Internet service providers or employers that track the pages you visit
  • Malicious software that tracks your keystrokes in exchange for free smileys
  • Surveillance by secret agents
  • People standing behind you

By the way I do not want to sound paranoid but by “Surveillance by secret agents” is Google telling us that they are forced to spy on us by some intelligence agency ? Or is it just humor ?

The interface is indeed pretty simple. No menu bar, only contextual menus and 2 buttons on the right of the address bar that display an edit and history menu. Incognito mode is simply launched by pressing maj+ctrl+n or by using the history button.
[Edit] One simple thing I love is that when you open a link “in a new tab” the new tab is just on the right of the tab you were in, unlike on Firefox where the new tab is on the far right of your tabs. This has been feeding up me for a while.

Yet we’ll judge about easiness when it will come to look for and to integrate plugins.

About bugs
On the bad side, this website is not well displayed. For some reason the images in the articles appear completely distorted. I hope this will be quickly corrected. I will need to check if the same happens on Chrome on Windows.

About Flash
To activate Flash you need to do the following (thx to Ben and Linux archive):

$ sudo mkdir /opt/google/chrome/plugins
$ cd /opt/google/chrome/plugins
$ sudo ln -s /usr/lib/adobe-flashplugin/libflashplayer.so libflashplayer.so
$ cd /opt/google/chrome/
$ google-chrome --enable-plugins

You might not need the 3 first steps. Try first to launch chrome with the option --enable-plugins to see if it works. Also, your directory with the flash plugin might be different. Mine was in “/usr/lib/flashplugin-installer”.

I have tested flash on Google analytics and on YouTube (2 Google sites btw but it was not on purpose). It worked well and without crash.

* I am using google toolbar and webdevelopper plugins

Posted in | 3 comments | Tags , , | atom

Migration to KDE4, nvidia, show desktop, quicklaunch, and multiline taskbar

Posted by Harry Seldon on November 19, 2008

With the migration to Intrepid, I got KDE4. The first impression is ‘wow it is shiny’ ! The second impression is ‘does it work’ (it was not) ? The third impression, once it works, is ‘how does it work’?

I got this second impression because everything was very slow. So I was strongly doubting everything was nominal. Indeed, I was having troubles with the nvidia configuration for KDE4. The one line answer to solve the problem is:

nvidia-settings -a InitialPixmapPlacement=2 -a GlyphCache=1

The full solution can be found here. Thanks to him.

Then it was finally working but I quickly understood that I did not know how it was supposed to work. I was lost. I did not know how to get new ‘plasmoids’. I did not understand why I had lost my ‘show desktop’ icon or why I had lost my quicklaunch icons. So first I wanted to have these back. Here is how.

First you need to know that all these features are now “plasmoids”. KDE4 seems to be powered by a soft called Plasma. Therefore, the widgets for plasma are called plasmoids. OK that is logical. To install a new plasmoid you click the taskbar and you click ‘add plasmoid’, simple enough. Then you need to know which plasmoid you are looking for and where to look for, it is a little harder.

The show desktop feature can be activated using the plasmoid ‘show desktop’. It is simple if you have it in the options which was not my cause. So for info, make a sudo apt-get install plasmoid* or sudo apt-get install kubuntu-desktop and then you will have it in your menu.

For the quicklaunch feature you need the plamoid quicklauncher available on kde-look at this place.

I am still missing a few things :

Overall, I really like KDE4 but I am looking forward to having it more practical and professional. Currently, it reminds me when I played around with OS/2 Warp some 15 years ago. It was shiny and full of good ideas but some basic things were missing (like a practical file manager).

What do you think of KDE4? What are your preferred plasmoids?

Posted in | 6 comments | Tags , , , | atom

Kubuntu migration from Hardy to Intrepid : a piece of cake (or not)

Posted by Harry Seldon on November 19, 2008

In life there are things that change and things that do not change. Linux is an always changing and evolving thing. However, the fact that after each migration I lose my wifi connection is something that does not change. But now I am used to it, so before the migration I pulled my ethernet wire to be ready and happy! Let us see how this migration from Ubuntu 8.04 (Hardy Heron) to Ubuntu 8.10 (Intrepid Ibex) went.

I told you about the wifi but it was not exactly the most surprising thing. First when I wanted to migrate using adept manager it appeared that adept did not want to propose me the migration. So after updating, I forced it:

sudo adept_manager --dist-upgrade

But then after a few seconds, I got an error message saying the following:

Could not calculate the upgrade
A unresolvable problem occurred while calculating the upgrade.
This can be caused by:
* Upgrading to a pre-release version of Ubuntu
* Running the current pre-release version of Ubuntu
* Unofficial software packages not provided by Ubuntu
If none of this applies, then please report this bug against the 'update-manager' package and include the files in /var/log/dist-upgrade/ in the bugreport.

I learnt that way I was running the development version of Hardy. This was due to the fact I had activated the backports at some point to get a file that could help solving my wifi troubles. In fact, I did not only get this file but probably updated all my distro to the dev level. Since then I had desactivated the backports but too late.

Finally, I chose to persist in the mistake (diabolicum est). I activated back the backports and launched again the migration and this time it worked. Bonus is I was glad to solve an “unresolvable problem”!

Hum, it almost worked to be accurate. Indeed after the reboot I got the infamous black screen with the white cursor at the top left corner. Thing is I was not that surprised because I had already got plenty of troubles with my nvidia video drivers. So I thought about an xorg problem. It was not only that.

I ran the safe mode and ran the dpkg option. First time, it made some things then I got an error. OK, I rebooted and did it again, same thing, it did some new things and then crashed. OK, I am patient, I do it again. This time it worked. I was finally able to boot my PC and I met KDE4. I knew KDE4 was around. However, I had thought I would have the choice between KDE3.5 and KDE4. I did not. OK, let’s go for this long awaited KDE4. Let me tell you straight I should have waited for longer, it is promising but not ready yet.

Let’s finish the migration before speaking about KDE4. After finally getting to the desktop, I quickly realized the internet connection was not working, not only the wireless connection which I expected but also the ethernet connection. The weird thing is the wifi connection seemed to work because all the usual parameters were green (access point, IP adress etc.) but I had no internet. Anyway, I finally got the ethernet connection working when I shut down the wireless connection.

With the internet connection I could at last fight the other [problems I had due to KDE4] (See next post).
Before going to the next post, I’d like to thank the guys at ubuntu-fr who answered my questions during this migration.

How was your migration?

PS Here is the error message in French for guys who would like to google it.

Impossible d'évaluer les mises à jour nécessaires   
Un problème insoluble est survenu lors de la préparation de la mise à niveau.   
 Ceci peut être dû à :  
 *la mise à niveau vers une version de développement d'Ubuntu ;   
 * la version de développement d'Ubuntu est actuellement utilisée;   
 * des paquets logiciels non officiels, non fournis par Ubuntu.  
 Si rien de ceci fonctionne veuillez signaler ceci comme un bogue du paquet "update-manager" et inclure les fichiers présents dans /var/log/dist-upgrade dans votre rapport de bogue.     

Posted in | no comments | Tags , , , | atom

Some useful commands in Linux administration when making a website.

Posted by Harry Seldon on September 27, 2008

This is a cheatsheet of useful commands in Linux administration when making a website in Rails. I am using these commands over and over again so I thought it might help someone.


Detailed list of files:

    ls -l 

List the running processes:

    ps -e  

Create a directory:

    mkdir demo 

Kill the use of a specific port (I use it when Aptana/RadRails crashes and do not close the port):

    fuser -k 3005/tcp  

Delete a directory and subdirectories, without confirmation, verbose mode. (BE CAUTIOUS !):

    rm demo/ -r -f -v  

Add a cron jon:

    crontab cron_job.txt 

List cron jobs:

    crontab -l 

Create cron job:

    crontab -e 

Mount a local virtual directory for an actual remote directory:

    sshfs ‘-oworkaround-rename’ username@ssh.domain.com: /home/username/remote/ 


Connect to mysql local server:

    mysql -u username -p 

Connect to mysql remote server:

    mysql -u username -h mysql.domain.com -p 

Create databases (Rails style):

    CREATE DATABASE demo_development; 
    CREATE DATABASE demo_test; 
    CREATE DATABASE demo_production; 


Create a rails app:

    rails demo  

Install a plugin:

    script/plugin install git://github.com/pullmonkey/open_flash_chart.git 

Install a plugin, force reinstall:

    script/plugin install git://github.com/pullmonkey/open_flash_chart.git –force 

Launch server on a specified port:

    script/server -p 3005  

Open a console where you can send ruby commands to your app (Extremely useful!) in dev mode:

    script/console development

Open a console where you can send ruby commands to your app (Extremely useful!) in prod mode (BE CAUTIOUS !):

    script/console production

Migrate the database:

    rake db:migrate 

Migrate the database to a given version:

    rake db:migrate VERSION-22 

Migrate the production database:

    rake db:migrate RAILS_ENV-production 

Install gem:

    gem install RedCloth 

Install a given version of Rails:

    gem install -v-2.0.2 rails  


Checkout a repo (svn meaning):

    git clone git://github.com/pullmonkey/open_flash_chart.git   

Get the differences:

    git diff 

Fetch from and merge with another repository or a local branch:

    git pull 


    git checkout 

Create a branch:

    git branch mybranch 

Configure the user settings:

    git config –global user.name "toto" 
    git config –global user.email "toto@example.com"  

Posted in | 2 comments | Tags , , , , , | atom

2 tricks for Firefox, 1 for KDE

Posted by Harry Seldon on August 22, 2008

I noticed these nice firefox 3 features haphazardly :
On the tab bar : 
you can duplicate a tab thanks to a ctrl+click
you can move the tabs left or right using your mouse scrolling button

By the way, one thing I do not understand for Firefox is why open new tab does not open your start page ?

1 trick for KDE
Right click on a window name bar and you have the option to keep the window above others. That is nice to do some copy/paste from one page to a notepad or also to keep the command line while typing code in an IDE….

Posted in | no comments | Tags , | atom



Recent Comments

Recent Posts


actuators aircraft atc blog chaos chaos_theory charts control controllers controls crisis economy finance flight fractals git gnc gs guidance linux mandelbrot marketing navigation ns ofc on pilot rails ruby sas scs sensors statistics systems techcrunch thinkosphere tutorial typo ubuntu wifi