Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python 2.7 with mac osx lion: fn + delete and control + r

The sequences control+r and fn+delete that used to do recursive search / delete the following character do not work anymore in python 2.7 / Mac OSX Lion. Instead, a ~ appears each time I use fn+delete. I am using readline for tab completion (which also had to be changed according to python tab completion Mac OSX 10.7 (Lion)). Any ideas how to fix it?

Thanks, Bruno

like image 806
Bruno Lenzi Avatar asked Jan 16 '12 17:01

Bruno Lenzi


2 Answers

According to http://pypi.python.org/pypi/readline:

"Mac OS X, do not ship with GNU readline installed. The readline extension module in the standard library of Mac "system" Python uses NetBSD's editline (libedit) library instead, which is a readline replacement with a less restrictive software license."

So, you can install it with the command:

sudo easy_install readline

Else, you can use tcsh shortcuts; control + d to delete the following character and Ecp + p for history search.

like image 184
Faruk Sahin Avatar answered Nov 18 '22 09:11

Faruk Sahin


For recursive search you can configure libedit by adding following line to ~/.editrc

bind ^R em-inc-search-prev

or right from your .pystartup file

readline.parse_and_bind("bind ^R em-inc-search-prev")
like image 36
Sasha P. Avatar answered Nov 18 '22 10:11

Sasha P.