人這一輩子,真的是非常不容易:讀書時,被老師、同學嘲笑,作業時,被老板、同事嘲笑,就連出去擼個串兒,還可能被朋友嘲笑……
這些也就算了,畢竟大家還都是同類,都是活生生的人,但是,你如果被 Linux 終端給嘲笑了,你的內心會是什么感受?
今天要介紹的,是一個非常有趣的 CLI 工具,這個工具可以實作當你在終端輸錯命令時,會隨機回復一句嘲笑你的話,雖然是嘲笑人的工具,但良許覺得還是挺有趣的,給枯燥的作業帶來一些樂趣,
Linux 終端嘲笑器的安裝
這是一個在 GitHub 上的開源專案,所以可以直接 clone 到本地:
git clone https://github.com/hkbakke/bash-insulter.git bash-insulter
將下載后的 bash.command-not-found 檔案復制到 etc 目錄下:
sudo cp bash-insulter/src/bash.command-not-found /etc/
然后,再將 bash.command-not-found 添加到 bash.bashrc 檔案里:
$ vi /etc/bash.bashrc
#Bash Insulter
if [ -f /etc/bash.command-not-found ]; then
. /etc/bash.command-not-found
fi
運行以下命令使以上的改動生效:
sudo source /etc/bash.bashrc
大功告成了!接下來你就可以測驗一下這個神奇的會嘲笑人的工具!
Linux 終端嘲笑器的使用
我們隨便亂輸一些不存在的「命令」,然后就接受它的嘲笑吧~
[alvin@VM_0_16_centos ~]$ sldkf
Why are you doing this to me?!
-bash: sldkf: command not found
[alvin@VM_0_16_centos ~]$ iehf
You are not as bad as people say, you are much, much worse.
-bash: iehf: command not found
[alvin@VM_0_16_centos ~]$ sdfas
How many times do I have to flush before you go away?
-bash: sdfas: command not found
Linux 終端嘲笑器的配置
上面那些嘲諷的句子,其實是可以配置的,它的檔案就是剛剛復制的 bash.command-not-found 檔案,直接編輯它,就可以自己添加一些句子,
# vi /etc/bash.command-not-found
print_message () {
local messages
local message
messages=(
"Boooo!"
"Don't you know anything?"
"RTFM!"
"Haha, n00b!"
"Wow! That was impressively wrong!"
"Pathetic"
... #省略
}
當然,這個也可以寫成中文的,如果你不喜歡這些嘲諷的話,你可以將它們改成一些鼓勵的話,比如:加油哦,棒棒噠,你行的 ,就看你的腦洞啦~
公眾號:良許Linux
有識訓?希望老鐵們來個三連擊,給更多的人看到這篇文章
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/20598.html
標籤:Linux
