Arch Linux 命令提示符PS1 color 设置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Arch Linux 命令提示符PS1 color 设置相关的知识,希望对你有一定的参考价值。

[[email protected] ~]$ vim .bashrc
#
# ~/.bashrc
#

alias ls=‘ls --color=auto‘
alias ll=‘ls -la --color=auto‘
# If not running interactively, don‘t do anything
[[ $- != *i* ]] && return

#PS1=‘[\[email protected]\h \W]\$ ‘
PS1=‘\[\033[1;32m\]\[email protected]\h \w $\[\033[0m\] ‘

[[email protected] ~]$
[[email protected] ~]$source .bashrc
[email protected] ~ $

显示效果如下

技术分享图片

[email protected] ~ $ vim terminal_color.sh 
#!/bin/bash
#
#   This file echoes a bunch of color codes to the 
#   terminal to demonstrate what‘s available.  Each 
#   line is the color code of one forground color,
#   out of 17 (default + 16 escapes), followed by a 
#   test use of that color on all nine background 
#   colors (default + 8 escapes).
#

T=‘gYw‘   # The test text

echo -e "\n                 40m     41m     42m     43m     44m     45m     46m     47m";

for FGs in ‘    m‘ ‘   1m‘ ‘  30m‘ ‘1;30m‘ ‘  31m‘ ‘1;31m‘ ‘  32m‘            ‘1;32m‘ ‘  33m‘ ‘1;33m‘ ‘  34m‘ ‘1;34m‘ ‘  35m‘ ‘1;35m‘            ‘  36m‘ ‘1;36m‘ ‘  37m‘ ‘1;37m‘;
  do FG=${FGs// /}
  echo -en " $FGs \033[$FG  $T  "
  for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
    do echo -en "$EINS \033[$FG\033[$BG  $T  \033[0m";
  done
  echo;
done
echo

显示效果如下

技术分享图片

参考文献

以上是关于Arch Linux 命令提示符PS1 color 设置的主要内容,如果未能解决你的问题,请参考以下文章

Linux终端提示符PS1设置

自定义Linux终端 PS1命令提示符

linux 命令提示符修改详细介绍

Linux下命令提示符的修改,PS1的个项参数详解

在Bash中定制炫酷的命令提示符

linux下环境变量PS1-命令提示符