Reputation: 1715
I'm trying to create a keyboard shortcut to reset the current terminal. I'm using a .inputrc entry like this:
"\C-K": 'echo -en "\\033c"\n'
It works, however, I can't do that while typing a command.
For instance, if I'm typing a command like this (with the cursor at the end):
$ foobar
and press CTRL+K, it will become
$ foobarecho -en "\033c""
and, of course, it is not going to work. It is possible to do it?
I suppose it is possible, since that's what CTRL+L does. The only problem with CTRL+L is that it won't clear the entire terminal, including history, just what's on screen.
Upvotes: 3
Views: 1922
Reputation: 59080
I am not sure how to do that in inputrc
, but you can do it with the bind
command and its -x
option.
bind -x '"\C-K": "echo -en \\033c"'
You can put the above line in your .bashrc
and it will offer the same behaviour as the one you describe with CTRL+L.
Upvotes: 1
Reputation: 142
do not understand "reset the current terminal". Clean your terminal? If so you can use command clear
Upvotes: 0