【问题标题】:Can the bash "autocomplete" (via TAB TAB) entries be colored/formated?bash“自动完成”(通过 TAB TAB)条目可以着色/格式化吗?
【发布时间】:2016-04-20 21:42:08
【问题描述】:

背景:

我所说的“自动完成”功能是当您在 bash 中输入一半命令或文件名时,如果您按两次 TAB 键,它将打印出建议。

问题:

条目输出看起来像默认的ls 行为。

我怎样才能覆盖它以赋予它不同的颜色或格式(如ls)?

编辑:复制粘贴 Answer on UnixStackExchange - 在那里投票!

在 bash 4.3 及更高版本中可以添加

set colored-stats on

~/.inputrc

http://cnswww.cns.cwru.edu/php/chet/readline/rluserman.html:

colored-stats

如果设置为 `on',Readline 会使用不同的颜色显示可能的补全以指示其文件类型。颜色定义取自 LS_COLORS 环境变量的值。默认是`off'。

您可以使用http://geoff.greer.fm/lscolors/ 生成LS_COLORS(GNU lscolored-stats 使用)和LSCOLORS‏(BSD 使用ls)。

【问题讨论】:

标签: bash


【解决方案1】:

set coloured-stats on 附加到您的 input-rc 文件中。

[[ -f $INPUTRC ]] && echo set colored-stats on >> $INPUTRC

或者如果你有它在默认位置:

echo set colored-stats on >> ~/.inputrc

然后重启 bash。

就是这样。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-14
    • 1970-01-01
    • 2012-03-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-30
    • 1970-01-01
    相关资源
    最近更新 更多