简体   繁体   English

如何使Macbook Terminal文本的透明度降低

[英]How to make Macbook Terminal text less transparent

I've recently tinkered with my .bash_profile to change the color and formatting of my Terminal command prompt. 我最近修改了.bash_profile来更改终端命令提示符的颜色和格式。 Unfortunately, in doing so, I've also caused for any text that I type in to appear in a very transparent shade: 不幸的是,这样做时,我还导致输入的任何文本都以非常透明的阴影显示:

在此处输入图片说明

Below are the contents of my .bash_profile: 以下是我的.bash_profile的内容:

PS1="\[\033[0;35m\]\u\[\033[1;33m\]@\[\033[1;33m\]\w\[\033[0;32m\]\$ "
export PS1;

export CLICOLOR=1
export LSCOLORS=Gafxcxdxbxegedabagacad

How might my .bash_profile file be modified to make all text as bright/bold as the bold-green and bold-yellow text shown in the image? 如何修改我的.bash_profile文件,以使所有文本都与图像中显示的粗体绿色和粗体黄色文本一样亮/粗体?

Setting the PS1 variable using escape codes is tedious and often has side effects. 使用转义码设置PS1变量很繁琐,而且经常会有副作用。 I did it that way for years, and line wrapping was often broken. 多年来,我一直是这样做的,而且换行经常被打断。 I tested your PS1 in a terminal window. 我在终端窗口中测试了您的PS1。 Seems that something is not terminated correctly as the color bleeds into the following line. 似乎随着颜色渗入下一行,某些东西未正确终止。 I use tput to set PS1, which makes the assignment more readable. 我使用tput设置PS1,这使分配更具可读性。 Here is what I have in .bash_profile: 这是我在.bash_profile中的内容:

set_prompt() {
local red=$(tput setaf 1)
local green=$(tput setaf 2)
local yellow=$(tput setaf 3)
local blue=$(tput setaf 4)
local magenta=$(tput setaf 5)
local cyan=$(tput setaf 6)
local white=$(tput setaf 7)
local reset=$(tput sgr0)

if [ ${UID} -eq 0 ]; then
    # user is red when we are root
    export PS1="\[$red\]\u\[$white\]@\[$green\]\h\[$white\]:\[$yellow\]\w [$reset\]$ "
else
    export PS1="\[$blue\]\u\[$white\]@\[$green\]\h\[$white\]:\[$yellow\]\w\[$reset\]$ "
fi;

} }

# Don't set the prompt for dumb terminals
if [ ${TERM+x} -a "${TERM-}" != "dumb" ]; then
    set_prompt
fi

The brighter text was from this chunk, which sets the bold attribute 1 : 较亮的文本来自此块,它设置了粗体属性1

\[\033[1;33m\]

and the text is left dim because you omitted bold at the end: 文本变暗,因为您在末尾省略了粗体:

\[\033[0;32m\]

The 32 and 33 select colors green and yellow , respectively, but without the bold attribute, most terminals display that as brown . 3233选择绿色黄色 ,但没有粗体属性,大多数终端将其显示为棕色

Further reading 进一步阅读

I am using macbook too but I don't use the default terminal application. 我也使用Macbook,但不使用默认的终端应用程序。 I use iTerm, it is really more flexible and can be configured as how you want it to display things. 我使用iTerm,它确实更加灵活,可以根据您希望它显示事物的方式进行配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM