默认情况下,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
分享到:
相关推荐
Archlinux 设置IP地址、网关、DNS的方法.docx
Archlinux 产生于2001年初。最初的设计思想来源于两个Linux发行版:PLD和CRUX。PLD采用的是 apt-get 作为 rpm 系统的前端,便于系统的升级;CRUX 的软件包的打包方式十分简单,就是最简单的tar.gz包,更易于管理和...
archlinux 安装
archlinux安装图解教程.pdf
该文档描述了archlinux中安装、配置gnome的步骤。
ArchLinux简体中文官方指南 ,适用于初学者,可以让初学者更好的了解linux的安装过程。
打造完美的Linux桌面 Archlinux
aui, Archlinux最终安装 项目只接受补丁这个项目没有积极地开发,但是我们将接受 PRs Archlinux安装安装和配置archlinux从未更容易 !你可以先用 virtualbox 试试先决条件工作互联网连接以'root'登录'如何获取它
你厌烦了越来越臃肿,拖得越来越慢...可是网络上的Archlinux的教程比较分散,而Archlinux官网上的教程又太老了,也不易理解,因此作者打算结合最近的Archlinux使用经验做这份Linux使用教程,帮助大家学习和使用Linux。
ArchLinux安装镜像,用于安装ArchLinux的live环境
archlinux-2016.04.01-dual.iso.torrent
ArchLinux 电源管理 cpufreq ArchLinux 电源管理 cpufreq
新手安装Archlinux+GNOME 3.2完整教程
虚拟机安装Archlinux(全.docx
archLinux dual install.一个4个文档,包括ArchLinux dual的按照,比较细致,包括硬盘分区都有
安装archlinux作为WSL (Windows Subsystem for Linux) 主机
Ansible-ansible-archlinux.zip,Automated Arch Linux桌面环境Automated ArchLinux,ansible是一个简单而强大的自动化引擎。它用于帮助配置管理、应用程序部署和任务自动化。
自己安装archlinux的过程。centos7.3系统,vitualbox。没有efi分区。
archlinux新手安装指南 archlinux新手安装指南 archlinux新手安装指南 archlinux新手安装指南
archlinux-安装完全指南.pdf