描述的bash解决方案在bash中工作很好,但在fish中移植时失败。
鱼群配置
function configure_pager
# Colored man pages: http://linuxtidbits.wordpress.com/2009/03/23/less-colors-for-man-pages/
# Less Colors for Man Pages
set -gx LESS_TERMCAP_mb '\E[01;31m' # begin blinking
set -gx LESS_TERMCAP_md '\E[01;38;5;74m' # begin bold
set -gx LESS_TERMCAP_me '\E[0m' # end mode
set -gx LESS_TERMCAP_se '\E[0m' # end standout-mode
set -gx LESS_TERMCAP_so '\E[38;5;016m\E[48;5;220m' # begin standout-mode - info box
set -gx LESS_TERMCAP_ue '\E[0m' # end underline
set -gx LESS_TERMCAP_us '\E[04;38;5;146m' # begin underline
end鱼体渲染
我得到的不是颜色,而是未解释的代码: LS(1)用户命令LS(1)
\E[01;38;5;74mNAME\E[0m
ls - list directory contents
\E[01;38;5;74mSYNOPSIS\E[0m
\E[01;38;5;74mls\E[0m [\E[04;38;5;146mOPTION\E[0m]... [\E[04;38;5;146mFILE\E[0m]...
\E[01;38;5;74mDESCRIPTION\E[0m
List information about the FILEs (the current directory by default). Sort entries alphabetically if none of \E[01;38;5;74m-cftuvSUX\E[0m nor \E[01;38;5;74m--sort\E[0m is specified.问题
这可能是因为我在fish中对字符串文本变量使用了错误的语法。
set -gx LESS_TERMCAP_mb '\E[01;31m' # begin blinking原始bash是:
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking鱼类颜色编码的正确语法是什么?
发布于 2015-12-14 12:04:26
在bash版本中所做的是ANSI-C引文。这使得bash在将序列设置为变量之前对其进行解释。因此,LESS_TERMCAP_mb不包含文字字符串"\E[01;31m",但其中指定的序列--特别是"\E“是转义字符。
在fish中,您要做的是在引号之外指定转义序列-请参阅fish文档中关于引号的部分
set -gx LESS_TERMCAP_mb \e'[01;31m'诸若此类。
预览

https://stackoverflow.com/questions/34265221
复制相似问题