Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save AlvinLaiPro/2482adcf9e2dda9c25a840919dca6b96 to your computer and use it in GitHub Desktop.

Select an option

Save AlvinLaiPro/2482adcf9e2dda9c25a840919dca6b96 to your computer and use it in GitHub Desktop.

Revisions

  1. @tuxfight3r tuxfight3r revised this gist May 5, 2016. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
  2. @tuxfight3r tuxfight3r renamed this gist May 5, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @tuxfight3r tuxfight3r renamed this gist May 5, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @tuxfight3r tuxfight3r revised this gist May 5, 2016. 1 changed file with 75 additions and 0 deletions.
    75 changes: 75 additions & 0 deletions bash_shortcuts_v2.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,75 @@
    Bash
    ====

    ## Moving

    | command | description |
    |----------|--------------------------------|
    | ctrl + a | Goto BEGINNING of command line |
    | ctrl + e | Goto END of command line |
    | ctrl + b | move back one character |
    | ctrl + f | move forward one character |
    | alt + f | move cursor FORWARD one word |
    | alt + b | move cursor BACK one word |

    ## Other

    | command | description |
    |----------|--------------------------------|
    | ctrl + d | Delete the character under the cursor |
    | ctrl + l | Clear the screen (same as clear command) |
    | ctrl + p | Fetch the previous command from the history list, moving back in the list (same as up arrow) |
    | ctrl + n | Fetch the next command from the history list, moving forward in the list (same as down arrow) |
    | ctrl + u | Clear all BEFORE cursor |
    | ctrl + k | Clear all AFTER cursor |
    | ctrl + r | Search backward starting at the current line and moving 'up' through the history as necessary |
    | crtl + s | Search forward starting at the current line and moving 'down' through the history as necessary |
    | ctrl + c | kill whatever is running |
    | ctrl + d | Exit shell (same as exit command) |
    | ctrl + w | delete the word BEFORE the cursor |
    | ctrl + t | swap the last two characters before the cursor |
    | ctrl + y | paste (if you used a previous command to delete) |
    | ctrl + z | Place current process in background |
    | ctrl + _ | undo |
    | esc + t | Swap last two words before the cursor |
    | esc + . | |
    | esc + _ | |
    | alt + [Backspace] | delete PREVIOUS word |
    | alt + < | Move to the first line in the history |
    | alt + > | Move to the end of the input history, i.e., the line currently being entered |
    | alt + ? | |
    | alt + * | |
    | alt + . | print the LAST ARGUMENT (ie "vim file1.txt file2.txt" will yield "file2.txt") |
    | alt + c | |
    | alt + d | |
    | alt + l | |
    | alt + n | |
    | alt + p | |
    | alt + r | |
    | alt + t | |
    | alt + u | |
    | ~[TAB][TAB] | List all users |
    | $[TAB][TAB] | List all system variables |
    | @[TAB][TAB] | List all entries in your /etc/hosts file |
    | [TAB] | Auto complete |
    | !! | Run PREVIOUS command (ie `sudo !!`) |
    | !vi | Run PREVIOUS command that BEGINS with vi |
    | cd - | change to PREVIOUS working directory |

    # Kill a job

    n = job number, to list jobs, run `jobs`

    ```bash
    kill %n
    ```

    Example:

    ```bash
    kill %1
    ```

    ## References

    1. http://cnswww.cns.cwru.edu/php/chet/readline/readline.html
  5. @tuxfight3r tuxfight3r created this gist Dec 17, 2014.
    27 changes: 27 additions & 0 deletions bash_keyboard_shortcuts.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@

    Ctrl-a Move to the start of the line.
    Ctrl-e Move to the end of the line.
    Ctrl-b Move back one character.
    Alt-b Move back one word.
    Ctrl-f Move forward one character.
    Alt-f Move forward one word.
    Ctrl-] x Where x is any character, moves the cursor forward to the next occurance of x.
    Alt-Ctrl-] x Where x is any character, moves the cursor backwards to the previous occurance of x.
    Ctrl-u Delete from the cursor to the beginning of the line.
    Ctrl-k Delete from the cursor to the end of the line.
    Ctrl-w Delete from the cursor to the start of the word.
    Esc-Del Delete previous word (may not work, instead try Esc followed by Backspace)
    Ctrl-y Pastes text from the clipboard.
    Ctrl-l Clear the screen leaving the current line at the top of the screen.
    Ctrl-x Ctrl-u Undo the last changes. Ctrl-_ does the same
    Alt-r Undo all changes to the line.
    Alt-Ctrl-e Expand command line.
    Ctrl-r Incremental reverse search of history.
    Alt-p Non-incremental reverse search of history.
    !! Execute last command in history
    !abc Execute last command in history beginning with abc
    !abc:p Print last command in history beginning with abc
    !n Execute nth command in history
    !$ Last argument of last command
    !^ First argument of last command
    ^abc^xyz Replace first occurance of abc with xyz in last command and execute it