How do you bind a key sequence to shell command? Using stock Terminal.app on El Capitan, the effort is to set up a shortcut in a sense, that upon press it would execute a specific command.

Consulting man pages for bind command following steps have been taken but yielded no results.

First approach was to place the setting inside ~/.inputrc file and let the login session do its work. The current state of the file is:

"\C-s": "ssh hostname"


Second, used bind command directly.

$ bind '"\C-s": "ssh hostname"'


appendix:

GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Add a newline character to the end, for example:

bind '"\C-s": "ssh hostname\n"'


Another thing is what key sequence you want to bind the command to, and if it's not already handled by the system. For example, for F12, which is available, you'd use:

bind '"\e[24~": "ssh hostname\n"'