开发者

Making entered commands bold at the prompt

开发者 https://www.devze.com 2023-01-14 05:33 出处:网络
This is my current PS1 prompt definition from by .bashrc: PS1=\'\\[\\033[01;33m\\]★ \\[\\033[01;30m\\]\\w \\[\\033[32m\\]\\$ \\[\\033[m\\]\'

This is my current PS1 prompt definition from by .bashrc:

PS1='\[\033[01;33m\]★ \[\033[01;30m\]\w \[\033[32m\]\$ \[\033[m\]'

My command prompt works great and I love it, but I would like to add one more little thing. I would really like to be able to have the text I enter (commands at the prompt) bold.

I know I could change the last escape code to 开发者_开发问答be:

\[\033[01m\]

Which would make the command prompt text I enter bold, but it also does funny (undesirable) things with the output of entered commands.

Is there a way to do this? If so, how?

I am running gnome-terminal in Ubuntu.


I was looking to do this too. I found an answer here: https://wiki.archlinux.org/index.php/Color_Bash_Prompt#Different_colors_for_text_entry_and_console_output

Add this line to your ~/.bashrc which will reset the color that you set in your PS1 variable before displaying your command's output:

trap 'echo -ne "\e[0m"' DEBUG

0

精彩评论

暂无评论...
验证码 换一张
取 消