• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

Using up and down arrow key in shell

nimzov

Unregistered
Joined
Apr 12, 2004
Messages
954
In Ubuntu 10.04, I have open a terminal window and started a program shell called mongodb.

Now when I use the arrow key to use the command history, I get this printed on the screen instead of the previous commands :

^[[A for the up key and

^[[B for the down key.

In other windows like the one for python or the terminal window, the command history works correctly with the arrow keys.

Some shell works ok with the arrow keys, other don't. Any idea, what causes this behaviour.

Thanks
 
Those are the actual keycodes for the arrow keys. It means that mongodb doesn't recognize the arrow keys for history.
 
Allegedly it does, not that I'd know firsthand.

The sequences that you see are VT100 escape sequences associated with those keys. The first thing I'd recommend is that you try Ctrl-P ("previous") for up and Ctrl-N ("next") for down and see if those work. Those are the emacs editing keys that the link refers to, and they might be enough for your needs.

If you really need the arrow keys to work, here are the gory details:

Creating your MongoDB shell window starts with creating the terminal window. The terminal window program has some options to control how arrow keys are handled. The terminal window might run the MongoDB shell directly (the simple case) or it might run a Unix shell that runs some setup commands and then runs the MongoDB shell. The setup commands might also affect how arrow keys are handled. So to diagnose this you would have to disable the later steps in the process, then gradually add them back, until you find the point at which arrow keys stop working as arrow keys. It takes time and possibly some on-site help from someone with enough Unix experience to have done this before.
 
Last edited:
Thanks for the info.

I will access mangodb through iPython.

This will solve my problems.
 

Back
Top Bottom