I found this helpful command bind -x '"\C-r"':reset to clear the terminal but I wanted to make a simple bash script:

#!/bin/bash
bind -x '"\C-r"':reset

output:

alfred@alfred-laptop:~/bash$ ./bind 
./bind: line 2: bind: warning: line editing not enabled

Could someone please explain:

  1. How can I fix this?
  2. What does warning: line editing not enabled mean?
link|improve this question
I fixed this already using echo -e '\0033\0143' thanks to superuser.com/questions/122911/bash-reset-and-clear-commands/…, but I still would like to know what this error means and how to fix this. Many thanks. – alfredwesterveld Feb 1 '11 at 1:55
@squircle thanks for good improvements. Might you also know answer to my question :P? – alfredwesterveld Feb 1 '11 at 2:10
feedback

1 Answer

up vote 2 down vote accepted

You need to source that script. Do . ./bind or source ./bind to make that key binding active in the current session.

Running it normally, it doesn't have a terminal so it gives you that error message. Also, if it were to work, it would only be active for the duration of the script.

If you want that keybinding to be persistent, add that command to your ~/.bashrc.

link|improve this answer
1. I know about the persistence. 2. Your example does work, but adds complexity running command(in my opinion). I guess I now know this, but I would like to have a simple bash file which I can run without this source. – alfredwesterveld Feb 1 '11 at 2:25
1  
@alfredwesterveld: If you don't want the binding loaded every time you start a shell, but you want to be able to activate it any time without having to use source or dot (.), add a function to your ~/.bashrc: rbind () { bind -x '"\C-r"':reset; } then you can enter rbind by itself as a command and the binding will be activated. – Dennis Williamson Feb 1 '11 at 2:42
thanks for your information :) – alfredwesterveld Feb 1 '11 at 2:51
feedback

Your Answer

 
or
required, but never shown

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