GNU readline cheatsheet

在 Linux環境中,command line如bash或是interpreter如python常常有支援readline的keymap,以下整理常用的快速鍵,其他可參考以下連結

https://en.wikipedia.org/wiki/GNU_Readline

移動游標

  • Ctrl + f : move forward 1 character →
  • Ctrl + b : move backward 1 character ←
  • Alt + f : move forward 1 word
  • Alt + b : move backward 1 word
  • Ctrl + a : move to the start of the line
  • Ctrl + e : move to the end of the line
  • Ctrl + l : clear screen

command操作

  • Ctrl + n : next command in history ↓
  • Ctrl + p : prev command in history ↑
  • Ctrl + r : reverse search, 再Ctrl + r 再繼續search
  • Ctrl + g : abort search

Edit

  • Ctrl + t : 游標前後字元對調
  • Ctrl + w : 往前刪退一個word
  • Ctrl + k : 刪到行尾
  • Alt + u : uppercase the word after cursor
  • Alt + l : lowercase the word after cursor

離開

  • Ctrl + c : send SIGINT
  • Ctrl + d : send EOF

bash的特別指令

  • Ctrl + x Ctrl + v : show bash version
  • Ctrl + x Ctrl + e : edit current line with default editor 這個是滿好用的快速鍵,可以將現在這行跳到編輯器編輯完再返回bash執行,對於很長的命令需要剪剪貼貼的情境很好用
This entry was posted in System Administration. Bookmark the permalink.

Leave a Reply