ArchLinux 终端文字颜色设置

  默认情况下,ArchLinux的终端显示是黑白的,如命令提示行(即root@host:~#)、ls显示的结果等,下面描述两种设置方法,即手动设置与使用Gentoo的配置文件。

1. 手动设置:

  对于普通用户,编辑~/.bashrc,添加如下代码:

 

 PS1=\[\e[32;1m\]\u@\h\[\e[m\]:\[\e[33m\]\w\[\e[m\]\$' 
 export PS1

 上面代码在命令提示行显示用户(红色、高亮)、冒号(白色)、当前路径(黄色)和$符号。

  对于root用户,可编辑/etc/bash.bashrc,添加或更改如下代码:

 

PS1=\[\e[32;1m\]\u@\h\[\e[m\]:\[\e[33m\]\w\[\e[m\]\$' 
export PS1
alias ls='ls --color=auto'
alias grep='grep --colour=auto' #这句确实起作用

 2. 使用Gentoo的配置文件:

Gentoo的.bashrc:

 

# /etc/skel/.bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen !


# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi


# Put your fun stuff here.

 Gentoo的/etc/bash/bashrc:

 

# /etc/bash/bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen !


# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi

# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control. #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize

# Enable history appending instead of overwriting. #139609
shopt -s histappend

# Change the window title of X terminals 
case ${TERM} in
xterm*|rxvt*|Eterm|aterm|kterm|gnome*|interix)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
;;
screen)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\033\\"'
;;
esac

use_color=false

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS. Try to use the external file
# first to take advantage of user additions. Use internal bash
# globbing instead of external grep binary.
safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM
match_lhs=""
[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs} ]] \
&& type -P dircolors >/dev/null \
&& match_lhs=$(dircolors --print-database)
[[ \n'${match_lhs} == *\n'"TERM "${safe_term}* ]] && use_color=true

if ${use_color} ; then
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489
if type -P dircolors >/dev/null ; then
if [[ -f ~/.dir_colors ]] ; then
eval $(dircolors -b ~/.dir_colors)
elif [[ -f /etc/DIR_COLORS ]] ; then
eval $(dircolors -b /etc/DIR_COLORS)
fi
fi

if [[ ${EUID} == 0 ]] ; then
PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
fi

alias ls='ls --color=auto'
alias grep='grep --colour=auto'
else
if [[ ${EUID} == 0 ]] ; then
# show root@ when we don't have colors
PS1='\u@\h \W \$ '
else
PS1='\u@\h \w \$ '
fi
fi

# Try to keep environment pollution down, EPA loves us.
unset use_color safe_term match_lhs

 参考:http://www.linuxdiyf.com/viewarticle.php?id=197611

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 要在Arch Linux上安装中文字体,可以按照以下步骤进行操作: 1. 安装中文字体包:在终端中输入命令“sudo pacman -S adobe-source-han-serif-cn-fonts adobe-source-han-sans-cn-fonts”,然后按回车键执行。 2. 配置字体:在终端中输入命令“sudo vim /etc/fonts/local.conf”,然后按回车键执行。在打开的文件中添加以下内容: ``` <?xml version="1."?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <dir>/usr/share/fonts/</dir> <dir>/usr/local/share/fonts/</dir> <dir>~/.fonts</dir> <match target="font"> <edit mode="assign" name="rgba"> <const>rgb</const> </edit> </match> <alias> <family>sans-serif</family> <prefer> <family>WenQuanYi Micro Hei</family> <family>WenQuanYi Zen Hei</family> <family>WenQuanYi Bitmap Song</family> <family>WenQuanYi Zen Hei Sharp</family> <family>WenQuanYi Zen Hei Mono</family> <family>WenQuanYi Micro Hei Mono</family> <family>WenQuanYi Micro Hei Light</family> <family>WenQuanYi Micro Hei Bold</family> <family>WenQuanYi Micro Hei Mono Light</family> <family>WenQuanYi Micro Hei Mono Bold</family> <family>WenQuanYi Zen Hei Mono Sharp</family> </prefer> </alias> <alias> <family>serif</family> <prefer> <family>WenQuanYi Bitmap Song</family> <family>WenQuanYi Zen Hei Sharp</family> <family>WenQuanYi Zen Hei Mono</family> <family>WenQuanYi Micro Hei Mono</family> <family>WenQuanYi Micro Hei Light</family> <family>WenQuanYi Micro Hei Bold</family> <family>WenQuanYi Micro Hei Mono Light</family> <family>WenQuanYi Micro Hei Mono Bold</family> <family>WenQuanYi Zen Hei Mono Sharp</family> </prefer> </alias> <alias> <family>monospace</family> <prefer> <family>WenQuanYi Micro Hei Mono</family> <family>WenQuanYi Zen Hei Mono</family> <family>WenQuanYi Micro Hei Mono Light</family> <family>WenQuanYi Micro Hei Mono Bold</family> <family>WenQuanYi Zen Hei Mono Sharp</family> </prefer> </alias> </fontconfig> ``` 3. 保存文件并退出:在vim编辑器中按下“Esc”键,然后输入“:wq”命令并按回车键。 4. 更新字体缓存:在终端中输入命令“sudo fc-cache -fv”,然后按回车键执行。 完成以上步骤后,就可以在Arch Linux上使用中文字体了。 ### 回答2: archlinux是一款强大的Linux操作系统,它与其他Linux操作系统不同之处在于它的软件包管理方式叫做pacman,它的安装包也叫做tar包。但是,由于一些历史原因,在archlinux中安装中文字体并不是那么容易。本文将介绍如何在archlinux中安装中文字体。 首先,要确保系统中已经安装了fcitx输入法,因为fcitx是中文输入法的首选。如果您还没有安装fcitx,请使用以下命令安装: sudo pacman -S fcitx-im fcitx-configtool fcitx-googlepinyin fcitx-sogoupinyin 接下来,您需要在系统中安装中文字体。目前,archlinux中比较常用的中文字体有文泉驿微米黑,这是一款非常好的中文字体,它可以完美地显示中文字符。如果您想安装文泉驿微米黑字体,请使用以下命令: sudo pacman -S wqy-microhei 如果您想安装其他的中文字体,可以通过pacman搜索来发现合适的字体包。 安装完中文字体后,您需要将它们配置到系统中。在archlinux中,字体的配置是通过编辑配置文件实现的。您需要先安装FONTCONFIG这个软件包: sudo pacman -S fontconfig 然后,在 /etc/fonts/conf.d 文件夹中,创建一个名为 70-noto.conf 的文件,写入以下内容: <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <dir>/usr/share/fonts/OTF</dir> <dir>/usr/share/fonts/TTF</dir> </fontconfig> 保存文件后,重新启动系统以使字体配置生效。 以上就是在archlinux中安装中文字体的完整步骤,希望对您有所帮助。 ### 回答3: Archlinux是一种自由和开放源代码的操作系统,它的用户界面是基于X Window System和桌面环境的。由于中文字体和英文字体的差异,本文将为您介绍如何在Archlinux中安装中文字体。 首先,您可以使用以下命令Archlinux软件仓库安装中文字体: 1. 通过更新软件包列表,运行命令:sudo pacman -Syu。 2. 第一种方法:安装整体字体包,可输入命令sudo pacman -S wqy-zenhei ttf-dejavu ttf-ubuntu-font-family。 3. 第二种方法:逐一安装需要的字体,可执行命令sudo pacman -S wqy-zenhei(文泉驿正黑)ttf-dejavu(DejaVu字体)ttf-ubuntu-font-family(Ubuntu字体)等。 然后,您可以按照以下步骤设置和测试中文字体: 1. 安装相应的字体包后,在设置中进行字体更改时,您应该能在列表中看到中文字体的选项,如文泉驿正黑等。 2. 如果您无法在设置中找到新安装的字体包,请确保已经在/usr/share/fonts/目录下为您安装了字体文件。 3. 要在命令行中测试中文字体是否正确显示,可以使用以下命令: - fc-list -f '%{family}\n' | grep -i <字体名称>:该命令将显示系统中的所有字体名称,您可以使用grep命令来过滤您安装的字体。 - fc-match <字体名称>:该命令将显示与您输入的字体名称最符合的字体。 总体来说,安装中文字体是Archlinux的一个简单而必要的步骤。希望这篇文章能够帮助您更好地使用Archlinux

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值