2017-05-27 105 views
0

我對如何保存ipython別名有點困惑,以至於每次打開ipython會話(首先保存別名後)並直接使用別名命令(在這一點上,您不應再次輸入別名)。 例如,在Linux(或Windows)中使用ipython時,我會使用vi而不是!vi文件。如何永久保存ipython別名?

vi fileneme

!vi filename

回答

0

爲了生成默認的配置文件ipython_config.py在IPython的目錄下profile_default:

$ ipython profile create 

在linux查找ipython_config.py /窗口

#use find command in linux 
find/-name ipython_config.py 
#in window,you can use all kinds of tools to search . 
#in commands line,you can use 
ipython locate profile. 
#in the directory,you can get it 

編輯th Ëipython_config.py文件添加fellowing內容

c = get_config() 
c.TerminalIPythonApp.display_banner = True 
c.InteractiveShellApp.log_level = 20 
c.InteractiveShellApp.extensions = [] 
c.InteractiveShellApp.exec_lines = [] 
c.InteractiveShellApp.exec_files = ['mycode.py']#load Module when open ipython 
c.InteractiveShell.autoindent = True 
c.InteractiveShell.colors = 'LightBG'#ipython console color 
c.InteractiveShell.confirm_exit = False 
c.InteractiveShell.editor = 'vim'#you can change your favorite editor 
c.InteractiveShell.xmode = 'Context' 
c.PrefilterManager.multi_line_specials = True 
#you can add your alias in the fellowing list 
c.AliasManager.user_aliases = [('vi','vim'),('py','python')('git','git'),]#i add git ,vim python .i really dislike "!" 

保存文件並退出,並得到它