warning: line editing not enabled

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?

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.


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.