Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable IPython Exit Confirmation

Tags:

python

ipython

It's really irritating that every time I type exit(), I get prompted with a confirmation to exit; of course I want to exit! Otherwise, I would not have written exit()!!!

Is there a way to override IPython's default behaviour to make it exit without a prompt?

like image 566
Naftuli Kay Avatar asked Oct 01 '22 08:10

Naftuli Kay


2 Answers

If you also want Ctrl-D to exit without confirmation, in IPython 0.11, add c.TerminalInteractiveShell.confirm_exit = False to your config file *.

If you don't have a config file yet, run ipython profile create to create one.

Note this ticket if you're working within the Django shell.


* The config file is located at: $HOME/.ipython/profile_default/ipython_config.py

like image 140
tuomassalo Avatar answered Oct 18 '22 03:10

tuomassalo


In ipython version 0.11 or higher,

  1. Run with --no-confirm-exit OR
  2. Exit via 'exit' instead of control-D OR
  3. Make sure the directory exists (or run ipython profile create to create it) and add these lines to $HOME/.ipython/profile_default/ipython_config.py:

    c = get_config()
    
    c.TerminalInteractiveShell.confirm_exit = False
    
like image 46
Ernest Avatar answered Oct 18 '22 01:10

Ernest