说出来也许你不信,我被 Linux 终端嘲笑了…….

人这一生,真的是很是不容易:读书时,被老师、同窗嘲笑,工做时,被老板、同事嘲笑,就连出去撸个串儿,还可能被朋友嘲笑……git

这些也就算了,毕竟你们还都是同类,都是活生生的人。可是,你若是被 Linux 终端给嘲笑了,你的心里会是什么感觉?github

今天要介绍的,是一个很是有趣的 CLI 工具,这个工具能够实现当你在终端输错命令时,会随机回复一句嘲笑你的话。虽然是嘲笑人的工具,但良许以为仍是挺有趣的,给枯燥的工做带来一些乐趣。centos

Linux 终端嘲笑器的安装

这是一个在 GitHub 上的开源项目,因此能够直接 clone 到本地:bash

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
复制代码

运行如下命令使以上的改动生效:ui

sudo source /etc/bash.bashrc
复制代码

大功告成了!接下来你就能够测试一下这个神奇的会嘲笑人的工具!this

Linux 终端嘲笑器的使用

咱们随便乱输一些不存在的「命令」,而后就接受它的嘲笑吧~spa

[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 文件,直接编辑它,就能够本身添加一些句子。code

# 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"
        ... #省略
    }
复制代码

固然,这个也能够写成中文的。若是你不喜欢这些嘲讽的话,你能够将它们改为一些鼓励的话,好比:加油哦,棒棒哒,你行的 ,就看你的脑洞啦~


-----------------

我是良许,世界500强外企 Linux 开发工程师,专业生产 Linux 干货。欢迎关注个人公众号「良许Linux」,回复「1024」获取最新最全的技术资料,回复「入群」进入高手如云技术交流群。

相关文章
相关标签/搜索