# System wide environment and startup programs # --整个系统环境和启动程式 # # Functions and aliases go in /etc/bashrc # --/etc/bashhrc中包含功能和别名 # # This file sets up the following features and programs: # --这个文档设定下列功能: # # o path --路径 # o prompts --提示符 # o a few environment variables --几个环境变数 # o colour ls --ls 的颜色 # o less behaviour --设定less的功能 # o rxvt # # Users can override these settings and/or add others in their # $HOME/.bash_profile # 用户可在 $HOME/.bash_profile 中取消这些设定和(或)增加其他设定
# set a decent path # 设定可行的路径
PATH="$PATH:/usr/X11R6/bin:$HOME/bin:."
# notify the user: login or non-login shell. If login, the prompt is # coloured in blue; otherwise in magenta. Root's prompt is red. # See the Colour-ls mini HOWTO for an explanation of the escape codes. # 通知用户:登录(login)或不登录(non-login)的外围程序(shell)。 # 如果登录,则提示符为蓝色,否则为紫红色。Root的提示符为红色。 # 参阅Colour-ls mini HOWTO 中对换码符(escape codes)的使用解释。
USER=`whoami` if [ $LOGNAME = $USER ] ; then COLOUR=44 # blue --蓝色 else COLOUR=45 # magenta --紫红色 fi
if [ $USER = 'root' ] ; then COLOUR=41 # red --红色 PATH="$PATH:/usr/local/bin" fi
LESS='-M-Q' LESSEDIT="%E ?lt+%lt. %f" LESSOPEN="| lesspipe.sh %s" LESSCHARDEF=8bcccbcc13b.4b95.33b. # show colours in ls -l | less # LESSCHARSET=latin1 PAGER=less export LESS LESSEDIT LESSOPEN VISUAL LESSCHARDEF
# fix the backspace key in rxvt/xterm # 设定rxvt/xterm中的退後键
CTRL_H="\010" NULL_STRING=" $CTRL_H" # space + backspace if [ "$NULL_STRING" != "" ] ; then stty erase ^? else stty erase ^H fi
# set xterm title: full path case $TERM in xterm*) PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' ;; esac
for i in /etc/profile.d/*.sh ; do if [ -x $i ]; then . $i # beware - variables and aliases might get overridden! fi done
# call fortune, if available --如有fortune if [ -x /usr/games/fortune ] ; then echo ; /usr/games/fortune ; echo fi
# System wide functions and aliases # 整个系统的功能和别名 # # Environment stuff goes in /etc/profile # /etc/profile中的环境参数 # # Insert PS1 definitions here if you experience problems. # 如有问题可将PS1的参数放在此处
export CDPATH="$CDPATH:
# common aliases --共同别名
alias cp='cp -i' alias l=less alias ls="ls $LS_OPTIONS" alias mv='mv -i' alias rm='rm -i' alias rmbk='/bin/rm -f .* alias u='cd ..' alias which="type -path" alias x=startx
# A few useful functions --几项有用的功能
c () # cd to the new directory and list its contents { cd $1 ; ls }
inst() # Install a .tar.gz archive in current directory --在当前目录中建立.tar.gz储存库 { if [ $# != 0 ]; then tar zxvf $1; fi }
cz() # List the contents of a .zip archive --列出.zip的内容 { if [ $# != 0 ]; then unzip -l $*; fi }
ctgz() # List the contents of a .tar.gz archive --列出.tar.gz的内容 { for file in $* ; do tar ztf ${file} done }
tgz() # Create a .tgz archive a la zip. --建立压缩档.tgz { if [ $# != 0 ]; then name=$1.tar; shift; tar -rvf ${name} $* ; gzip -9 ${name} fi }
crpm() # list information on an .rpm file --列出.rpm档的内容 { if [ $# != 0 ]; then rpm -qil $1 | less; fi }
# this is needed to notify the user that they are in non-login shell # 需要以下设定,以便通知处於不登录(non-login)外围程序(shell)中的用户
if [ "$GET_PS1" = "" ] ; then COLOUR=45; ESC="\033"; STYLE=';1m'; # STYLE='m' USER=`whoami` export PS1="\[$ESC[$COLOUR;37$STYLE\]$USER:\[$ESC[37;40$STYLE\]\w\\$ " fi
# personal aliases # 个人别名
alias backup='tar -Mcvf /dev/fd0' alias dial='eznet up myisp' alias f='cd alias hangup='eznet down' alias lyx='lyx -width 580 -height 450' alias restore='tar -M -xpvf /dev/fd0'
# personal functions # 几个个人使用的功能
xj() # Launch xjed and a file in background --在背景启动xjed和文档 { xjed $1 & }
# User specific environment and startup programs # 用户特定的环境参数和启动程式 # # This file contains user-defined settings that override # those in /etc/profile # 这个文档中存有用户自订的设置,可取代/etc/profile 中的数值 # # Get aliases and functions # 设定别名和功能 # if [ -f then GET_PS1="NO" # don't change the prompt colour --不改变提示符的颜色 . fi
set bell-style visible # please don't beep # 喇叭不发声 set meta-flag On # allow 8-bit input (i.e, accented letters) # 允许8-位元输入(例如重音字符)译注:用于欧洲
set convert-meta Off # don't strip 8-bit characters # 不取消8-位元字符 set output-meta On # display 8-bit characters correctly # 正确显示8-位元字符 set horizontal-scroll-mode On # scroll long command lines # 长指令行自动翻转 set show-all-if-ambiguous On # after TAB is pressed # 按TAB键
#!/bin/sh # This is a preprocessor for 'less'. It is used when this environment # variable is set: LESSOPEN="|lesspipe.sh %s" # 此为‘less’的预处理器。当环境参数定为LESSOPEN="|lesspipe.sh %s" # 时,便起用这个预处理器。
lesspipe() { case "$1" in *.tar) tar tf $1 2>/dev/null ;; # View contents of .tar and .tgz files # 阅读.tar和.tgz档的内容 *.tgz|*.tar.gz|*.tar.Z|*.tar.z) tar ztf $1 2>/dev/null ;; *.Z|*.z|*.gz) gzip -dc $1 2>/dev/null ;; # View compressed files correctly # 正确阅读压缩文档 *.zip) unzip -l $1 2>/dev/null ;; # View archives # 阅读档案文档 *.arj) unarj -l $1 2>/dev/null ;; *.rpm) rpm -qpil $1 2>/dev/null ;; *.cpio) cpio --list -F $1 2>/dev/null ;; *.1|*.2|*.3|*.4|*.5|*.6|*.7|*.8|*.9|*.n|*.l|*.man) FILE=`file -L $1` FILE=`echo $FILE | cut -d ' ' -f 2` if [ "$FILE" = "troff" ]; then groff -s -p -t -e -Tascii -mandoc $1 fi ;; *) file $1 | grep text > /dev/null ; if [ $? = 1 ] ; then # it's not some kind of text strings $1 fi ;; esac }