Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am working in Linux and C-shell. Often times I would require to change some portion of what is there already in the prompt that I obtain from reverse searching through the history command by use of CTRL+R. I do not want to use the Backspace for doing this. I have looked at this question on superuser.com which was specifically for bash. This answer says to use CTRL+U which would clear out everything before the current cursor position. But this is clearing out everything for me even though I have hit a few backspaces and now am at the middle of the text in the prompt. Is there a C-shell specific way of achieving the same in Linux?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

In tcsh (which I suppose is what you're calling "C-Shell" if you're not totally masochist) in emacs mode (usually the default), you can use Ctrl-W. That's the kill-region widget which deletes between the mark (set with Ctrl-Space but defaults to the beginning of the line) and the cursor.

In that regard, its behaviour is closer to emacs' than with bash(readline)/ksh/zsh emacs mode, but departs from the terminal driver embedded line editor (in canonical mode), where Ctrl-W deletes the previous word (werase, also in vi). That time it chose emacs over usual terminal behaviour but not in the case of Ctrl-U where in emacs it's the universal argument while it's the kill-line character in the terminal.

If you'd rather Ctrl-U delete to the beginning of the line, you can also do:

bindkey '^U' backward-kill-line

En vi mode, Esc to go to command mode, and d0 to delete to the beginning of the line (or c0 if you want to change instead of deleting that).

share|improve this answer
    
You said "In that regard, its behaviour is closer to emacs' than with bash(readline)/ksh/zsh emacs mode, but departs from the terminal driver embedded line editor (in canonical mode)". Can you please explain what you meant by emacs' and bash(readline)/ksh/zsh emacs mode and terminal driver embedded line editor(in canonical mode)? –  Geek Aug 2 '13 at 8:38
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.