IPython: How to wipe IPython's history selectively & securely?

History is store on $(ipython locate)/profile_default/history.sqlite by default. You can remove the file, and or do any operation you want on it (secure erase, etc..). It's an sqlite file so you can load it with any sqlite program and do query on it.

Check in $(ipython locate)/profile_default/ and other $(ipython locate)/profile_xxx that you do not have any other history files. $(ipython locate) is usually ~/.ipython/ but can vary:

ls $(ipython locate)/profile_*/*.sqlite

One solution would be:

sqlite ~/.ipython/profile_default/history.sqlite

delete from history where source like '%password =%';

Combining @Ovidiu Ghinet's answer with @Matt's accepted answer:

sqlite $(ipython locate)/profile_*/*.sqlite || sqlite3 $(ipython locate)/profile_*/*.sqlite

Then from within sqlite console:

delete from history where source like '%password%';
select * from history; /* confirm that no passwords left        */
.quit                  /* forgot how to exit sqlite console? ;) */