最近想在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之间的区别