Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using ipython

Inside the python shell, when I press up instead of showing the last command, it prints

^[[A

also CTRL-[keys] are fubar. CTRL-p prints

^P

Everything is normal under terminal\bash

My guess is that it is an encoding problem. I'd like to either enable the full encoding in ipython or changer the encoding of the shell which runs ipython.

Or any other helpful information is welcome

share|improve this question

2 Answers 2

Everything is normal under Bash, because Bash uses the readline library to provide command-line editting. Your Python shell probably doesn't. See this blog post for a solution to your problem: http://www.razorvine.net/blog/user/irmen/article/2004-11-22/17

share|improve this answer
    
-1: Doesn't really answer the question. Link isn't viewable without cookies. (Consider including the relevant information from the link here.) –  Thanatos Apr 17 at 20:40

For me, I needed to create ~/.inputrc, and fill it with my preferences. For me, this is:

set editing-mode emacs
"\e[1;5C": forward-word
"\e[1;5D": backward-word

The \e[1;5C, for me, is the sequence that means Ctrl+. Yours is likely the same, but you can figure it out in bash by typing: Ctrl+V, Ctrl+. For me, this shows, ^[[1;5C, and you need to know that ^[ means "escape", which is the \e above. The rest ([1;5C) is just literal, copy it. forward-word is the command to execute on this key sequence, i.e., I want my Ctrl+arrows to skip words.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.