Skip to content

Instantly share code, notes, and snippets.

@gregorynicholas
Last active April 19, 2024 04:10
Show Gist options
  • Save gregorynicholas/1812027 to your computer and use it in GitHub Desktop.
Save gregorynicholas/1812027 to your computer and use it in GitHub Desktop.
OSX .inputrc to make terminal way better. and by better i mean i'm naked
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": history-search-backward
"\e[6~": history-search-forward
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
set completion-ignore-case On
set expand-tilde on
set convert-meta off
set input-meta on
set output-meta on
set show-all-if-ambiguous on
set visible-stats on
set -o vi
Copy link

ghost commented Apr 1, 2012

also if you know vim, you can set bash or zsh to use vim with: "set -o vi" in your bashrc

@gregorynicholas
Copy link
Author

thanks @deshawnbw! that's for sure a solid

@jasonshanks
Copy link

I like the fast completion! Can you provide some explanation on what everything else does though? I'm assuming the first block is VI keyboard shortcuts?

@gregorynicholas
Copy link
Author

cheers @plmtr -- they are actually a number of helpful settings for the terminal input directly.. allowing for such things as skipping words with the control key and arrow cursors..

@jasonshanks
Copy link

Thanks @gregorynicholas - From a little web searching and hunt & pecking around I figured out that CTRL+A = beg of line, CTRL+E = end of line. I guess the next step would be commenting each line for us terminal intermediates such as myself!

@jasonm23
Copy link

Emacs nav keys work by default already, so alt-f / alt-b are forward / back word, alt-a / alt-e are forward back sentence / block, etc... etc...

@jasonm23
Copy link

Also zsh let's you do alt-x and then enter these shell navigation/control commands wit Tab completion too.

@jduthen
Copy link

jduthen commented Oct 20, 2013

@plmtr: instead of web searching and hunt, you might rtfm:
From Terminal.app: man bash
or, from within emacs: M-x man RET bash RET
and then search for "Commands for Moving"
HTH

@rampion
Copy link

rampion commented Jan 15, 2014

What keystroke is "\e[1~"?

@fetmar
Copy link

fetmar commented Jul 28, 2014

Backward word delete didn't work for me until I checked this setting:

Terminal | Preferences | Settings | Keyboard | Use option as meta key

And forward word delete only works once I add a key mapping in the same Keyboard panel with the following settings

  • Key: Forward Delete
  • Modifier: Option
  • Send text: /033d Hit esc, d to insert this

Now all is right in the universe.

@fetmar
Copy link

fetmar commented Jul 28, 2014

@gregorynicholas, this didn't seem to matter but 4 of the double quotes in your example are not actually " characters.

@Grazfather
Copy link

@rampion it's escape-home

@codekiln
Copy link

If "\e[1~" is escape home, what are the others?

@colemickens
Copy link

Lines 3 and 4 have smart quotes.

@gregorynicholas
Copy link
Author

@thom-nic
Copy link

thom-nic commented Feb 2, 2017

Most important lines in my .inputrc:

# From http://www.ukuug.org/events/linux2003/papers/bash_tips/
# Incremental searching with Up and Down. Type 'ssh <up>' to get the last 'ssh' command you used
"\e[A": history-search-backward
"\e[B": history-search-forward

@soshial
Copy link

soshial commented Mar 30, 2018

Reloading these combinations with source ~/.inputrc didn't work for me and this worked: bind -f ~/.inputrc

@mgiugliano
Copy link

Thank you @shoshial: that solved my problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment