ps1

Long lines overlap in Bash PS1 prompt

本秂侑毒 提交于 2021-02-08 07:47:04
问题 I have configured a PS1 bash prompt. My ~/.bashrc file: if [[ $EUID -ne 0 ]]; then PS1='\n\e[0;33m☛ \W\e[0m \n\e[1;35m⤷\e[0m ' fi The problem is that the new line overlaps the previous one. Any idea how to fix this? 回答1: When using non-printing characters in a bash prompt, you have to specify non-printing sequences (e.g. color codes) as non-printing, using \[...\] : PS1='\n\[\e[0;33m\]☛ \W\[\e[0m\] \n\[\e[1;35m\]⤷\[\e[0m\] ' 来源: https://stackoverflow.com/questions/17306348/long-lines-overlap

Long lines overlap in Bash PS1 prompt

南笙酒味 提交于 2021-02-08 07:45:51
问题 I have configured a PS1 bash prompt. My ~/.bashrc file: if [[ $EUID -ne 0 ]]; then PS1='\n\e[0;33m☛ \W\e[0m \n\e[1;35m⤷\e[0m ' fi The problem is that the new line overlaps the previous one. Any idea how to fix this? 回答1: When using non-printing characters in a bash prompt, you have to specify non-printing sequences (e.g. color codes) as non-printing, using \[...\] : PS1='\n\[\e[0;33m\]☛ \W\[\e[0m\] \n\[\e[1;35m\]⤷\[\e[0m\] ' 来源: https://stackoverflow.com/questions/17306348/long-lines-overlap

Bash PS1 window title?

萝らか妹 提交于 2020-11-29 09:29:06
问题 Say I have this as my PS1 PS1='\[\e]0;TITLE\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ ' it will give me this prompt Steven@Steven-PC ~ $ with a window title as TITLE I understand that this part \e]0;TITLE\a creates the title, but I dont understand why. It just seems like some gibberish. 回答1: The terminal driver looks for output containing that specific code ( \e]0; )and uses everything up to the \a as the terminal window title. 来源: https://stackoverflow.com/questions/10456228/bash-ps1

How to modify conda prompt string content

浪子不回头ぞ 提交于 2020-07-23 06:50:07
问题 How can I edit the conda prompt's behavior without touching my normal prompt? I want to retain conda's prepend-to-PS1 behavior, but change the string that gets prepended. The question how to modify conda 'source activate' ps1 behavior is very similar. However, the solution there is to either inject the conda prefix into the middle of PS1 and/or edit PROMPT_COMMAND . This breaks the encapsulation I want, and is very hacky when the prepend-to-PS1 behavior is still desirable. My normal prompt

How to modify conda prompt string content

∥☆過路亽.° 提交于 2020-07-23 06:49:45
问题 How can I edit the conda prompt's behavior without touching my normal prompt? I want to retain conda's prepend-to-PS1 behavior, but change the string that gets prepended. The question how to modify conda 'source activate' ps1 behavior is very similar. However, the solution there is to either inject the conda prefix into the middle of PS1 and/or edit PROMPT_COMMAND . This breaks the encapsulation I want, and is very hacky when the prepend-to-PS1 behavior is still desirable. My normal prompt

How to modify conda prompt string content

痴心易碎 提交于 2020-07-23 06:48:27
问题 How can I edit the conda prompt's behavior without touching my normal prompt? I want to retain conda's prepend-to-PS1 behavior, but change the string that gets prepended. The question how to modify conda 'source activate' ps1 behavior is very similar. However, the solution there is to either inject the conda prefix into the middle of PS1 and/or edit PROMPT_COMMAND . This breaks the encapsulation I want, and is very hacky when the prepend-to-PS1 behavior is still desirable. My normal prompt

PS1 bash command substitution not working on windows 10

送分小仙女□ 提交于 2020-06-12 05:06:29
问题 This is my script that sets up my bash PS1 # Reset Color_Off="\[\033[0m\]" # Text Reset # Regular Colors Black="\[\033[0;30m\]" # Black Red="\[\033[0;31m\]" # Red Green="\[\033[0;32m\]" # Green Yellow="\[\033[0;33m\]" # Yellow Blue="\[\033[0;34m\]" # Blue Purple="\[\033[0;35m\]" # Purple Cyan="\[\033[0;36m\]" # Cyan White="\[\033[0;37m\]" # White # Bold BBlack="\[\033[1;30m\]" # Black BRed="\[\033[1;31m\]" # Red BGreen="\[\033[1;32m\]" # Green BYellow="\[\033[1;33m\]" # Yellow BBlue="\[\033[1

PS1 bash command substitution not working on windows 10

独自空忆成欢 提交于 2020-06-12 05:06:10
问题 This is my script that sets up my bash PS1 # Reset Color_Off="\[\033[0m\]" # Text Reset # Regular Colors Black="\[\033[0;30m\]" # Black Red="\[\033[0;31m\]" # Red Green="\[\033[0;32m\]" # Green Yellow="\[\033[0;33m\]" # Yellow Blue="\[\033[0;34m\]" # Blue Purple="\[\033[0;35m\]" # Purple Cyan="\[\033[0;36m\]" # Cyan White="\[\033[0;37m\]" # White # Bold BBlack="\[\033[1;30m\]" # Black BRed="\[\033[1;31m\]" # Red BGreen="\[\033[1;32m\]" # Green BYellow="\[\033[1;33m\]" # Yellow BBlue="\[\033[1

设置Linux终端字体颜色

早过忘川 提交于 2020-04-03 20:22:48
系统启动后,环境变量加载的顺序为:/etc/profile → /etc/profile.d/*.sh → ~/.bash_profile → ~/.bashrc → /etc/bashrc 想要修改某用户登录后shell字体的颜色,在~/.bashrc中修改PS1的内容即可。 命令提示符PS1的常用参数: \d :日期,格式为"周 月 日",例如:"Mon Aug 1" \H :完整的主机名; \h :仅取主机的第一个名字; \t :24小时制的时间,如:HH:MM:SS; \A :24小时制的时间:HH:MM; \T :12小时制的时间; \u :当前用户的用户名; \v :BASH的版本信息; \w :当前工作目录的完整路径; \W :当前工作目录的basename; \$ :提示符,如果是root时,提示符为:#,普通用户则为:$ 要实现颜色显示,这里要用到转义序列;转义序列就是一个让 shell 执行一个特殊步骤的控制指令。 转义序列通常都是以ESC开头,在shell里表示为^[ ,这种表示法需要一点时间去适应,也可以用 \033 完成相同的工作(ESC的ASCII 码用十进制表示就是27,等于用八进制表示的033)。 要直接在shell里面输入转义序列需要先按 CTRL-v ESC 或者 CRTL-v-[ 。 \033[m 声明了转义序列的开始。 \033[0m

MIT 6.0001 ps1 c

十年热恋 提交于 2020-03-07 04:32:46
bisection search 有递归,无递归两种写法 def achieve_down_payment ( num , annual_salary , portion_down_payment ) : current_savings = 0 month = 1 while ( ( current_savings - portion_down_payment ) < ( - 100 ) ) : portion_saved = num * 0.0001 * annual_salary / 12 if month == 1 : current_savings = portion_saved else : current_savings = current_savings * r / 12 + portion_saved + current_savings if month % 6 == 0 : annual_salary = annual_salary * ( 1 + semi_annual_raise ) month += 1 return month def bisection_search ( list , left , right , steps ) : if left > right : return - 1 , steps if left <= right : mid =