I was using the below pystartup script in linux to make history and autocompletion on tab available in REPL Python. I have switched to OSX and I have modified the script such that tab completion works. But I am not able to figure out how to make the search work? Search couple of SO questions like Python interactive mode history and arrow keys
But I don't want to uninstall the python version that comes with OSX as it may lead to some other dependency breakages.
My python version is 2.7.10
Script
import atexit
import os
import readline
import rlcompleter
historyPath = os.path.expanduser("~/.pyhistory")
def save_history(historyPath=historyPath):
import readline
readline.write_history_file(historyPath)
if os.path.exists(historyPath):
readline.read_history_file(historyPath)
if 'libedit' in readline.__doc__:
readline.parse_and_bind("bind ^I rl_complete")
else:
readline.parse_and_bind("tab: complete")
readline.set_history_length(1000)
atexit.register(readline.write_history_file, historyPath)
atexit.register(save_history)
del os, atexit, readline, rlcompleter, save_history, historyPath