tags:

views:

34

answers:

2

I'd like to unbind C-d from sending EOF in bash, and set it to another key. The idea is to keep C-d as EOF in my .bashrc, but to rebind it in my .bash_profile, so that hitting C-d repeatedly with pull me out of any subshells I'm in, but leave me in my login shell.

Is this possible? C-d seems to be bound to delete-char, which it performs if there's text on the current line. It only sends EOF if there's no text on the current line. Rebinding delete-char to, say, C-f applies the delete-char action, but not the EOF sending.

Does Readline offer a way to rebind the EOF command?

+1  A: 

The behavior you're talking about is set by stty. Why don't you bind another keystroke to either emit C-d or nothing depending on whether you're in a login shell or a non-login shell and use that?

Dennis Williamson
+1  A: 

No, but stty eof will allow you to change the EOF character. And it's a really bad idea to do so.

msw
Why is changing the EOF character bad? I believe you, I'd just like to understand it.
Peeja
Too many things in the unix realm depend on EOF and if you train your fingers to behave differently, it will likely bite you in a situation you didn't expect and if you should ever sit down at keyboard with a standard binding, you'd be unhappy. My answer now sounds more dire than was intended , substitute "can I bind CAPS LOCK to generate SPACE" and my answer is the same.
msw