Linux终端Tab提示忽略大小写

最近想在Linux终端设置Tab智能匹配大小写, 发现bsh和csh的设置完全不同, 查找之后将其分别进行了统计, 以供参考.

1. csh/tcsh

参考:autocomplete - cshell tab completion , case insensitive - Stack Overflow

set autolist = ambiguous 
set complete = enhance 

set complete = enhance completes . as anything. Without it its case sensitive. I'm irrationally annoyed by this

Here's a more verbose answer for the uber newbs:

Ratheesh Pai's answer is correct, but if you want the settings to persist, you want to write the commands to your .cshrc file. This file is executed any time you open a shell (assuming the .cshrc file is in your home directory. Think of the .cshrc file as a settings file - you add whatever personal preferences you want into it...

Here's how to setup tab completion:

cd ~
vim .cshrc

Insert in the two lines below into .cshrc

set autolist = ambiguous 
set complete = enhance

Then quit VIM.

Last, either re-open your shell (or source the .cshrc file):

source ./.cshrc

Then give it a shot, you should be able to case-insensitive tab complete.

2. bsh

参考: A ~/.inputrc for Humans - Top Bug Nethttps://www.topbug.net/blog/2017/07/31/inputrc-for-humans/

Copy and paste the code below to your ~/.inputrc file:

$include /etc/inputrc
"\C-p":history-search-backward
"\C-n":history-search-forward

set colored-stats On
set completion-ignore-case On
set completion-prefix-display-length 3
set mark-symlinked-directories On
set show-all-if-ambiguous On
set show-all-if-unmodified On
set visible-stats On

Here is the explanation.

$include /etc/inputrc: This line carries over site-wide readline configuration to the user configuration. Usually /etc/inputrc includes some goodies.

"\C-p":history-search-backward and "\C-n":history-search-forward: These two lines set Ctrl-P/Ctrl-N to search backward/forward through the history for the string of characters between the start of the current line and the current cursor position.

set colored-stats On: This line sets readline to display possible completions using different colors to indicate their file types. The colors are determined by the environmental variable LS_COLORS, which can be nicely configured.

set completion-ignore-case On: This line sets auto completion to ignore cases.

set completion-prefix-display-length 3: This line sets 3 to be the maximum number of characters to be the common prefix to display for completions. If the common prefix has more than 3 characters, they are replaced by ellipsis. For example, assume we are in a directory with files Screenshot_20170730.png and Screenshot_20170731.png. If using the default option, an auto completion prints Screenshot_20170730.png Screenshot_20170731.png. If this option is set, then the auto completion prints ...0.png ...1.png. However, if the common prefix is very short (fewer or equal to 3 characters), the full file names are still printed. For example, in a directory with files S10.png and S11.png, an auto completion still prints S10.png S11.png. This can be very useful when auto completing in a directory in which a lot of files have a long common prefix, such a camera image directory.

set mark-symlinked-directories On: This line sets every completion which is a symbolic link to a directory to have a slash appended.

set show-all-if-ambiguous On: This line sets the completions to be listed immediately instead of ringing the bell, when the completing word has more than one possible completion.

set show-all-if-unmodified On: This line sets the completions to be listed immediately instead of ringing the bell, when the completing word has more than one possible completion but no partial completion can be made.

set visible-stats On: This lines sets completions to be appended by characters that indicate their file types reported by the stat system call.

3.  csh/tcsh/bsh之间的区别 

参考: 几种常见的Shell:sh、bash、csh、tcsh、ash_鸟叔-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值