• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

Custom_prompts howto

发布: 2007-6-08 22:43 | 作者: seanhe | 来源: | 查看: 21次 | 进入软件测试论坛讨论

领测软件测试网
?p> To set a prompt that looks like
/usr/users/smith
porthos:smith >

with the first line in bold and the second line as normal text you may use the following definitions in your shell startup files:

For csh, add to your .cshrc file:

set BOLD='^[[1m'
set UNDLN='^[[4m'
set BLREV='^[[5m'
set REV='^[[7m'
set OFF='^[[0m'
set sys = `/bin/hostname | cut -f1 -d.`
alias p 'set prompt="${REV}`pwd`${OFF}
${sys}:${USER} > "'
alias cd 'cd !*; p'
alias chdir 'chdir !*; p'
alias popd 'popd !*; p'
alias pushd 'pushd !*; p'
p

For korn shell, add this to your .profile file:

BOLD='^[[1m'
UNDLN='^[[4m'
BLREV='^[[5m'
REV='^[[7m'
OFF='^[[0m'
sys=`/bin/hostname | cut -f1 -d.`
# if you want to use something other than the real name
[ "$sys" = "porthos" ] && sys="athos"
PS1='${REV}$PWD${OFF}
${sys}:${USER} > '

Note that the character depicted here as '^[' is the escape character, decimal 27, hex 1B. It may be inserted directly using Vi by pressing the keys : ctrl-v, Esc. In Emacs, use ctrl-q, Esc.

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

# .kshrc ( written by B. Miretti in 1999)
#--------------------------------
# display current directory on host writable line for "vt" mode and
# change window name and icon for dtterm.
#)
# Requires the following line in your .profile: # export ENV=$HOME/.kshrc
#--------------------------------
XT_NB="`tput -T dtterm colb7;tput -T dtterm colf0;tput smso`"
XT_RN="`tput -T dtterm colb0;tput -T dtterm colf1;tput smso`"
XT_NG="`tput -T dtterm colb2;tput -T dtterm colf0;tput smso`"
XT_NY="`tput -T dtterm colb3;tput -T dtterm colf0;tput smso`"
XT_NC="`tput -T dtterm colb6;tput -T dtterm colf0;tput smso`"

SPC=" "
XT_ON="\033[2$~\033[1$}\r${XT_NB}"
XT_OFF="${SPC}${SPC}${SPC}${SPC}\033[m\033[K\033[0$}"

#--------------------------------
# Note: KSHRC_VERSION is defined at your convenience in
# the .profile file or let blank
# Example: # export KSHRC_VERSION="`sizer -v|awk '{print $4}'` "
#-------------------------------
function _cd
{
'cd' $1
if test "`tty`" != "not at tty"
then
CLUNAME=`sysconfig -q clubase 
2>/dev/null|grep ^cluster_name|awk '{print $3}'`
HOSTNAME="`hostname -s`${CLUNAME:+($CLUNAME)}"

case "${TERM}"
in
"dtterm")
echo "\033]0;${USER}@${HOSTNAME} on ${PWD}\007\c"
;;
vt*)
CONS="";test "`tty`" = "/dev/console" &&
CONS="${XT_RN}*CONSOLE*${XT_NB} "
echo "${XT_ON}${CONS}${KSHRC_VERSION}$USER@${HOSTNAME} on \c"
test -L $PWD && echo "${XT_NC}-> \c"
if test -w ${PWD}
then
echo "${XT_NG}${PWD}${XT_OFF}\c"
else
echo "${XT_NY}${PWD} (ro)${XT_OFF}\c"
fi
;;
esac
fi

} typeset -fx _cd
alias -x cd=_cd
alias cd..='cd ..'

function Display_Last

{ last=`fc -lnr|head -1`
CLUNAME=`sysconfig -q clubase 2>/dev/null|grep ^cluster_name|awk '{print 3}'`
HOSTNAME="`hostname -s`${CLUNAME:+($CLUNAME)}" case "${TERM}"
in
"dtterm")
echo "\033]0;${USER}@${HOSTNAME} executing { `echo $last` }\007\c"
;;
vt*)
test "`tty`" = "/dev/console" && 
CONS="${XT_RN}*CONSOLE*${XT_NB} " || CONS=""
echo "${XT_ON}${CONS}${KSHRC_VERSION $USER@${HOSTNAME} executing
${XT_NC}{ `echo $last` }${XT_OFF}\c"
;;
esac
}

function _login
{
trap '_cd . ' 1 2 9 14 15 17
Display_Last
'login' $*
_cd .
}
typeset -fx _login
alias -x login=_login

function _rlogin
{
trap '_cd . ' 1 2 9 14 15 17
Display_Last
'rlogin' $*
_cd .
}
typeset -fx _rlogin
alias -x rlogin=_rlogin

function _setld
{
trap '_cd . ' 1 2 9 14 15 17
Display_Last
'setld' $*
_cd .
}
typeset -fx _setld
alias -x setld=_setld

function _te.net
{
trap '_cd .' 1 2 9 14 15 17
Display_Last
'telnet' $*
_cd .
}
typeset -fx _telnet
alias -x telnet=_telnet

# Note: sometimes the su command does not work when aliased
# Should remove the aliasing in case of issue.
function _su
{
trap '_cd . ' 1 2 9 14 15 17
Display_Last
'su' $*
_cd .
}
typeset -fx _su
alias -x su=_su

function _tip
{
trap '_cd . ' 1 2 9 14 15 17
Display_Last
tip $*
_cd .
}
typeset -fx _tip
alias -x tip=_tip

set -o emacs
cd .

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

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网