2017-05-29 46 views
0

每當我進入終端時,我可以輸入'jp'而不是'jupyter notebook'嗎?我試圖別名〜/ .bash_profile中,但它沒有工作mac上的習慣命令行

alias jp = 'jupyter notebook' 

和它說

-bash: ‘jupyter: command not found 
+0

您究竟是什麼別名?你的意思是「不起作用」?你的.bash_profile是否可以運行? – Robert

+1

你是否在'='周圍輸入了空格,就像上面一樣?一定沒有。 –

+0

@BenjaminW。你能給個例子嗎? – ZHU

回答

1

有不同的方式來做到這一點:

1日的〜/ .bashrc

打開〜/ .bashrceditor您的選擇並在之後添加一些行:

# Alias definitions. 
# You may want to put all your additions into a separate file like 
# ~/.bash_aliases, instead of adding them here directly. 
# See /usr/share/doc/bash-doc/examples in the bash-doc package. 
alias jp='jupyter notebook' 

保存並關閉它。

第2〜/ .bash_aliases更明確

一點點是touch一個新的文件〜/ .bash_aliases,並與editor經常選擇打開。添加幾行,保存並關閉它。

alias jp='jupyter notebook' 
alias la='ls -al' 
alias ..='cd ..' 

爲了需要在添加這些線路的.bashrc

if [ -f ~/.bash_aliases ]; then 
     . ~/.bash_aliases 
fi 

最後,你需要重新加載源重裝bash_aliases:

1路:

$ source ~/.bashrc 

創建新文件後的第二種方法:

$ source ~/.bash_aliases