如何在鱼壳下获取彩色手册页?

Ash*_*ppa 12 colors fish manpage

似乎有一种方法可以让手册页以彩色显示(请参阅此处。它涉及设置与 less 相关联的环境变量并将这些定义添加到.bashrc。我尝试在鱼壳中执行相同操作config.fish,但没有颜色输出。

如何在鱼壳中获取彩色手册页?

Ror*_*ane 7

如果你想查看手册页时,不会为你在查看所有这些颜色将仅增加less,则应该在一个包装函数,这些变量man,而不是将它们放在你的config.fish

整个过程就是在 at 创建一个新文件,在~/.config/fish/functions/man.fish里面定义一个函数man,设置必要的环境变量,然后调用原来的manusing command,传入参数 using $argv

这是我的包装函数版本:

~/.config/fish/functions/man.fish
function man --description "wrap the 'man' manual page opener to use color in formatting"
  # based on this group of settings and explanation for them:
  # http://boredzo.org/blog/archives/2016-08-15/colorized-man-pages-understood-and-customized
  # converted to Fish shell syntax thanks to this page:
  # http://askubuntu.com/questions/522599/how-to-get-color-man-pages-under-fish-shell/650192

  # start of bold:
  set -x LESS_TERMCAP_md (set_color --bold red)
  # end of all formatting:
  set -x LESS_TERMCAP_me (set_color normal)

  # start of standout (inverted colors):
  #set -x LESS_TERMCAP_so (set_color --reverse)
  # end of standout (inverted colors):
  #set -x LESS_TERMCAP_se (set_color normal)
  # (no change – I like the default)

  # start of underline:
  #set -x LESS_TERMCAP_us (set_color --underline)
  # end of underline:
  #set -x LESS_TERMCAP_ue (set_color normal)
  # (no change – I like the default)

  command man $argv
end
Run Code Online (Sandbox Code Playgroud)

  • 很好,谢谢!要想变得更加可疑,你可以使用 `set_color` 命令。例如:`set -x LESS_TERMCAP_md (set_color -o red)`、`set -x LESS_TERMCAP_me (set_color normal)` (2认同)

小智 6

您可以通过以下命令设置配置,

set -x LESS_TERMCAP_mb (printf "\033[01;31m")  
set -x LESS_TERMCAP_md (printf "\033[01;31m")  
set -x LESS_TERMCAP_me (printf "\033[0m")  
set -x LESS_TERMCAP_se (printf "\033[0m")  
set -x LESS_TERMCAP_so (printf "\033[01;44;33m")  
set -x LESS_TERMCAP_ue (printf "\033[0m")  
set -x LESS_TERMCAP_us (printf "\033[01;32m")  
Run Code Online (Sandbox Code Playgroud)