如果你想查看手册页时,不会为你在查看所有这些颜色将仅增加less
,则应该在一个包装函数,这些变量man
,而不是将它们放在你的config.fish
。
整个过程就是在 at 创建一个新文件,在~/.config/fish/functions/man.fish
里面定义一个函数man
,设置必要的环境变量,然后调用原来的man
using 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)
小智 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)