Skip to content

Instantly share code, notes, and snippets.

@JakubAndrysek
Last active January 25, 2025 12:15
Show Gist options
  • Save JakubAndrysek/0e8862fe19920185ac4859caab411c33 to your computer and use it in GitHub Desktop.
Save JakubAndrysek/0e8862fe19920185ac4859caab411c33 to your computer and use it in GitHub Desktop.
#!/bin/sh
echo -e "\
╔════════════════════════════════════════════╗
║ BASH KEYBOARD SHORTCUTS ║
╚════════════════════════════════════════════╝
\033[1mCursor Movement:\033[0m
\033[1mCtrl + A\033[0m |← Move cursor to the \033[3mbeginning\033[0m of the line
\033[1mCtrl + E\033[0m →| Move cursor to the \033[3mend\033[0m of the line
\033[1mCtrl + B\033[0m ← Move \033[3mback\033[0m one character
\033[1mCtrl + F\033[0m → Move \033[3mforward\033[0m one character
\033[1mAlt + B\033[0m ←← Move \033[3mbackward\033[0m one word
\033[1mAlt + F\033[0m →→ Move \033[3mforward\033[0m one word
\033[1mEditing:\033[0m
\033[1mCtrl + W\033[0m Delete the \033[3mlast word\033[0m (back to whitespace)
\033[1mCtrl + U\033[0m Delete from cursor to the \033[3mstart\033[0m of the line
\033[1mCtrl + K\033[0m Delete from cursor to the \033[3mend\033[0m of the line
\033[1mCtrl + Y\033[0m \033[3mYank\033[0m (paste) the last killed text
\033[1mOther:\033[0m
\033[1mCtrl + L\033[0m Clear the screen (\033[3msame as 'clear'\033[0m)\n"

How to Use the terminal-shortcut Script

image

This guide will walk you through the steps to download, rename, grant execute permissions, and use the terminal-shortcut script.

Step 1: Download the Script from Gist

Find the Gist URL containing the terminal-shortcut script.

Use the curl or wget command to download it to your working directory.

Using curl

curl -O https://gist.githubusercontent.com/JakubAndrysek/0e8862fe19920185ac4859caab411c33/raw/ae189d22cc7ec58a41c8c2e0a6e881eba57dbe3e/terminal-shortcut

Using wget

wget https://gist.githubusercontent.com/JakubAndrysek/0e8862fe19920185ac4859caab411c33/raw/ae189d22cc7ec58a41c8c2e0a6e881eba57dbe3e/terminal-shortcodes

Step 2: Rename the Script

Rename the downloaded file to terminal-shortcodes for easier usage.

mv <DOWNLOADED_FILE_NAME> terminal-shortcodes

Step 3: Grant Execute Permissions

Give the script executable permissions so you can run it directly.

chmod +x terminal-shortcodes

Step 4: Run the Script

Execute the script to display the terminal keyboard shortcuts in a readable format.

./terminal-shortcodes

Maybe add to the PATHs

Example Output

╔════════════════════════════════════════════╗
║         BASH KEYBOARD SHORTCUTS            ║
╚════════════════════════════════════════════╝

Cursor Movement:
  Ctrl + A    |←  Move cursor to the beginning of the line
  Ctrl + E    →|  Move cursor to the end of the line
  Ctrl + B    ←   Move back one character
  Ctrl + F    →   Move forward one character
  Alt + B     ←←  Move backward one word
  Alt + F     →→  Move forward one word

Editing:
  Ctrl + W    Delete the last word (back to whitespace)
  Ctrl + U    Delete from cursor to the start of the line
  Ctrl + K    Delete from cursor to the end of the line
  Ctrl + Y    Yank (paste) the last killed text

Other:
  Ctrl + L    Clear the screen (same as 'clear')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment