Make the Ghostty terminal command line behave like a macOS text field when you use Bash. This project fixes the problem where Shift+Left Arrow prints D, Shift+Right Arrow prints C, or Shift+Arrow moves the cursor without selecting text. It also adds familiar Command and Option keyboard shortcuts for selecting, copying, cutting, pasting, moving, deleting, undoing, and redoing text.
If you searched for any of the following, this project is intended to solve that problem:
- Ghostty Shift Arrow does not select text
- Ghostty Shift Left prints D or Shift Right prints C
- Bash select text with Shift+Arrow on macOS
- GNU Readline macOS keyboard shortcuts
- Ghostty Command+A, Command+C, Command+X, or Command+Z in Bash
- macOS terminal Option+Arrow or Command+Arrow keybindings
\e[1;2Dor\e[1;2Cappears in a Bash prompt
Requirements:
- macOS
- Ghostty as the terminal
- Bash as the interactive shell
curl,tar, and standard macOS command-line tools
Run the installer:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Kntnt/ghostty-macos-keybindings/main/install.sh)"Then reload Ghostty with Command+Shift+, and restart the current Bash session:
exec bash -lYou can instead inspect the code before running it:
git clone https://github.com/Kntnt/ghostty-macos-keybindings.git
cd ghostty-macos-keybindings
./install.shThe installer is safe to run again when the project is updated. It replaces its own marked configuration blocks instead of adding duplicates.
| Shortcut | Bash command-line behavior |
|---|---|
| Shift+Left/Right | Select one character at a time |
| Shift+Up/Down | Extend the selection vertically |
| Option+Left/Right | Move one word |
| Option+Shift+Left/Right | Select one word at a time |
| Command+Left/Right | Move to the beginning/end of the line |
| Command+Shift+Left/Right | Select to the beginning/end of the line |
| Option+Up/Down | Move to the beginning/end of the logical line |
| Option+Shift+Up/Down | Select to the beginning/end of the logical line |
| Command+Up/Down | Move to the beginning/end of a multiline command |
| Command+Shift+Up/Down | Select to the beginning/end of a multiline command |
| Command+A | Select the complete current command |
| Command+C | Copy selected command text to the macOS clipboard |
| Command+X | Cut selected command text to the macOS clipboard |
| Command+V | Paste, replacing selected command text |
| Command+Z | Undo |
| Command+Shift+Z | Redo |
| Option+Backspace/Delete | Delete the previous/next word |
| Command+Backspace/Delete | Delete to the beginning/end of the line |
Normal Readline bindings such as Control+A, Control+E, Control+R, and history navigation continue to work. When Ghostty has a native mouse selection, Command+C copies that selection. Otherwise, it copies the selection in the current Bash command. Control+C still interrupts the foreground command.
Ghostty encodes modified cursor keys as terminal escape sequences. Shift+Left commonly reaches Bash as ESC [ 1 ; 2 D, while Shift+Right arrives as ESC [ 1 ; 2 C.
GNU Readline, Bash's usual command-line editor, does not provide a complete selection-aware widget for these sequences. With no suitable binding, part of the escape sequence may be consumed while its final D or C is inserted as ordinary text. Simple .inputrc macros can move the cursor and set a mark, but repeated Shift+Arrow presses tend to reset the selection anchor. That does not behave like selection in a normal macOS text field.
This project uses ble.sh, a Bash line editor with a real selection state. A small Ghostty configuration fragment lets the relevant Command shortcuts reach ble.sh. The included ble.sh profile disables syntax highlighting, automatic suggestions, completion menus, completion candidate coloring, and status decorations so the result remains close to normal GNU Readline.
The installer:
- Downloads a pinned ble.sh build from the official project and verifies its SHA-256 checksum.
- Installs it under
~/.local/share/ghostty-macos-keybindings/(or$XDG_DATA_HOME). - Installs the macOS editing bindings under
~/.config/ghostty-macos-keybindings/(or$XDG_CONFIG_HOME). - Adds clearly marked loading blocks to
~/.bashrc. - Ensures the active Bash login file loads
~/.bashrcwhen needed. - Adds a
config-fileinclude to the active Ghostty configuration. - Saves the original files under
~/.config/ghostty-macos-keybindings/backups/before changing them.
The ble.sh source code is not copied into this repository. It remains a separately maintained dependency downloaded from its official release.
Confirm that the current shell is Bash:
printf '%s\n' "$BASH_VERSION"An empty result means you are probably using zsh, fish, or another shell. This project configures Bash only.
Reload Ghostty and Bash after installation:
exec bash -lYou can validate the active Ghostty configuration with:
/Applications/Ghostty.app/Contents/MacOS/ghostty +validate-configThat is intentional macOS behavior: Command+C copies text. Use Control+C to interrupt a running command.
zsh uses ZLE and fish has its own line editor, so neither uses GNU Readline or these ble.sh bindings. Their keymaps require a different solution.
Shift+Arrow uses broadly supported terminal sequences. Command shortcuts require the modified-key protocol to pass through every layer between Ghostty and Bash. Older multiplexers and remote terminal configurations may filter those keys.
From a clone of the repository:
./uninstall.shOr run the standalone uninstaller:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Kntnt/ghostty-macos-keybindings/main/uninstall.sh)"The uninstaller removes only this project's marked blocks, configuration fragment, and private ble.sh installation. Backups are retained.
MIT. See LICENSE.
ble.sh is a separate project with its own license and copyright holders. Ghostty is a separate project and is not affiliated with this repository.