本文介绍了如何修改conda'源激活'ps1行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我当前的bash ps1如下:
my current bash ps1 is as follows:
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-name
放在我的PS1
之前:
by default, tells conda
to prepend the env-name
to my PS1
:
(<env-name-here>)
user@short-domain:fullpath$
是否有办法告诉conda
将env-name
插入我的PS1
中,特别是在换行符之后?
Is there a way to tell conda
to insert the env-name
within my PS1
instead, specifically, right after the newline?
推荐答案
我找到的最简单的解决方案是将换行符从PS1
移到PROMPT_COMMAND
:
The simplest solution I have found is to move the newline from PS1
to PROMPT_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
行为,同时用换行符分隔bash命令:
This allows conda
to maintain it's default PS1
behavior all while separating bash commands with newlines:
user@short-domain:fullpath$ source activate <env-name-here>
(<env-name-here>) user@short-domain:fullpath$
这篇关于如何修改conda'源激活'ps1行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!