用 fortune 在终端随机打印一句格言

每次运行 fortune 都输出随机的格言、笑话或谚语。

macOS随机终端脚本低风险
运行 fortune 会随机打印一句名言;加 -s 只输出短句。

01命令

命令
$ fortune -s

02作用说明

fortune 会从多个文本库中随机取出一条,因此常见于 shell 启动文件和 MOTD。短句模式 -s 可避免大段文字,-o 则改用成人语录库。配合 cowsay 就是经典欢迎语。

03风险

风险低风险
使用条件brew install fortune
系统兼容性macOS with Homebrew installed
!注意: 部分语录库内容不适合共享日志;-o 专门选择成人语录库。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • Homebrew formula: fortune
    Homebrew · vendor-doc · 2026-09-20
    依据: Installs the fortune command with a bundled collection of quote databases.
  • fortune(6) — Debian manpage
    Debian · technical · 2026-09-20
    依据: Documents the fortune command, its databases and the -s short mode.

最后验证: 2026-09-20 · 分类: 开发者

06相关方案