Re: inputrc update

Stef Bon <[email protected]>
Newsgroups gmane.linux.lfs.general
Message-ID <[email protected]>
On 08/25/2011 10:02 PM, Steve Jones wrote:
> Since I finally got a "round tuit", I've been studying readline.  The
> inputrc file in the current book has gotten a bit long in the tooth.
> Some of the settings are now the default and readline uses better
> defaults and also uses termcap to map certain keys in different
> terminals.  Here is the current LFS inputrc file with my comments.
>
>> # Begin /etc/inputrc
>> # Modified by Chris Lynn<[email protected]>
>>
>> # Allow the command prompt to wrap to the next line
>> set horizontal-scroll-mode Off
> This is now the default setting.  It is redundant.
>
>> # Enable 8bit input
>> set meta-flag On
>> set input-meta On
> These are the same thing, setting one sets both.
>
>> # Turns off 8th bit stripping
>> set convert-meta Off
>>
>> # Keep the 8th bit for display
>> set output-meta On
> Nothing wrong here.
>
>> # none, visible or audible
>> set bell-style none
> Since this one is a personal preference how about leaving it in but
> commented out.
>
>> # All of the following map the escape sequence of the
>> # value contained inside the 1st argument to the
>> # readline specific functions
>>
>> "\eOd": backward-word
>> "\eOc": forward-word
> These are by default mapped to backward-char and forward-char.  What are
> these keys?  The only clue is a comment in the code about common arrow
> keys.  Does anybody really want some special keyboard to use the arrow
> keys differently.  Meta-b and Meta-f already do these.
>
>> # for linux console
>> "\e[1~": beginning-of-line
> Default one linux terminal.
>
>> "\e[4~": end-of-line
> Default one linux terminal.
>
>> "\e[5~": beginning-of-history
>> "\e[6~": end-of-history
> These two are needed.
>
>> "\e[3~": delete-char
> Default one linux terminal.
>
>> "\e[2~": quoted-insert
> Use the INSERT key for quoted-insert.  I think overwrite-mode is a
> better default.  quoted-insert already has 2 default key sequences.
>
>> # for xterm
>> "\eOH": beginning-of-line
>> "\eOF": end-of-line
> Readline already does the right thing here in xterm.
>
>> # for Konsole
>> "\e[H": beginning-of-line
>> "\e[F": end-of-line
> I don't use Konsole but the readline does these also.
>
>> # End /etc/inputrc
> Here is my new inputrc file.  I've gone to a lot of effort to find out
> exactly what readline really does in the default case without any inputrc
> file.  Since LFS doesn't use emacs and I don't either, this is set up
> for vi mode, but includes commands to switch back and forth.  All the
> info on the web about readline and the inputrc file is old and does not
> really explain what readline is really doing with these commands.
>
> NOTE:  There are some bash specific bindable functions that are bound by
> default in emacs mode but are not bound at all in vi mode while others
> are bound.
>
>> # Begin ~/.inputrc
>> # By Steve Jones<[email protected]>
>>
>> # Set these for modern 8bit terminals.
>> set input-meta On
>> set convert-meta Off
>> set output-meta On
>>
>> # none, visible or audible
>> set bell-style audible
>>
>> # Don't match hidden files on tab complete.
>> set match-hidden-files Off
>>
>> # Set emacs mode, even though it is the default before setting the keymap.
>> set editing-mode emacs
>> 	# Although emacs mode has 3 different keymaps, they are all
>> 	# concatenated together, so we only need to set stuff in one keymap.
>> 	set keymap emacs
>> 		# Use this to see the editing mode and keymap.
>> 		"\e\C-v": dump-variables
>> 		# Change to vi mode.
>> 		"\e\C-j": vi-editing-mode
>> 		# Change to overwrite.  Changes back to insert after new line.
>> 		"\e[2~": overwrite-mode # INSERT
>> 		# Use Page-Up/Down to help navigate history.
>> 		"\e[5~": beginning-of-history # PAGE-UP
>> 		"\e[6~": end-of-history # PAGE-DOWN
>> 		# Set forward-search-history to M-C-s since \C-s is
>> 		# caught by the kernel to stop the terminal.
>> 		"\e\C-s": forward-search-history
>> 		$if term=linux
>> 			# These do not work in {E,x}term, Caught by e16.
>> 			"\e\C-f": dump-functions # Ctr-Alt-f
>> 			"\e\C-m": dump-macros
>> 			"\e\C-r": re-read-init-file
>> 		$endif
>> 		$if bash
>> 			# F1: Get the man 1 page for the command on the line.
>> 			# Remove any options that may still be there.
>> 			# NOTE: This does not work correctly on commands that
>> 			# contain dashes (-) or other word brake characters in
>> 			# their name.
>> 			"\e[[A": "\C-aman 1 \ef\C-k\C-m"
>> 		$endif
>>
>> # Set vi editing mode and leave it as the mode to use.
>> set editing-mode vi
>> 	# Since the vi keymaps are different, we need different mappings for
>> 	# each.
>> 	set keymap vi-insert
>> 		"\C-l": clear-screen # CTRL-L
>> 		"\e\C-v": dump-variables
>> 		# Change to emacs mode.
>> 		"\e\C-j": emacs-editing-mode
>> 		# Overstrike in vi-insert.
>> 		"\e[2~": vi-replace # Insert
>> 		"\e[3~": vi-delete # Delete
>> 		# Use Page-Up/Down to help navigate history.
>> 		"\e[5~": beginning-of-history # PAGE-UP
>> 		"\e[6~": end-of-history # PAGE-DOWN
>> 		# Set forward-search-history to M-C-s since \C-s is
>> 		# caught by the kernel to stop the terminal.
>> 		"\e\C-s": forward-search-history
>> 		$if term=linux
>> 			# These do not work in {E,x}term, Caught by e16.
>> 			"\e\C-f": dump-functions # Ctr-Alt-f
>> 			"\e\C-m": dump-macros
>> 			"\e\C-r": re-read-init-file
>> 		$endif
>> 		$if bash
>> 			# F1: Get the man 1 page for the command on the line.
>> 			# Remove any options that may still be there.
>> 			# NOTE: If there is no trailing space on a command with
>> 			# no options, the `a' command complains with a bell.
>> 			"\e[[A": "\e0iman 1 \eEa \ed$\C-m"
>> 		$endif
>>
>> 	set keymap vi-command
>> 		"\e\C-v": dump-variables
>> 		"\e\C-j": emacs-editing-mode
>> 		# Change to vi-insert mode.
>> 		"\e[2~": vi-editing-mode # Insert
>> 		# Use Page-Up/Down to help navigate history.
>> 		"\e[5~": beginning-of-history # PAGE-UP
>> 		"\e[6~": end-of-history # PAGE-DOWN
>> 		# Set forward-search-history to M-C-s since \C-s is
>> 		# caught by the kernel to stop the terminal.
>> 		"\e\C-s": forward-search-history
>> 		$if term=linux
>> 			# These do not work in {E,x}term, Caught by e16.
>> 			"\e\C-f": dump-functions # Ctr-Alt-f
>> 			"\e\C-m": dump-macros
>> 			"\e\C-r": re-read-init-file
>> 		$endif
>> 		$if bash
>> 			# F1: Get the man 1 page for the command on the line.
>> 			# Remove any options that may still be there.
>> 			# NOTE: If there is no trailing space on a command with
>> 			# no options, the `a' command complains with a bell.
>> 			"\e[[A": "0iman 1 \eEa \ed$\C-m"
>> 		$endif
>>
>> # End ~/.inputrc
> I also have built an authoritative inputrc file, one with all the variables
> and bindable functions for readline with the bash add ons.  Also all the
> default keymaps are included.  Not all the functions or variables are
> documented, What I could find and so far figure out from reading the
> code is included.  If anyone is interested I can post it later (2233
> lines long).
>
Looks good to me! And I'm interested in good documentation about these 
things. The existing inputrc is indeed very basic, and knowing what is 
possible is always a plus!

Stef
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-chat
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.