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?
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?
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!