自动更正目录名

其实感觉这个功能不是很有用,因为大多数情况下我们都是用tab直接补全目录名的,不过作者既然在这里说(chong)了(shu),那本着尊重作者的原则我也应该啰嗦下:

shopt -s cdspell

就是这货,开启更正目录开关。

比如:

cd /tmp/dir_1
➤ ls
hello
➤ cd hhllo
bash: cd: hhllo: No such file or directory
➤

没错,进不去。

但是当你开启那个神奇的开关之后:

shopt -s cdspell

shopt -s cdspell
➤ cd hhllo
hello
➤ pwd
/tmp/dir_1/hello
➤

进去了~这就是自动更正目录名的效果。

其实不仅如此,shopt还有好多可以玩的地方,有兴趣的同学可以探索下哦~

shopt -s xxxx是开启xxxx

shopt -u xxxx是关闭xxxx

shopt
autocd             off
cdable_vars        off
cdspell            on
checkhash          off
checkjobs          off
checkwinsize       on
cmdhist            on
compat31           off
compat32           off
compat40           off
compat41           off
compat42           off
complete_fullquote    on
direxpand          off
dirspell           off
dotglob            off
execfail           off
expand_aliases     on
extdebug           off
extglob            on
extquote           on
failglob           off
force_fignore      on
globstar           off
globasciiranges    off
gnu_errfmt         off
histappend         on
histreedit         off
histverify         off
hostcomplete       off
huponexit          off
interactive_comments    on
lastpipe           off
lithist            off
login_shell        off
mailwarn           off
no_empty_cmd_completion    off
nocaseglob         off
nocasematch        off
nullglob           off
progcomp           on
promptvars         on
restricted_shell    off
shift_verbose      off
sourcepath         on
xpg_echo           off

results matching ""

    No results matching ""