首页 > 系统服务 > 详细

linux 终端欢迎界面 cowsay fortune

时间:2020-06-11 20:17:27      阅读:114      评论:0      收藏:0      [点我收藏+]

新建脚本,并命名为welcome.sh,将如下内容写入脚本中。

#!/bin/bash

chmod ugo+x welcome.sh

cd ~

sudo apt-get update
sudo apt-get install cowsay
sudo apt-get install fortune

git clone https://github.com/ruanyf/fortunes.git
sudo mv fortunes/data/* /usr/share/games/fortunes/
cd /usr/share/games/fortunes/
sudo rm -rf *.dat

strfile -c % chinese chinese.dat
strfile -c % diet diet.dat
strfile -c % fortunes fortunes.dat
strfile -c % song100 song100.dat
strfile -c % tang300 tang300.dat
fortune -c
fortune -f

cd /ect/profile.d/

sudo cat > start-with-fortune-and-cowsay.sh << EOF
#!/bin/bash

animal=$(ls /usr/share/cowsay/cows | shuf -n 1)
fortune /usr/share/games/fortunes/tang300 | cowsay -f ${animal%%.*}
EOF
sudo chmod ugo+x start-with-fortune-and-cowsay.sh

 

执行welcome.sh即可。想要查看欢迎界面,执行start-with-fortune-and-cowsay.sh即可。

把/etc/profile.d/start-with-fortune-and-cowsay.sh 加入.bashrc的最后一行,以后打开一个终端都会看到。

 

可能会遇到cowsay, fortune命令找不到的情况,可以把/usr/games加入环境变量或者使用命令全路径就可解决。

https://blog.csdn.net/chinanjing/article/details/103713303

 

另外一个安装方法更简单https://www.cnblogs.com/Skrillex/p/7132288.html

技术分享图片

 

linux 终端欢迎界面 cowsay fortune

原文:https://www.cnblogs.com/longchang/p/13095184.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!