shell脚本,怎么实现每次新开一个shell都输出一个提示语?

[root@localhost wyb]# cat test.sh 
echo -e "\033[32mhello,This is wangyuebo's shell\033[0m"
echo -e "\033[32m`date`\033[0m"
LANG=en
echo -e "\033[32m`date` login at `hostname` `w`\033[0m" >>/etc/wangyuebo.log
[root@localhost wyb]# 

当写好了提示语在test.sh脚本里面,这时把脚本放到~/.bashrc文件里面就可以了 bash /root/wyb/test.sh

[root@localhost wyb]# cat ~/.bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi
bash /root/wyb/test.sh
[root@localhost wyb]# 

然后在重新打开一个shell,就可以看到在test.sh设置的提示语了
Connecting to 192.168.16.110:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Fri Sep  2 00:16:14 2016 from 192.168.16.101
hello,This is wangyuebo's shell
Fri Sep  2 00:19:35 CST 2016
[root@localhost ~]# 

 

posted on 2016-09-02 00:23  王月波  阅读(1787)  评论(0编辑  收藏  举报

导航