自动更正目录名

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

shopt -s cdspell

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

比如:

  1. cd /tmp/dir_1
  2. ls
  3. hello
  4. cd hhllo
  5. bash: cd: hhllo: No such file or directory

没错,进不去。

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

shopt -s cdspell

  1. shopt -s cdspell
  2. cd hhllo
  3. hello
  4. pwd
  5. /tmp/dir_1/hello

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

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

shopt -s xxxx是开启xxxx

shopt -u xxxx是关闭xxxx

  1. shopt
  2. autocd off
  3. cdable_vars off
  4. cdspell on
  5. checkhash off
  6. checkjobs off
  7. checkwinsize on
  8. cmdhist on
  9. compat31 off
  10. compat32 off
  11. compat40 off
  12. compat41 off
  13. compat42 off
  14. complete_fullquote on
  15. direxpand off
  16. dirspell off
  17. dotglob off
  18. execfail off
  19. expand_aliases on
  20. extdebug off
  21. extglob on
  22. extquote on
  23. failglob off
  24. force_fignore on
  25. globstar off
  26. globasciiranges off
  27. gnu_errfmt off
  28. histappend on
  29. histreedit off
  30. histverify off
  31. hostcomplete off
  32. huponexit off
  33. interactive_comments on
  34. lastpipe off
  35. lithist off
  36. login_shell off
  37. mailwarn off
  38. no_empty_cmd_completion off
  39. nocaseglob off
  40. nocasematch off
  41. nullglob off
  42. progcomp on
  43. promptvars on
  44. restricted_shell off
  45. shift_verbose off
  46. sourcepath on
  47. xpg_echo off