Readline簡介 - Linux技術問答 - Linux中國 | Linux.cn - 我們的Linux中文社區
Readline簡介 [復制鏈接]
| 1744
Readline 是一個強大的庫,只要使用了它的程序,都可以用同一個配置文件配置,而且用同樣的方法操作命令行,讓你可以方便的編輯命令行。
使用 readline 的程序現在主要有 Bash, GDB,ftp 等。readline 付予這些程序強大的 Emacs 似的命令行編輯方式,你可以隨意綁定你的鍵盤。
所有使用readline的程序,都使用一個配置文件來決定它的行為和鍵綁定。這個文件一般是 INPUTRC 環境變量確定的。如果這個環境變量沒有值,那么缺省使用 ~/.inputrc。
--------------------------------------------------------------------------------------------------------------------------------
方向 刪除
ctrl + k? ?? ?刪除光標后面所有字符相當于VIM里d shift+$
ctrl + u? ?? ?刪除光標前面所有字符相當于VIM里d shift+^
ctrl + w? ?? ?刪除光標前一個單詞相當于VIM里db
ctrl + y? ?? ?恢復ctrl+u上次執行時刪除的字符
ctrl + r? ?? ? 輸入單詞搜索歷史命令
ctrl + s? ?? ?鎖住終端
ctrl + q? ?? ?解鎖終端
ctrl + l? ?? ???清屏相當于命令clear
ctrl + ?? ?? ?撤消前一次輸入
PS:
CTRL 鍵相關的快捷鍵:Ctrl + a - Jump to the start of the line
Ctrl + b - Move back a char
Ctrl + c - Terminate the command??//用的最多了吧?
Ctrl + d - Delete from under the cursor
Ctrl + e - Jump to the end of the line
Ctrl + f - Move forward a char
Ctrl + k - Delete to EOL
Ctrl + l - Clear the screen??//清屏,類似 clear 命令
Ctrl + r - Search the history backwards??//查找歷史命令
Ctrl + R - Search the history backwards with multi occurrence
Ctrl + u - Delete backward from cursor // 密碼輸入錯誤的時候比較有用
Ctrl + xx - Move between EOL and current cursor position
Ctrl + x @ - Show possible hostname completions
Ctrl + z - Suspend/ Stop the command
補充:
Ctrl + h - 刪除當前字符
Ctrl + w - 刪除最后輸入的單詞
ALT 鍵相關的快捷鍵:
平時很少用。有些和遠程登陸工具沖突。
Alt +??- Move to the last line in the history
Alt + ? - Show current completion list
Alt + * - Insert all possible completions
Alt + / - Attempt to complete filename
Alt + . - Yank last argument to previous command
Alt + b - Move backward
Alt + c - Capitalize the word
Alt + d - Delete word
Alt + f - Move forward
Alt + l - Make word lowercase
Alt + n - Search the history forwards non-incremental
Alt + p - Search the history backwards non-incremental
Alt + r - Recall command
Alt + t - Move words around
Alt + u - Make word uppercase
Alt + back-space - Delete backward from cursor
// SecureCRT 如果沒有配置好,這個就很管用了。
其他特定的鍵綁定:
輸入 bind -P 可以查看所有的鍵盤綁定。這一系列我覺得更為實用。
Here "2T" means Press TAB twice
$ 2T - All available commands(common) //命令行補全,我認為是 Bash 最好用的一點
$ (string)2T - All available commands starting with (string)
$ /2T - Entire directory structure including Hidden one
$ ./2T - Only Sub Dirs inside including Hidden one
$ *2T - Only Sub Dirs inside without Hidden one
$ ~2T - All Present Users on system from "/etc/passwd" //第一次見到,很好用
$ $2T - All Sys variables //寫Shell腳本的時候很實用
$ @2T - Entries from "/etc/hosts"??//第一次見到
$ =2T - Output like ls or dir //好像還不如 ls 快捷
補充:
Esc + T - 交換光標前面的兩個單詞
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
