歡迎光臨
每天分享高質量文章

Bash-Insulter:一個在輸入錯誤命令時嘲諷使用者的指令碼 | Linux 中國

這是一個非常有趣的指令碼,每當使用者在終端輸入錯誤的命令時,它都會嘲諷使用者。

— Magesh Maruthamuthu

 

它讓你在解決一些問題時會感到快樂。有的人在受到終端嘲諷的時候感到不愉快。但是,當我受到終端的批評時,我真的很開心。

這是一個有趣的 CLI 工具,在你弄錯的時候,會用隨機短語嘲諷你。此外,它允許你新增自己的短語。

如何在 Linux 上安裝 Bash-Insulter?

在安裝 Bash-Insulter 之前,請確保你的系統上安裝了 git。如果沒有,請使用以下命令安裝它。

對於 Fedora 系統, 請使用 DNF 命令[1] 安裝 git。

  1. $ sudo dnf install git

對於 Debian/Ubuntu 系統,請使用 APT-GET 命令[2] 或者 APT 命令[3] 安裝 git。

  1. $ sudo apt install git

對於基於 Arch Linux 的系統,請使用 Pacman 命令[4] 安裝 git。

  1. $ sudo pacman -S git

對於 RHEL/CentOS 系統,請使用 YUM 命令[5] 安裝 git。

  1. $ sudo yum install git

對於 openSUSE Leap 系統,請使用 Zypper 命令[6] 安裝 git。

  1. $ sudo zypper install git

我們可以透過克隆clone開發人員的 GitHub 儲存庫輕鬆地安裝它。

首先克隆 Bash-insulter 儲存庫。

  1. $ git clone https://github.com/hkbakke/bash-insulter.git bash-insulter

將下載的檔案移動到檔案夾 /etc 下。

  1. $ sudo cp bash-insulter/src/bash.command-not-found /etc/

將下麵的程式碼新增到 /etc/bash.bashrc 檔案中。

  1. $ vi /etc/bash.bashrc
  2. #Bash Insulter
  3. if [ -f /etc/bash.command-not-found ]; then
  4. . /etc/bash.command-not-found
  5. fi

執行以下命令使更改生效。

  1. $ sudo source /etc/bash.bashrc

你想測試一下安裝是否生效嗎?你可以試試在終端上輸入一些錯誤的命令,看看它如何嘲諷你。

  1. $ unam -a
  2. $ pin 2daygeek.com

如果你想附加你自己的短語,則導航到以下檔案並更新它。你可以在 messages 部分中新增短語。

  1. # vi /etc/bash.command-not-found
  2. print_message () {
  3. local messages
  4. local message
  5. messages=(
  6. "Boooo!"
  7. "Don't you know anything?"
  8. "RTFM!"
  9. "Haha, n00b!"
  10. "Wow! That was impressively wrong!"
  11. "Pathetic"
  12. "The worst one today!"
  13. "n00b alert!"
  14. "Your application for reduced salary has been sent!"
  15. "lol"
  16. "u suk"
  17. "lol... plz"
  18. "plz uninstall"
  19. "And the Darwin Award goes to.... ${USER}!"
  20. "ERROR_INCOMPETENT_USER"
  21. "Incompetence is also a form of competence"
  22. "Bad."
  23. "Fake it till you make it!"
  24. "What is this...? Amateur hour!?"
  25. "Come on! You can do it!"
  26. "Nice try."
  27. "What if... you type an actual command the next time!"
  28. "What if I told you... it is possible to type valid commands."
  29. "Y u no speak computer???"
  30. "This is not Windows"
  31. "Perhaps you should leave the command line alone..."
  32. "Please step away from the keyboard!"
  33. "error code: 1D10T"
  34. "ACHTUNG! ALLES TURISTEN UND NONTEKNISCHEN LOOKENPEEPERS! DAS KOMPUTERMASCHINE IST NICHT FÜR DER GEFINGERPOKEN UND MITTENGRABEN! ODERWISE IST EASY TO SCHNAPPEN DER SPRINGENWERK, BLOWENFUSEN UND POPPENCORKEN MIT SPITZENSPARKEN. IST NICHT FÜR GEWERKEN BEI DUMMKOPFEN. DER RUBBERNECKEN SIGHTSEEREN KEEPEN DAS COTTONPICKEN HÄNDER IN DAS POCKETS MUSS. ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN."
  35. "Pro tip: type a valid command!"
  36. "Go outside."
  37. "This is not a search engine."
  38. "(╯°□°)╯︵ ┻━┻"
  39. "¯\_(ツ)_/¯"
  40. "So, I'm just going to go ahead and run rm -rf / for you."
  41. "Why are you so stupid?!"
  42. "Perhaps computers is not for you..."
  43. "Why are you doing this to me?!"
  44. "Don't you have anything better to do?!"
  45. "I am _seriously_ considering 'rm -rf /'-ing myself..."
  46. "This is why you get to see your children only once a month."
  47. "This is why nobody likes you."
  48. "Are you even trying?!"
  49. "Try using your brain the next time!"
  50. "My keyboard is not a touch screen!"
  51. "Commands, random gibberish, who cares!"
  52. "Typing incorrect commands, eh?"
  53. "Are you always this stupid or are you making a special effort today?!"
  54. "Dropped on your head as a baby, eh?"
  55. "Brains aren't everything. In your case they're nothing."
  56. "I don't know what makes you so stupid, but it really works."
  57. "You are not as bad as people say, you are much, much worse."
  58. "Two wrongs don't make a right, take your parents as an example."
  59. "You must have been born on a highway because that's where most accidents happen."
  60. "If what you don't know can't hurt you, you're invulnerable."
  61. "If ignorance is bliss, you must be the happiest person on earth."
  62. "You're proof that god has a sense of humor."
  63. "Keep trying, someday you'll do something intelligent!"
  64. "If shit was music, you'd be an orchestra."
  65. "How many times do I have to flush before you go away?"
  66. )

via: https://www.2daygeek.com/bash-insulter-insults-the-user-when-typing-wrong-command/

作者:Magesh Maruthamuthu[8] 選題:lujun9972 譯者:zero-mk 校對:wxy

贊(0)

分享創造快樂