Keyboard Shortcuts
比較完整的在這篇裡面http://halotis.com/2010/07/06/bash-keyboard-shortcuts/
列一些比較常用的
Moving the cursor
Ctrl + a Go to the beginning of the line (Home)
Ctrl + e Go to the End of the line (End)
Ctrl + p Previous command (Up arrow)
Ctrl + n Next command (Down arrow)
Alt + b Back (left) one word
Alt + f Forward (right) one word
Editing
Ctrl + L Clear the Screen, similar to the clear command
Ctrl + u Cut/delete the line before the cursor position.
Ctrl + k Cut the Line after the cursor to the clipboard.
Alt + backspace Delete the Word before the cursor.
Alt + d Delete the Word after the cursor.
Ctrl + w Cut the Word before the cursor to the clipboard.
Ctrl + y Paste the last thing to be cut
Ctrl + t Swap the last two characters before the cursor (typo).
Alt + t Swap current word with previous
Alt + u UPPER capitalize every character to the end of the current word.
Alt + l Lower the case of every character to the end of the current word.
Alt + / Attempt to complete filename
History
Ctrl + r Search the history backwards.
Ctrl + g Escape from history searching mode
!! Execute last command in history
!abc Execute last command in history beginning with abc
!n Execute n-th command in history
Other
Ctrl + x @ Show possible hostname completions.
Terminal Alt Shortcut Key Problem
Alt activate the menu item
Gnome Terminal 預設按 alt 會切換到 menu item. 但這會造成 Alt+f/Alt+b 無法使用, 如果想要取消這個功能可以在選單 Edit->Keyboard Shortcut 內把"Enable menu access keys"
"Enable the menu shortcut key"
都移除勾選
Alt+left / Alt+right key no use
在 Window/Putty 時,沒有這個問題,但在 Gnome Terminal 就出現了這個問題
檢查了一下 Alt+left key 的值, 發現在兩個環境內收到的不一樣!?
在 putty 環境內
# press Alt+left key $ read ^[^[[D # press Alt + right key $ read ^[^[[C
在 gnome terminal 內
# press Alt+left key $ read ^[[1;3D # press Alt + right key $ read ^[[1;3C
http://blog.simplicitymedialtd.co.uk/457/making-alt-leftalt-right-work-in-gnome-terminal-like-putty
目前還是不清楚為什麼會有這樣的狀況,但快速解法是修改 /etc/inputrc or ~/.inputrc
以滿足兩個狀況下的 Alt+array key 都能發揮作用
cat .inputrc # mapping for alt+left-arrow and alt+right-arrow for word moving "\e[1;3D": backward-word "\e[1;3C": forward-word "\e\e[C": forward-word "\e\e[D": backward-word
沒有留言:
張貼留言