Question: 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

Answer: 
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.
This worked for me (using OSX and pyenv):

```
CFLAGS="-I$(brew --prefix readline)/include -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" \
LDFLAGS="-L$(brew --prefix readline)/lib -L$(brew --prefix openssl)/lib" \
PYTHON_CONFIGURE_OPTS=--enable-unicode=ucs2 \
pyenv install -v 2.7.11

```

Source: <https://medium.com/@pimterry/setting-up-pyenv-on-os-x-with-homebrew-56c7541fd331#.urbdkrc9l>