LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-15-2006, 05:24 AM   #1
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Rep: Reputation: 36
bash: How to make ^u kill entire line, not just to beginning


All,

On Slack 10.2/current with bash, pressing ^u on the command-line kills the content from cursor to the beginning of the line, instead of killing the entire contents of the input. I have the proper stty ^u statement, but it seems like it's bash's ReadLine that needs configuration in the ~/.inputrc to tell it to kill the entire line, rather than just from cursor to start.

Does anyone have a sample entry in .inputrc that does this? I've played around with various set commands and "Control-u":kill-entire-line settings, but so far found none that work..

Thanks in advance, and Happy Holidays!

-Y1
 
Old 04-15-2006, 10:03 AM   #2
tobyl
Member
 
Registered: Apr 2003
Location: uk
Distribution: slackware current
Posts: 769

Rep: Reputation: 66
in your .inputrc, try

"\C-u": kill-whole-line

enter ctrl-x ctrl-r to get the file re-read first

this may depend on how some other environment variables are set, but see how you go

tobyl
 
Old 04-15-2006, 11:49 AM   #3
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Original Poster
Rep: Reputation: 36
Thanks tobyl,

Unfortunately I've tried that and quite a few variants, and my ~/.inputrc (perm rwx) has tried both "\C-u": kill-whole-line and "Control-u":kill-whole-line, but none work. It keeps its "default" behaviour of killing from cursor to the beginning of the line, leaving the characters after the cursor.

Pressing ^E ^U works, as it first moves the cursor to the end, and then erases all infront, but that's not the behaviour I'm looking for here..

Additionally, it'd be nice to understand how this actually works, as I am only beginning to grasp how powerful the readline system is.

Could the emacs mode be part of the reason, rather than vi-mode?

Anyone else experiencing this ^u behaviour in bash?

-Y1
 
Old 04-15-2006, 12:59 PM   #4
tobyl
Member
 
Registered: Apr 2003
Location: uk
Distribution: slackware current
Posts: 769

Rep: Reputation: 66
Quote:
Could the emacs mode be part of the reason, rather than vi-mode?
yes! I was playing around, and found that if you put the line I quoted in your .inputrc (i'm sure "Control-u":kill-whole-line is fine too)

then

set -o emacs

then ctrl-x ctrl-r as before, it works as you want

if I do
set | grep emacs
I get
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor=emacs

I think this is the important bit



if you use the set command it seems necessary to re-read the .inputrc

Quote:
Anyone else experiencing this ^u behaviour in bash?
probably, because it is the default behaviour.
kill-whole-line is not bound by default to any key combination

(I only know this because your post got me curious)

tobyl
 
Old 04-15-2006, 11:45 PM   #5
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
Also, I know that Ctrl-K kills everything from the cursor to the end of the line, so together with Ctrl-U, that kills the whole line, right? Perhaps there are other control sequences that do this better?
 
Old 04-17-2006, 01:19 PM   #6
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Original Poster
Rep: Reputation: 36
Tried the emacs options, and still can't get it to work. I know I can use ^E ^U or ^U ^K, but now I'm curious as to these bindings and would really like to understand how to harness the power of readline..

I'm set for emacs mode, and still ^U only kills from cursor to line-begin.

Any other useful information on my settings I should contribute?

Thanks again to all who helped so far!

-Y1
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash shell script read file line by line. Darren[UoW] Programming 57 04-17-2016 07:07 PM
BASH: Read entire file line in for loop clinton Programming 16 04-18-2013 01:06 PM
BASH: read every line in the files and use the line as parameters as another program tam3c36 Programming 10 12-07-2010 02:42 PM
Handling filename beginning with '--' in bash vjimin Linux - Newbie 2 02-07-2006 05:18 AM
deleting characters at the beginning of a line poobeany Programming 6 09-23-2003 06:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration