Is it possible to create a bash function that return to the current line?
For example
#~/.bashrc
do-magic() {
# do some magic and return the input to current prompt line
# for example "hello"
}
bind -x '"\C-e":do-magic'
Then
$ echo <ctrl+e>
# become
$ echo hello
Best Answer
As of Bash 4.0 you can do this by changing the
READLINE_LINE
andREADLINE_POINT
variables inside the function. (The 'point' is the current cursor position.) For example: