Bash command line editing

Using the bash command line may seem difficult at first, if you are coming from a Windows world. However a few editing commands key strokes your life easier. A detailed Command Line Editing sheet may help, but you really only needs a few commands . Below C- means the Control key and M- the Meta (or esc) key:

Key Action
C-a (C-e) Move to the start (end) of the line
M-f (M-b) Move forward (backward) a word
C-b (C-f) Move back (forward) one character
C-k (u) Kill the text from the current cursor position to the end (start) of the line
M-d (M-DEL) Kill from the cursor to the end (start) of the current word, or if between words, to the end (start) of the next word
C-d  (DEL) Delete the character underneath (left of) the cursor
C-_ Undo the last thing that you did
C-l Clear the screen, reprinting the current line at the top
C-y Yank the most recently killed text back into the buffer at the cursor

Leave a Reply

Your email address will not be published. Required fields are marked *