You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何像打开x-man-page://链接一样打开本地文本文件

在MacOS黄色手册页阅读器中打开自定义文本

MacOS定义了一套x-man-page://command格式的URL,不管是通过浏览器访问,还是在Terminal里执行open x-man-page://command,都能唤起那个带黄色背景的手册页阅读器。实际上这个阅读器就是采用「Man Page」配置文件的Terminal窗口。

如果你想要实现打开指定配置文件的Terminal窗口,向其中写入文本并保持窗口打开(和打开手册页的效果一致),目前你可以用groff -man -Tps filename.txt | open -f -a Preview在Preview中打开文本,但更推荐用下面的方案直接使用黄色终端阅读器:

借助@Philippe提供的AppleScript,你可以定义以下shell函数,用它在该阅读器中打开大多数文本文件:

function reader {
  if [[ "$1" = /* ]]; then
    osascript ~/Code/scripts/xman_window.scpt "cat $1"
  elif [[ "$1" = ~/* ]]; then
    osascript ~/Code/scripts/xman_window.scpt "cat ${1/#\~/$HOME}"
  else
    osascript ~/Code/scripts/xman_window.scpt "cat $(pwd)/$1"
  fi
}

内容的提问来源于stack exchange,提问作者Hugo Schongin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 15:54:51