2017-02-27 60 views
1

我目前的bash PS1如下:如何修改暢達 '源激活' PS1行爲

bldred='\e[1;31m' # Red 
bldcyn='\e[1;36m' # Cyan 
bldwht='\e[1;37m' # White 
txtrst='\e[0m' # Text Reset - Useful for avoiding color bleed 

export PS1="\n\[$bldred\]\u\[$txtrst\]@\[$bldwht\]\h\[$txtrst\]:\[$bldcyn\]\w\[$txtrst\]$ " 

但是,在運行:

source activate <env-name-here> 

默認情況下,告訴conda預先設置env-namePS1

(<env-name-here>) 
[email protected]:fullpath$ 

有沒有辦法告訴conda在我的PS1之內插入env-name,而不是在換行符之後?

+0

我根本不知道'conda',但是你能不能把它傳遞給字符串' \ n',並從PS1中刪除'\ n'? – Aaron

回答

1

我發現最簡單的解決方法是換行擺脫PS1PROMPT_COMMAND

bldred='\e[1;31m' # Red 
bldcyn='\e[1;36m' # Cyan 
bldwht='\e[1;37m' # White 
txtrst='\e[0m' # Text Reset - Useful for avoiding color bleed 

PROMPT_COMMAND="printf '\n'" 
export PS1="\[$bldred\]\u\[$txtrst\]@\[$bldwht\]\h\[$txtrst\]:\[$bldcyn\]\w\[$txtrst\]$ " 

這使得conda保持它的默認PS1行爲,同時還能分離慶典用換行命令:

[email protected]:fullpath$ source activate <env-name-here> 

(<env-name-here>) [email protected]:fullpath$