1

I'd like to bind Ctrl + L to tput reset rather than clear. Any ideas how to accomplish this?

1

You can use a nice program called AutoKey, which allows you to bind keyboard shortcuts with text actions. To do what you need would be super easy. Take a look at this snapshot, you can copy paste itctrl+l in autokey

| improve this answer | |
  • The keyboard.send_key("<enter>") doesn't seem to work for terminal. The alternative fake_keypress does work, but with too large of a delay. – bfletch May 18 '17 at 21:06
0

This is not for bash, so I will not accept this self posted answer.

I use zsh, and the following at the end of my .zshrc file works well for me:

# Hard clear shortcut
function hard_clear() {
  bak_buff=$BUFFER
  BUFFER="tput reset"
  zle accept-line 
  zle -U $bak_buff
}
zle -N hard_clear
bindkey "^[k" hard_clear

We create a function hard_clear() which backs up the buffer, replaces the buffer with tput reset, executes, then rewrites the old buffer. This function is bound to Alt + k.

| improve this answer | |
0

If you are using zsh you can just use

bindkey "^[k" clear-screen

Works just as well and no need to define a function.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.