Monday, July 6, 2015

Bash - Few shortcuts to make our life easier


Navigate the cursor inside the current command statement
Ctrl + a - Start of the command
Ctrl + e - End of the command
Ctrl + f - Move to the next character
Ctrl + b - Move to the previous character
Alt + right_arrow - End of the current word or the next word
Alt + left_arrow - Start of the current word or the previous word
                      
Delete
Ctrl + k - Delete from current cursor position to the end of the command
Ctrl + u - Delete from current cursor position to the start of the command
Ctrl + w - Delete one word before the cursor
Ctrl + h - Delete one character before the cursor (Backspace)
Ctrl + d - Delete the current character under the cursor
                      
Search History
Ctrl + r - Find the command with the phrase you type.It searches the
history as you type. For each consecutive hit "Ctrl + r", it finds the
next match in the history and moves to the start of the history.
!! - Repeat the last command
!xyz - Find the latest command starting with xyz from the history and run it
!xyz:p - Print the latest command starting with xyz from the history
!$ - Last argument of previous command
!* - All arguments of previous command
^abc^def - Replace abc with def in the previous command and run it
                      
Process
$$ - Gets the pid of the current bash/script
$! - Pid of the last background process
$? - Exit status of the last command
                      

No comments :

Post a Comment