用慣了Linux下的bash,在Windows下對於那個cmd.exe很惱火,且不說雙引號區分參數這樣的“高級”問題,就是調個歷史命令都麻煩得很,命令行編輯能力相當弱。
最近發現了clink這個擴展,可以讓cmd.exe擁有幾乎readline的全部能力。
clink: Bringing Bash's powerful command line editing to Microsoft Windows' cmd.exe
http://code.google.com/p/clink/
- Powerful Bash-like line editing from GNU's Readline library. Read more on Readline's keyboard shortcuts.
- Superior path completion (TAB).
- Paste from clipboard (Ctrl-V).
- Support for the completion of executables/commands, and environment variables.
- Undo/Redo (Ctrl-_ or Ctrl-X, Ctrl-U)
- Improved command line history.
- Persists across sessions.
- Searchable (Ctrl-R and Ctrl-S).
- History expansion (e.g. !!, !<string>, and !$).
- Scriptable completion using Lua.
跟隨cmd自動啟動clink
clink的安裝程序帶有“Autorun when cmd.exe starts"選項,但如果你不想使用安裝程序,又想要在啟動cmd時自動啟動clink,可以按如下辦法:
- 打開注冊表編輯器,找到(或者新建)HKEY_CURRENT_USER\Software\Microsoft\Command Processor
- 在該鍵下新建一個字符串項,名為AutoRun
- 將AutoRun的值設置為一個bat文件的路徑,比如d:\cmdstart.cmd
- 編輯d:\cmdstart.cmd,里面寫一句 d:\tools\clink /inject (當然你也可以再添加其他命令)