2009-08-10 14 views
9

如何在Ubuntu中獲得類似的突出顯示Zsh's Less Bash's Less?在Ubuntu的Zsh中讓顏色變得更少

我從OS X切換到Ubuntu。我的Less在Zsh中沒有按預期工作。

my Less中的手冊是綠色和黑色,有或沒有以下代碼。

# comment these out in Ubuntu 
export LESS_TERMCAP_mb=$'\E[01;31m'   # begin blinking 
export LESS_TERMCAP_me=$'\E[0m'  # end mode 

export LESS_TERMCAP_se=$'\E[0m'  # end standout-mode 
export LESS_TERMCAP_so=$'\E[38;5;246m' # begin standout-mode - info box 
export LESS_TERMCAP_ue=$'\E[0m'  # end underline 

export LESS_TERMCAP_us=$'\E[04;33;146m' # begin underline is now yellow 
#        | | | 
#        | |----------------- yellow 
#        |-------------------- underline 

# to have the indication of cursor's location and line numbers, and R 
export LESS="-mNR" 
#    |--------- only ASCII color 

該代碼使手冊在OS X中可讀,但它在Zsh中不適用於Ubuntu。

Ubuntu在Bash's Less中具有出色的突出性。我的手冊在Bash中的顏色是黃色,綠色和黑色,沒有我的代碼。 Zsh和Bash在/usr/bin/less處使用相同的Less。這表明我的Ubuntu的Bash有一些在某處配置它的點文件。

Ubuntu的Less in Bash的亮點在哪裏?

+1

@LubošTurek所以最後我創建了[tag:less-unix],所以如果你打算取消Linux的更少的請求,請求考慮在其位置添加這一個。 – fedorqui 2017-05-03 10:58:31

回答

8

This作品爲我的zsh上的archlinux:

$ mkdir ~/.terminfo/ && cd ~/.terminfo 
Now get the terminfo description: 
$ wget http://nion.modprobe.de/mostlike.txt 
Now compile it using tic (the terminfo entry-description compiler) 
$ tic mostlike.txt 
(you may want to delete the mostlike.txt file after compiling) 

mostlike.txt是這個

# Reconstructed via infocmp from file: /usr/share/terminfo/x/xterm-pcolor 
mostlike|manpages with color looking like most, 
    am, hs, km, mir, msgr, xenl, 
    cols#80, it#8, lines#24, wsl#40, 
    acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
    bel=^G, bold=\E[1m\E[31m, clear=\E[H\E[2J, cr=^M, 
    csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, 
    cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, 
    cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
    dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
    dsl=\E]0;\007, ed=\E[J, el=\E[K, enacs=\E)0, fsl=^G, 
    home=\E[H, ht=^I, hts=\EH, il=\E[%p1%dL, il1=\E[L, ind=^J, 
    is2=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>, kbs=^H, 
    kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, 
    kdch1=\E[3~, kf1=\E[11~, kf10=\E[21~, kf11=\E[23~, 
    kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, 
    kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, 
    kf2=\E[12~, kf20=\E[34~, kf3=\E[13~, kf4=\E[14~, 
    kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, 
    kfnd=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
    kslt=\E[4~, rc=\E8, rev=\E[7m\E[34m, ri=\EM, rmacs=^O, 
    rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E[?1l\E>, 
    rmso=\E[m, rmul=\E[m, 
    rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>, sc=\E7, 
    sgr0=\E[m, smacs=^N, smcup=\E7\E[?47h, smir=\E[4h, 
    smkx=\E[?1h\E=, smso=\E[1;30m\E[47m, smul=\E[32m, 
    tbc=\E[3g, tsl=\E]0;, u6=\E[%i%d;%dR, u7=\E[6n, 
    u8=\E[?1;2c, u9=\E[c, 

然後就是在你最喜歡的外殼的RC文件中定義的別名:

alias man="TERMINFO=~/.terminfo/ LESS=C TERM=mostlike PAGER=less man" 
+0

謝謝你的回答! – 2009-08-11 02:49:55

+1

感謝您的問題 - 我不知道這件事,但我總是暗暗想要它.. – 0x89 2009-08-11 10:19:00

+0

我在這裏添加了鏈接的內容,因爲僅鏈接的答案是不合適的。 – 2015-06-24 10:04:08

1

我的默認外殼是bash所以帶上一粒鹽。從/etc/profile開始,看看它是如何輸入特定於bash的文件的。您需要重新創建zsh的邏輯。也許zsh-lovers包可以提供幫助,至少它的標題提示,技巧和示例爲zsh 是暗示性的。

相關問題