Skip to content

Instantly share code, notes, and snippets.

@jzztf
Last active May 20, 2018 14:16
Show Gist options
  • Save jzztf/8ad236a262ba9a57acc710667ef32a8c to your computer and use it in GitHub Desktop.
Save jzztf/8ad236a262ba9a57acc710667ef32a8c to your computer and use it in GitHub Desktop.
ipython config
# coding: utf-8
#----------------------------------------------------
# .ipython/profile_default/startup/00-prompts-start.py
#----------------------------------------------------
# 参考: <https://ipython.readthedocs.io/en/stable/config/details.html#custom-prompts>
# 将此文件添加到".ipython/profile_default/startup/"即可
from IPython.terminal.prompts import Prompts, Token
class MyPrompt(Prompts):
def in_prompt_tokens(self,cli=None):
return [(Token.Prompt,'In :')]
def out_prompt_tokens(self,cli=None):
return [(Token.Prompt,'Out:')]
ip = get_ipython()
ip.prompts = MyPrompt(ip)
#----------------------------------------------------
# .ipython/profile_default/ipython_config.py
#----------------------------------------------------
## lines of code to run at IPython startup.
c.InteractiveShellApp.exec_lines = ['autoreload 2']
## A list of dotted module names of IPython extensions to load.
c.InteractiveShellApp.extensions = ['autoreload']
## Whether to display a banner upon starting IPython.
c.TerminalIPythonApp.display_banner = False
##
#c.InteractiveShell.separate_in = '\n'
c.InteractiveShell.separate_in = ''
## Set the editor used by IPython (default to $EDITOR/vi/notepad).
c.TerminalInteractiveShell.editor = 'nano'
#----------------------------------------------------
# shell中的操作
#----------------------------------------------------
# "$ ipython profile create"
# 创建默认的profile
# "$ ipython profile create foo"
# 创建自定义profile
# "$ ipython --profile=foo"
# 使用自定义profile
@jzztf
Copy link
Author

jzztf commented May 20, 2018

manage profile

# set the default profile
ipython profile create
# set special profile
ipython profile create simple
# show the profiles
ipython profile list
# edit '~/.ipython/profile_simple/ipython_config.py'
# manage startup files with ipython in '~/.ipython/profile_simple/startup/'
# use simple ipython
ipython --profile='simple'
# alias simple ipython in '.bashrc/.zshrc'
alias ipys="ipython --profile='simple'"
# more about ipython profile
ipython profile -h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment