linux 终端欢迎界面 cowsay fortune

新建脚本,并命名为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

相关推荐