Nếu bạn chỉ muốn thêm các màu này khi xem các trang man, không phải cho tất cả mọi thứ bạn xem less, bạn nên đặt các biến này trong hàm bao bọc manthay vì đặt chúng vào config.fish.
Toàn bộ quá trình là tạo một tệp mới tại ~/.config/fish/functions/man.fishvà bên trong nó xác định một hàm manđặt các biến môi trường cần thiết, sau đó gọi bản gốc manbằng cách sử dụng command, truyền vào các đối số bằng cách sử dụng $argv.
Đây là phiên bản của tôi về chức năng bao bọc:
~/.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