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

bind -x '"\C-r"':reset


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?
  • 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.
    – Alfred
    Feb 1 '11 at 1:55
  • @squircle thanks for good improvements. Might you also know answer to my question :P?
    – Alfred
    Feb 1 '11 at 2:10
  • 7
    Just for the record (because this hasn't really been answered): you get "line editing not enabled", because in the bash that is spawned when you invoke your script it simply isn't enabled and you have to do it yourself, .e.g by inserting a set -o emacs or set -o vi into your script (before the bind, of course). Nov 27 '15 at 17:01
  • could try piping it to dev null. bind -x '"\C-r"':reset 2>/dev/null;
    – john-jones
    Oct 12 at 11:11
  • Just use Ctrl+L
    – Ben_LCDB
    Nov 10 at 8:30

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.

  • 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.
    – Alfred
    Feb 1 '11 at 2:25
  • 2
    @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. Feb 1 '11 at 2:42

I had a similar message but mine was from a script being run outside of an interactive (login) shell; it was a shell script being run via a CGI script. My message was:

/home/richard/.bash_profile: line 4: bind: warning: line editing not enabled

and although it wasn't actually on line 4, the only bind in that file was:

bind 'set completion-ignore-case on'

which of course only makes sense if line editing is enabled, i.e. if it's an interactive shell.


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.