0

If I have a variable cmd I want to bind a key with the content of that variable

for example:

bind '"\C-h":"$cmd"'

but it doesn't work. How can I do?

user967489
  • 39
  • 2
  • 1
    check this posting http://stackoverflow.com/questions/4200800/in-bash-how-do-i-bind-a-function-key-to-a-command – Raihan Oct 30 '11 at 00:41

1 Answers1

0

Here you go:

bind -x '"\C-h":READLINE_LINE="$READLINE_LINE""$cmd"; ((READLINE_POINT += ${#cmd}));'

Tested on 4.2, works like a charm. Doesn't work on 3.x though. Hope you enjoy!

Rudolf Adamkovič
  • 31,030
  • 13
  • 103
  • 118