bash设置[1]

[入库:2005年9月21日] [更新:2007年3月24日]

本文简介:


bash(1)


要使bash 符合个人的口味,有几个文档需要修改:



/etc/bashrc 存有整个系统的别名和功能;
/etc/profile 存有整个系统的环境参数和启动程式;
$HOME/.bashrc 存有用户的的别名和功能;
$HOME/.bash_profile 存有用户的环境参数和启动程式;
$HOME/.bash_logout 存有退出系统时的结束方式;
$HOME/.inputrc 存有主要绑定数值和其他位元数值;
下文将例举对这些文档的修改。首先,最重要的文档是:/etc/profile。如以下几节中可以看到,一向以修改这个文档的方式来设定Linux的各种功能。


--------------------------------------------------------------------------------


# /etc/profile


# System wide environment and startup programs
# --整个系统环境和启动程式
#
# Functions and aliases go in /etc/bashrc
# --/etc/bashhrc中的功能和别名
#
# This file sets the following features:
# --这个文档设定下列功能:
#
# o path --路径
# o prompts --提示符
# o a few environment variables --几个环境变数
# o colour ls --ls 的颜色
# o less behaviour --设定less的功能
# o keyboard settings --键盘设置
#
# Users can override these settings and/or add others in their
# $HOME/.bash_profile
# 用户可在$HOME/.bash_profile中取消这些设定和(或)增加其他设定


# set a decent path
# 设定可行的路径


echo $PATH | grep X11R6 > /dev/null
if [ $? = 1 ] ; then # add entries to the path
PATH="$PATH:/usr/X11R6/bin:$HOME/bin:."
fi


# notify the user: login or non-login shell. If login, the prompt is
# coloured in blue; otherwise in magenta. Root's prompt is red.
# 通知用户:登录(login)或不登录(non-login)的外围程序(shell)。
# 如果登录,则提示符为蓝色,否则为紫红色。Root的提示符为红色。


USER=`whoami`
if [ $LOGNAME = $USER ] ; then
COLOUR=44
else
COLOUR=45
fi


if [ $USER = 'root' ] ; then
COLOUR=41
fi


# put a real escape character instead of ^[
# 用真正的换码字符代替^[


PS1='^[[$COLOUR;37;1m$HOSTNAME:^[[37;40;1mw$ '
PS2="Continue> "


# no core dumps, please
# 请勿转储内存信息


ulimit -c 0


# set umask
# 设定umask


if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
umask 002
else
umask 022
fi


# a few variables
# 几项变数


USER=`id -un`
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
EDITOR=jed
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
HISTFILESIZE=1000
export PATH PS1 PS2 USER LOGNAME MAIL EDITOR HOSTNAME HISTSIZE HISTFILESIZE


# enable colour ls
# 设定ls的颜色


eval `dircolors /etc/DIR_COLORS -b`
export LS_OPTIONS='-F -s -T 0 --color=tty'


# customize less
# 设定less


LESS='-M-Q'
LESSEDIT="%E ?lt+%lt. %f"
LESSOPEN="| lesspipe.sh %s"
VISUAL=jed
LESSCHARSET=latin1
export LESS LESSEDIT LESSOPEN VISUAL LESSCHARSET


# customise the keyboard
# 设定键盘


/sbin/kbdrate -s -r 16 -d 500


for i in /etc/profile.d/*.sh ; do
if [ -x $i ]; then
. $i
fi
done


--------------------------------------------------------------------------------


此处为 /etc/bashrc:


 


--------------------------------------------------------------------------------


# /etc/bashrc


# System wide functions and aliases
# 整个系统的功能和别名
#
# Environment stuff goes in /etc/profile
# /etc/profile中的环境参数
#


alias which="type -path"
alias d="ls"
alias dir="d"


--------------------------------------------------------------------------------


此处为 .bashrc:


 


--------------------------------------------------------------------------------


# $HOME/.bashrc
# Source global definitions


if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi


# this is needed to notify the user that they are in non-login shell
# 需要以下设定,以便通知处於不登录(non-login)外围程序(shell)中的用户


COLOUR=45
# put a real escape character instead of ^[
# 用真正的换码字符代替^[



本文关键:bash设置
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top