I've been trying to re-think an old problem that didn't get answered. I know this is possible, but I'm having trouble getting it to run. I just want to call a function with a key-press or key combination. I looked and saw bind can be used to run functions and other scripts this way. Here's what I've been trying:
# Bind F12 to Ctrl-U
bind -x '"\e[24~": CtrlU';
And here's my error:
bind: warning: line editing not enabled
From what I saw in the bash man page and online I must be close. Any help would be much appreciated.
bind -l lists what bind is currently set up to do.
I don't see how it can do anything except what is related to "playing with" the readline library. AFAIK the "function" you refer to has to be part of readline. Which can be customized as well.
Please tell us:
What are PRECISELY you trying to do - not how you already tried to do it?
This what I mean by a macro - expanding a keypress into a fixed command
bind '"\M-k"':"\"ls -a\""
edit: look at your /etc/inputrc file ( assuming linux) to see pre-defined key bindings. Looking at your other post I think you are trying to use ^[ instead of \e for example.
This works ONLY when ls is a shell builtin, I believe.