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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM