Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?
share|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. –  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
add comment

2 Answers 2

up vote 5 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.

share|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. –  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. –  Dennis Williamson Feb 1 '11 at 2:42
    
thanks for your information :) –  Alfred Feb 1 '11 at 2:51
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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