Softpanorama
May the source be with you, but remember the KISS principle ;-)

Contents Bulletin Scripting in shell and Perl Network troubleshooting History Humor

Readline and inputrc

News Recommended Links .profile Controlling the Prompt in bash Unix shells history Examples of .bashrc files
Command history reuse Bash and ksh93 Shell Prompts Customarization AIX dotfiles Sysadmin Horror Stories

Humor

Etc

The /etc/inputrc file deals with mapping the keyboard for specific situations. This file is the start-up file used by Readline, the input-related library used by Bash, perl and most other open source programs.

For more information, see the bash info page, section Readline Init File. The readline info page is also a good source of information.

Global values are set in /etc/inputrc. Personal user values are set in ~/.inputrc. The ~/.inputrc file will override the global settings file. A later page sets up Bash to use /etc/inputrc if there is no .inputrc for a user when /etc/profile is read (usually at login). To make the system use both, or to negate global keyboard handling, it is a good idea to place a default .inputrc into the /etc/skel directory for use with new users.

Below is a base /etc/inputrc, along with comments to explain what the various options do. Note that comments cannot be on the same line as commands.

To create the .inputrc in /etc/skel using the command below, change the command's output to /etc/skel/.inputrc and be sure to check/set permissions afterward. Copy that file to /etc/inputrc and the home directory of any user already existing on the system, including root, that needs a private version of the file. Be certain to use the -p  parameter of cp to maintain permissions and be sure to change owner and group appropriately.

One interesting possibility provided by readline is to map commands to function keys. Here is how to map ll command to F3 (bash support of remapping is buggy and you need first map F1 to non-existent character 201 and then 201 to ll. See asigning a certain command to a certain keyboard key - comp.unix.shell Google Groups):

bind '"\e[13~":'$'"\201"'; bind -x $'"\201":ll'

Here is the relevant fragment of manual that describes bind:

Bash Reference Manual - Bash Builtins This section describes builtin commands which are unique to or have been extended in Bash.
bind
bind [-m keymap] [-lpsvPSV]
bind [-m keymap] [-q function] [-u function] [-r keyseq]
bind [-m keymap] -f filename
bind [-m keymap] keyseq:function-name
Display current Readline (see section Command Line Editing) key and function bindings, or bind a key sequence to a Readline function or macro. The binding syntax accepted is identical to that of `.inputrc' (see section Readline Init File), but each binding must be passed as a separate argument: e.g., `"\C-x\C-r":re-read-init-file'. Options, if supplied, have the following meanings:
-m keymap
Use keymap as the keymap to be affected by the subsequent bindings. Acceptable keymap names are emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-command, and vi-insert. vi is equivalent to vi-command; emacs is equivalent to emacs-standard.
-l
List the names of all Readline functions.
-p
Display Readline function names and bindings in such a way that they can be re-read.
-P
List current Readline function names and bindings.
-v
Display Readline variable names and values in such a way that they can be re-read.
-V
List current Readline variable names and values.
-s
Display Readline key sequences bound to macros and the strings they output in such a way that they can be re-read.
-S
Display Readline key sequences bound to macros and the strings they output.
-f filename
Read key bindings from filename.
-q function
Query about which keys invoke the named function.
-u function
Unbind all keys bound to the named function.
-r keyseq
Remove any current binding for keyseq.
 

Bash-2.04 introduced option -x for bind to bind key sequences to shell commands

Examples:

bind -P a list of keys and their bindings

bind -l will give you a list of readline functions.
bind -p will give you a list in the format for .inputrc so you can do:-
bind -p > .inputrc


Top updates

Bulletin Latest Past week Past month
Google Search


NEWS CONTENTS

Old News ;-)

Tip inputrc settings

Hello

put the following either in ~/.inputrc or /etc/inputrc if you find yourself
using cli from time to time and want to make it a bit easier:

<------------------------------------------------------------
# do not casesensitive completion
set completion-ignore-case on

# if there are more than 150 possible completions for a word, ask the
# user if he wants to see all of them
set completion-query-items 150

# Adding this to your /etc/inputrc or ~/.inputrc will result in a character
# being appended to any file-names returned by completion, in much the same
# way as ls -F works.
set visible-stats on

# If you have this in your /etc/inputrc or ~/.inputrc, you will no longer
# have to hit the <Tab> key twice to produce a list of all possible
# completions.
# A single <Tab>  will suffice.
set show-all-if-ambiguous on

# Completed names which are symbolic links to
# directories have a slash appended.
set mark-symlinked-directories on



This one is allready in /etc/inputrc and only needs to be "uncommented":

# alternate mappings for "page up" and "page down" to search the history
"\e[5~": history-search-backward
"\e[6~": history-search-forward

------------------------------------------------------------>

Have fun

bye Thilo
--
i am on Ubuntu 2.6 KDE
- some friend of mine

gpg key: 0x4A411E09
 

Inputrc for bash history completion using up/down arrows

The bashrc file stores key mappings. Use your own bashrc by putting export INPUTRC=~/.inputrc in your .bash_profile or .bashrc

This page, Creating the /etc/inputrc File and this page, Super-useful inputrc give some useful advice about things you can put in those files.

One of things I most often find myself doing is searching my command line history. I frequently use the cursor up and down to scroll through my most recent commands. Often, I want to re-use a particular grep or find that I used recently, but I don't remember the specifics of it. With the text below in your .inputrc, you can type in the first few letters, say gr or f and press the cursor keys and it will scroll through your command history, showing the commands that began with those characters. Nice. :)

  1. # By default up/down are bound to previous-history  
  2. # and next-history respectively. The following does the  
  3. # same but gives the extra functionality where if you  
  4. # type any text (or more accurately, if there is any text  
  5. # between the start of the line and the cursor),  
  6. # the subset of the history starting with that text  
  7. # is searched (like 4dos for e.g.).  
  8. # Note to get rid of a line just Ctrl-C  
  9. "\e[B": history-search-forward  
  10. "\e[A": history-search-backward  
  11.  
  12. $if Bash  
  13.   # F10 toggles mc on and off  
  14.   # Note Ctrl-o toggles panes on and off in mc  
  15.   "\e[21~": "mc\C-M" 
  16.  
  17.   #do history expansion when space entered  
  18.   Space: magic-space  
  19. $endif 
  20.  
  21. # Include system wide settings which are ignored  
  22. # by default if one has their own .inputrc  
  23. $include /etc/inputrc 

Super-useful inputrc

Linuxart

You either want to place the following in ~/.inputrc or /etc/inputrc Ive found that while ~/.inputrc works sometimes, it doesnt on all systems.


"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
set completion-ignore-case On
 

All lines except the last enable nice readline & bash cursor movement (control + arrow keys and what not) while the last line turns on case insensitivity for tab-completion, enabling you to have folders and files of mixed case characters while not having to type the capital letters. (You can have a directory called Documents and tab-complete by tying doc<tab>

Ive been enjoying the above for a while now, and I think it really should be the default settings for distributions.

Note: This works for Linux, Mac OS X, and *BSD. It might work for people using Bash on Windows, but youre on your own there. (:

No TweetBacks yet. (Be the first to Tweet this post)

This entry was posted on Thursday, October 13th, 2005 at 1:23 pm and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

  1. With one change thats a very nice default configuration.

    "\e[5~": history-search-backward
    "\e[6~": history-search-forward

    This maps Page Up / Page Down to the IMO very useful history search function. Configured like that by default in paldo.

     
  2. If  ~/.inputrc doesnt work, then you need to add

    export INPUTRC=~/.inputrc

    to your .bashrc/.bash_profile/wherever.

     
  3. These should all be quote-backslash-e, right? The backslash is missing for me.

    I have a few more variables set:

    set bell-style visible
    set expand-tilde on
    set convert-meta off
    set input-meta on
    set output-meta on
    set show-all-if-ambiguous on
    set visible-stats on

     
  4. I acutally go the whole hog and do like 4dos used to.
    I.E. have the up/down arrows do the search.
    Note if you dont type anything the up/down arrow behave as before.
    http://www.pixelbeat.org/settings/.inputrc

     
  5. Yes you need to escape with a \\ before the first e. Doesnt seem to work in my xterm (debian) though.. :(

     
  6.  
  7. Works great in gnome-terminal; thanks!

    I also tried to get Control-Backspace to do unix-filename-rubout, but unfortunately it seems that Control-Backspace doesnt look any differently from Backspace.

     
  8.  
  9. for those who like the WinNT/XP way TAB works in MSDOS prompts (i.e. instead of showing a list of possible completions like bash does on default, TAB cycles through possible completions), just add this to .inputrc:

    \t: menu-complete

    it saves me a lot of typing !!

     
  10. Anybody know how to make a shortcut so that way when i press ctrl+a or whatever letter, i can set it to do an actioni was told it was with the /etc/inputrc file, but i cant figure it out.

     
  11. how to make readline auto compleate search the words to be compleated from the file.

     
  12. I had to add:
    \e[1;5C: forward-word
    \e[1;5D: backward-word
    on my (gentoo linux) system for word search to work. A similar translation should apply nicely to the others.

     
  13. I noticed what appears to be a bug in readline. Im using Terminal.app on tiger with bash, and doing set completion-ignore-case On causes completion to break with directories that have spaces in the name. For example:

    /home/micha/Documents/My Stuff/myfile.pdf

    If, from /home/micha I do

    ls documents/my\ [TAB]

    it completes correctly to produce Documents/My\ Stuff/ but if I press tab again at that point it produces this:

    ls Documents/My\\\ Stuff

    which is wrong.

     
  14. One simple question:

    How does the keyseq get generated? Are they predefined values? Do they relate to the ansi key set?

    IE: \e[3~: delete-char
    How does the value: \e[3~: relate to the delete key?

     
  15. Q: How does the value: \e[3~: relate to the delete key?

    A: \e[3~ is the sequence of bytes that your terminal sends when the delete key is pressed. And when I say terminal, I mean either a real serial terminal, or an xterm-like thing, or the Linux console driver.

     
  16. Does this work with iterm in os x? I copied and pasted

    \e[1~: beginning-of-line
    \e[4~: end-of-line
    \e[5~: beginning-of-history
    \e[6~: end-of-history
    \e[3~: delete-char
    \e[2~: quoted-insert
    \e[5C: forward-word
    \e[5D: backward-word
    \e\e[C: forward-word
    \e\e[D: backward-word

    into my ~/.inputrc and tried doing export INPUTRC=~/.inputrc but forward and backword word do not work for me. Anyone got any suggestions?

     
  17. kortina: if you typed export INPUTRC=~/.inputrc into your terminal that just sets the variable, doesnt actually read the file. you either have to type it in your ~/.bash_profile or just put those settings in /etc/inputrc instead of locally.

    oh, im not sure about if it works with iterm, i just use the Terminal in leopard (works just fine for me, ive yet to find something that iterm does and Terminal doesnt - besides fullscreening which i dont like anyway)

    but yes, it does work with mac os x :)

     
  18. Whoops. Looks like somebodys blog is converting double quote characters into posh quotes. Notice how theres a difference between these quotes and "these"

     
  19. Thank you blog author and Marius Gedminas!
    After much fruitless searching, I have finally gotten the console to use a visible bell instead of beeping loudly.

    I added line
    set bell-style visible
    to ~/.inputrc
    and added line
    export INPUTRC=~/.inputrc
    to ~/.bashrc

     
  20. Thanks for this post. If possible, can you and some comments to show which keys you are using? I know [5~, [6~ is Page up/Page down - but the rest have me a bit confused.

     
  21. Debian has a file explaining this:

    /usr/share/doc/bash/inputrc.arrows:
    # This file controls the behaviour of line input editing for
    # programs that use the Gnu Readline library.
    #
    # Arrow keys in keypad mode
    #
    \C-[OD backward-char
    \C-[OC forward-char
    \C-[OA previous-history
    \C-[OB next-history
    #
    # Arrow keys in ANSI mode
    #
    \C-[[D backward-char
    \C-[[C forward-char
    \C-[[A previous-history
    \C-[[B next-history
    #
    # Arrow keys in 8 bit keypad mode
    #
    \C-M-OD backward-char
    \C-M-OC forward-char
    \C-M-OA previous-history
    \C-M-OB next-history
    #
    # Arrow keys in 8 bit ANSI mode
    #
    \C-M-[D backward-char
    \C-M-[C forward-char
    \C-M-[A previous-history
    \C-M-[B next-history

[Mar 10, 2008] Problem with "bind -x"

This is an undocumented bug in bash that exists for the last five years or more. See above for the tick to bypass it

I'm having trouble with the bind builtin. I'm working on a trivial example
to bind a shell command to a key sequence. If I type

        bind -x '"abc":/bin/echo def'

I would expect the screen to display "def", but instead I get this error:

        bash2: bash_execute_unix_command: cannot find keymap for command

Granted that this is a trivial example, what am I doing wrong, and how can
I make it work? The eventual goal is to use bind to map function keys to
aliases.

--
"The only thing that helps me maintain my slender grip on reality is the
friendship I share with my collection of singing potatoes."

                        - Holly, JMC Vessel *Red Dwarf*

[Mar 10, 2008 GeSHi - Generic Syntax Highlighter Home

Can be used for shell scripts and bash initrc

[Mar 10, 2008 Bash Config Files

How Bash executes startup files.

For Login shells (subject to the -noprofile option):

On logging in:
If `/etc/profile' exists, then source it.

If `~/.bash_profile' exists, then source it,
else if `~/.bash_login' exists, then source it,
else if `~/.profile' exists, then source it.

On logging out:
If `~/.bash_logout' exists, source it.

For non-login interactive shells (subject to the -norc and -rcfile options):
On starting up:
If `~/.bashrc' exists, then source it.

For non-interactive shells:
On starting up:
If the environment variable `ENV' is non-null, expand the variable and source the file named by the value.
If Bash is not started in Posix mode, it looks for `BASH_ENV' before `ENV'.

So, typically, your `~/.bash_profile' contains the line
`if [ -f `~/.bashrc' ]; then source `~/.bashrc'; fi' after (or before) any login specific initializations.

If Bash is invoked as `sh', it tries to mimic the behavior of `sh' as closely as possible. For a login shell, it attempts to source only `/etc/profile' and `~/.profile', in that order. The `-noprofile' option may still be used to disable this behavior. A shell invoked as `sh' does not attempt to source any other startup files.

When Bash is started in POSIX mode, as with the `-posix' command line option, it follows the Posix 1003.2 standard for startup files. In this mode, the `ENV' variable is expanded and that file sourced; no other startup files are read.

My .bashrc can be found here.

My .bash_profile can be found here.

.inputrc (readline)-- Although the Readline library comes with a set of Emacs-like key bindings installed by default, it is possible that you would like to use a different set of keybindings. You can customize programs that use Readline by putting commands in an "init" file in your home directory. The name of this file is taken from the value of the shell variable `INPUTRC'. If that variable is unset, the default is `~/.inputrc'.

When a program which uses the Readline library starts up, the init file is read, and the key bindings are set.

In addition, the `C-x C-r' command re-reads this init file, thus incorporating any changes that you might have made to it.

Conditional Init Constructs within readline

Readline implements a facility similar in spirit to the conditional compilation features of the C preprocessor which allows key bindings and variable settings to be performed as the result of tests. There are three parser directives used.

`$if' The `$if' construct allows bindings to be made based on the editing mode, the terminal being used, or the application using Readline. The text of the test extends to the end of the line; no characters are required to isolate it.
`mode' The `mode=' form of the `$if' directive is used to test whether Readline is in `emacs' or `vi' mode. This may be used in conjunction with the `set keymap' command, for instance, to set bindings in the `emacs-standard' and `emacs-ctlx' keymaps only if Readline is starting out in `emacs' mode.
`term' The `term=' form may be used to include terminal-specific key bindings, perhaps to bind the key sequences output by the terminal's function keys. The word on the right side of the `=' is tested against the full name of the terminal and the portion of the terminal name before the first `-'. This allows SUN to match both SUN and SUN-CMD, for instance.
`application' The APPLICATION construct is used to include application-specific settings. Each program using the Readline library sets the APPLICATION NAME, and you can test for it. This could be used to bind key sequences to
functions useful for a specific program.
`$endif' This command terminates an `$if' command.
`$else' Commands in this branch of the `$if' directive are executed if the test fails.

The following command adds a key sequence that quotes the current or previous word in Bash:
$if bash
# Quote the current or previous word
"\C-xq": "\eb\"\ef\""
$endif
 

My .inputrc file is here

Last update by Hermann Heimhardt on October 7, 2001

[Feb 26, 2008] 7.8. Creating the -etc-inputrc File

The inputrc file handles keyboard mapping for specific situations. This file is the startup file used by Readline the input-related library used by Bash and most other shells.

Most people do not need user-specific keyboard mappings so the command below creates a global /etc/inputrc used by everyone who logs in. If you later decide you need to override the defaults on a per-user basis, you can create a .inputrc file in the user's home directory with the modified mappings.

For more information on how to edit the inputrc file, see info bash under the Readline Init File section. info readline is also a good source of information.

Below is a generic global inputrc along with comments to explain what the various options do. Note that comments cannot be on the same line as commands. Create the file using the following command:

cat > /etc/inputrc << "EOF"
# Begin /etc/inputrc
# Modified by Chris Lynn <roryo@roryo.dynup.net>

# Allow the command prompt to wrap to the next line
set horizontal-scroll-mode Off

# Enable 8bit input
set meta-flag On
set input-meta On

# Turns off 8th bit stripping
set convert-meta Off

# Keep the 8th bit for display
set output-meta On

# none, visible or audible
set bell-style none

# 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

# for linux console
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert

# for xterm
"\eOH": beginning-of-line
"\eOF": end-of-line

# for Konsole
"\e[H": beginning-of-line
"\e[F": end-of-line

# End /etc/inputrc
EOF

System Administration Toolkit Get the most out of bash

Command-line editing and key bindings

The main command prompt within bash provides both the ability to edit the command line and a history function, remembering individual command lines so that you can execute them again.

The editing functionality means that you can go forward and backward through the command line currently displayed to make changes and correct typos. In bash's standard form, you can use the cursor keys for basic movement. More extensive commands, such as going backward and forward by words, are controlled by the Readline library that supports both vi and emacs bindings by default. To set the editing mode, specify your preferred mode either on the command line or in a bootstrap file: $ set editing-mode emacs.

For example, using the emacs editing mode, the following key bindings are in effect:

You can in fact bind any key or combination you like to a particular operation using the internal bind bash command. To start, you can get a list of the available commands by using the -P option (see Listing 1).


Listing 1. Using the -P option to get a list of available commands
$ bind -P 

abort can be found on "\C-g", "\C-x\C-g", "\M-\C-g".
accept-line can be found on "\C-j", "\C-m".
alias-expand-line is not bound to any keys
arrow-key-prefix is not bound to any keys
backward-byte is not bound to any keys
...
yank can be found on "\C-y".
yank-last-arg can be found on "\M-.", "\M-_".
yank-nth-arg can be found on "\M-\C-y".
yank-pop can be found on "\M-y".

The \C refers to the control key. The \M sequence refers to the 'meta' key (special on some keyboards, or usually the Alt key or the Escape key).

To set a binding, you must specify the key sequence and the command to be executed, separated by a colon, with the key sequence escaped by a double quote (in extreme circumstances, you might need to escape this again with a single quote). For example, to change Control-B to go backwards word by word, use $ bind "\C-b":backward-word.

You can even use the binding to execute a shell command (for example, to run an application). To do this, you must add the -x option, and this is an example of where the escaping of both is required. For example, to set Control-E to run emacs, you would use the following: $ bind -x '"\C-e"':emacs.

To have key bindings in bash enabled every time, you can either set the information in the .inputrc file (which then affects all Readline-enable d applications), or you can place specific bash bindings in your startup scripts, which will be covered later in this article.

inputrc

# this eliminates the need for hitting tab twice to show choices whenever there are multiple completion matches set show-all-if-ambiguous on
-etc-inputrc [Homepage von Robert Kehl]
# /etc/inputrc - global inputrc for libreadline
# See readline(3readline) and `info rluserman' for more information.

# Be 8 bit clean.
set input-meta on
set output-meta on

# To allow the use of 8bit-characters like the german umlauts, comment out
# the line below. However this makes the meta key not work as a meta key,
# which is annoying to those which don't need to type in 8-bit characters.

# set convert-meta off

# try to enable the application keypad when it is called.  Some systems
# need this to enable the arrow keys.
#set enable-keypad on

# see /usr/share/doc/bash/inputrc.arrows for other codes of arrow keys

# do not bell on tab-completion 
# set bell-style none 

# Show all if ambigious.
set show-all-if-ambiguous on
# bash completions does not use more
set page-completions off

# some defaults / modifications for the emacs mode
$if mode=emacs

# allow the use of the Home/End keys
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# those two are for rxvt
#"\e[7~":beginning-of-line
#"\e[8~":end-of-line
# on some xterm
#"\e[H": beginning-of-line
#"\e[F": end-of-line
# on nxterms
#"\e[\C-@": beginning-of-line
#"\e[e": end-of-line

# allow the use of the Delete/Insert keys
# "\e[2~": quoted-insert
"\e[2~": yank                   # Insert
# "\e[3~": delete-char
"\e[3~":delete-char             # Suppr

# mappings for "page up" and "page down" to step to the beginning/end 
# of the history
# "\e[5~": beginning-of-history
# "\e[6~": end-of-history
# alternate mappings for "page up" and "page down" to search the history
"\e[5~": history-search-backward
"\e[6~": history-search-forward

# # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
#"\e[5C": forward-word
#"\e[5D": backward-word
#"\e\e[C": forward-word
#"\e\e[D": backward-word

# $if term=rxvt
# "\e[8~": end-of-line
# $endif

# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
# "\eOH": beginning-of-line
# "\eOF": end-of-line

# for freebsd console
# "\e[H": beginning-of-line
# "\e[F": end-of-line

$if term=xterm

# xterm with NumLock ON
# Operators
#"\eOo":         "/"
#"\eOj":         "*"
#"\eOm":         "-"
#"\eOk":         "+"
#"\eOl":         "+"
#"\eOM":         accept-line

# Colon and dot
#"\eOl":       ","
"\eOn":         "."

# Numbers
"\eOp":         "0"
"\eOq":         "1"
"\eOr":         "2"
"\eOs":         "3"
"\eOt":         "4"
"\eOu":         "5"
"\eOv":         "6"
"\eOw":         "7"
"\eOx":         "8"
"\eOy":         "9"

# Application keypad and cursor of xterm
"\eOD":         backward-char
"\eOC":         forward-char
"\eOA":         previous-history
"\eOB":         next-history
"\eOE":         re-read-init-file

$endif

$endif 

cat > /etc/inputrc << "EOF"

# Begin /etc/inputrc
# Modified by Chris Lynn <roryo@roryo.dynup.net>

# Make sure we don't output everything on the 1 line
set horizontal-scroll-mode Off

# Enable 8bit input
set meta-flag On 
set input-meta On

# Turns off 8th bit stripping
set convert-meta Off

# Keep the 8th bit for display
set output-meta On

# none, visible or audible
set bell-style none

# 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

# for linux console
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert

# for xterm
"\eOH": beginning-of-line
"\eOF": end-of-line

# for Konsole
"\e[H": beginning-of-line
"\e[F": end-of-line

# End /etc/inputrc
EOF
 

.inputrc and command line edit mode function key remapping


Think of this as a brief FUQ (a veritable 'Quickie', as
it were) -- Frequently Unanswered Questions

Disclaimer/Alibi
----------------
These are really questions for the 'bash' group, except
that they specifically deal with the PC and its
keyboard (*and* I'm using 'bash' on Cygwin).

I've searched for answers throughout the Cygwin,
'emacs' and 'bash' documentation, and the Web and even
bought the book, /Learning the bash shell/. Alas, no
FUQing help! ;-)

I plan to document this in some copylefted docs, so you
should be able to leverage the time of your answers.

Q1 -- When you remap a 'bash' Edit Mode function in
.inputrc, it looks like this:

"\e[3~":      delete-char # DEL key

The entity in double quotes ("\e[3~"), I'm calling the
"key ID (KID)". In the above '.inputrc' declaration,
the function 'delete-char' being remapped from its
default key assignment to the KID -- "\e[3~" -- the
<DEL> key.

What are the KIDs of the following IBM PC keys
(specified below with facsimiles of the key caps
contained in angle brackets -- '<...>')?

Cursor control key pad
----------------------
<HOME>
<END>
<left-arrow>
<right-arrow>
<PAGE_UP>
<PAGE_DOWN>
<INSERT>

Numeric pad
-----------
<->
<+>
<ENTER>
</>

In general, I'd like a table that maps the KIDs for all
104 keys on the keyboard I use. Or, better still, is
there a way to use scan codes?

(Incidentally, what makes finding a table of these
KIDs so difficult is the failure of the documentation
to assign this concept a unique, or even a consistent
word.)

Q2
--

Is there a way to make the <INSERT> key a toggle
between the insert and overwrite modes of 'bash'
edit mode?

I used to have these figured out for 'Microemacs', but
that was half a lifetime ago, for me, and Microemacs
supported scan codes, if I remember correctly.

The discerning reader will have surmised both from
these questions and my earlier query 'on the humble
<DEL> key', that I am trying to make a PC, under the
estimable Cygwin, exploit those few niceties of the PC
(keyboard).

Thanks

Lee

P.S. In anticipation of the "righteous" among you being
     offended by the term 'FUQ', I shared your
     indignation; it occurred shortly after buying the
     ill-fated -- and referenced -- 'bash' book. (Yes,
     it's true; I'm bashing the 'bash' book.)

     And, please, whatever you do, don't kid a KIDer. ;-)


Lee D. Rothstein -- lee@veritech.com
VeriTech -- 603-424-2900
7 Merry Meeting Drive
Merrimack, NH 03054-2934

----------

problems with certain entries in .inputrc


I'm using Cygwin 1.1.7 for Win95x:

BUG: If I include the following line in my .inputrc file, then no bindings
get loaded when the shell starts:

"": self-insert

(the above is ascii value 219)

what is wierd is that all other binding directives work fine.

This is the contents of my .inputrc file.  You'll notice that I commented
out the trouble line - when I do this, all bindings work fine.  However, if
I uncomment this line, then none of my bindings work:

"\C-g": abort
"\C-x\C-g": abort
"\e\C-g": abort
"\C-j": accept-line
"\C-m": accept-line
# alias-expand-line (not bound)
# arrow-key-prefix (not bound)
"\C-b": backward-char
"\eOD": backward-char
"\e[D": backward-char
"\C-h": backward-delete-char
"\C-?": backward-delete-char
"\C-x\C-?": backward-kill-line
"\e\C-h": backward-kill-word
"\e\C-?": backward-kill-word
"\eb": backward-word
"\e<": beginning-of-history
"\C-a": beginning-of-line
"\e[1~": beginning-of-line
"\C-xe": call-last-kbd-macro
"\ec": capitalize-word
"\C-]": character-search
"\e\C-]": character-search-backward
"\C-l": clear-screen
"\C-i": complete
"\e\C-[": complete
"\e!": complete-command
"\e/": complete-filename
"\e@": complete-hostname
"\e{": complete-into-braces
"\e~": complete-username
"\e$": complete-variable
# copy-backward-word (not bound)
# copy-forward-word (not bound)
# copy-region-as-kill (not bound)
"\C-d": delete-char
# delete-char-or-list (not bound)
"\e\\": delete-horizontal-space
"\e-": digit-argument
"\e0": digit-argument
"\e1": digit-argument
"\e2": digit-argument
"\e3": digit-argument
"\e4": digit-argument
"\e5": digit-argument
"\e6": digit-argument
"\e7": digit-argument
"\e8": digit-argument
"\e9": digit-argument
"\C-x\C-v": display-shell-version
"\C-xA": do-lowercase-version
"\C-xB": do-lowercase-version
"\C-xC": do-lowercase-version
"\C-xD": do-lowercase-version
"\C-xE": do-lowercase-version
"\C-xF": do-lowercase-version
"\C-xG": do-lowercase-version
"\C-xH": do-lowercase-version
"\C-xI": do-lowercase-version
"\C-xJ": do-lowercase-version
"\C-xK": do-lowercase-version
"\C-xL": do-lowercase-version
"\C-xM": do-lowercase-version
"\C-xN": do-lowercase-version
"\C-xO": do-lowercase-version
"\C-xP": do-lowercase-version
"\C-xQ": do-lowercase-version
"\C-xR": do-lowercase-version
"\C-xS": do-lowercase-version
"\C-xT": do-lowercase-version
"\C-xU": do-lowercase-version
"\C-xV": do-lowercase-version
"\C-xW": do-lowercase-version
"\C-xX": do-lowercase-version
"\C-xY": do-lowercase-version
"\C-xZ": do-lowercase-version
"\eA": do-lowercase-version
"\eB": do-lowercase-version
"\eC": do-lowercase-version
"\eD": do-lowercase-version
"\eE": do-lowercase-version
"\eF": do-lowercase-version
"\eG": do-lowercase-version
"\eH": do-lowercase-version
"\eI": do-lowercase-version
"\eJ": do-lowercase-version
"\eK": do-lowercase-version
"\eL": do-lowercase-version
"\eM": do-lowercase-version
"\eN": do-lowercase-version
"\eOE": do-lowercase-version
"\eOF": do-lowercase-version
"\eOG": do-lowercase-version
"\eOH": do-lowercase-version
"\eOI": do-lowercase-version
"\eOJ": do-lowercase-version
"\eOK": do-lowercase-version
"\eOL": do-lowercase-version
"\eOM": do-lowercase-version
"\eON": do-lowercase-version
"\eOO": do-lowercase-version
"\eOP": do-lowercase-version
"\eOQ": do-lowercase-version
"\eOR": do-lowercase-version
"\eOS": do-lowercase-version
"\eOT": do-lowercase-version
"\eOU": do-lowercase-version
"\eOV": do-lowercase-version
"\eOW": do-lowercase-version
"\eOX": do-lowercase-version
"\eOY": do-lowercase-version
"\eOZ": do-lowercase-version
"\eP": do-lowercase-version
"\eQ": do-lowercase-version
"\eR": do-lowercase-version
"\eS": do-lowercase-version
"\eT": do-lowercase-version
"\eU": do-lowercase-version
"\eV": do-lowercase-version
"\eW": do-lowercase-version
"\eX": do-lowercase-version
"\eY": do-lowercase-version
"\eZ": do-lowercase-version
"\e[1A": do-lowercase-version
"\e[1B": do-lowercase-version
"\e[1C": do-lowercase-version
"\e[1D": do-lowercase-version
"\e[1E": do-lowercase-version
"\e[1F": do-lowercase-version
"\e[1G": do-lowercase-version
"\e[1H": do-lowercase-version
"\e[1I": do-lowercase-version
"\e[1J": do-lowercase-version
"\e[1K": do-lowercase-version
"\e[1L": do-lowercase-version
"\e[1M": do-lowercase-version
"\e[1N": do-lowercase-version
"\e[1O": do-lowercase-version
"\e[1P": do-lowercase-version
"\e[1Q": do-lowercase-version
"\e[1R": do-lowercase-version
"\e[1S": do-lowercase-version
"\e[1T": do-lowercase-version
"\e[1U": do-lowercase-version
"\e[1V": do-lowercase-version
"\e[1W": do-lowercase-version
"\e[1X": do-lowercase-version
"\e[1Y": do-lowercase-version
"\e[1Z": do-lowercase-version
"\e[4A": do-lowercase-version
"\e[4B": do-lowercase-version
"\e[4C": do-lowercase-version
"\e[4D": do-lowercase-version
"\e[4E": do-lowercase-version
"\e[4F": do-lowercase-version
"\e[4G": do-lowercase-version
"\e[4H": do-lowercase-version
"\e[4I": do-lowercase-version
"\e[4J": do-lowercase-version
"\e[4K": do-lowercase-version
"\e[4L": do-lowercase-version
"\e[4M": do-lowercase-version
"\e[4N": do-lowercase-version
"\e[4O": do-lowercase-version
"\e[4P": do-lowercase-version
"\e[4Q": do-lowercase-version
"\e[4R": do-lowercase-version
"\e[4S": do-lowercase-version
"\e[4T": do-lowercase-version
"\e[4U": do-lowercase-version
"\e[4V": do-lowercase-version
"\e[4W": do-lowercase-version
"\e[4X": do-lowercase-version
"\e[4Y": do-lowercase-version
"\e[4Z": do-lowercase-version
"\e[E": do-lowercase-version
"\e[F": do-lowercase-version
"\e[G": do-lowercase-version
"\e[H": do-lowercase-version
"\e[I": do-lowercase-version
"\e[J": do-lowercase-version
"\e[K": do-lowercase-version
"\e[L": do-lowercase-version
"\e[M": do-lowercase-version
"\e[N": do-lowercase-version
"\e[O": do-lowercase-version
"\e[P": do-lowercase-version
"\e[Q": do-lowercase-version
"\e[R": do-lowercase-version
"\e[S": do-lowercase-version
"\e[T": do-lowercase-version
"\e[U": do-lowercase-version
"\e[V": do-lowercase-version
"\e[W": do-lowercase-version
"\e[X": do-lowercase-version
"\e[Y": do-lowercase-version
"\e[Z": do-lowercase-version
"\el": downcase-word
# dump-functions (not bound)
# dump-macros (not bound)
# dump-variables (not bound)
"\e\C-i": dynamic-complete-history
# emacs-editing-mode (not bound)
"\C-x)": end-kbd-macro
"\e>": end-of-history
"\C-e": end-of-line
"\e[4~": end-of-line
"\C-x\C-x": exchange-point-and-mark
# forward-backward-delete-char (not bound)
"\C-f": forward-char
"\eOC": forward-char
"\e[C": forward-char
"\C-s": forward-search-history
"\ef": forward-word
"\C-x*": glob-expand-word
"\C-xg": glob-list-expansions
# history-and-alias-expand-line (not bound)
"\e^": history-expand-line
# history-search-backward (not bound)
# history-search-forward (not bound)
"\e#": insert-comment
"\e*": insert-completions
"\e.": insert-last-argument
"\e_": insert-last-argument
"\C-k": kill-line
# kill-region (not bound)
# kill-whole-line (not bound)
"\ed": kill-word
# magic-space (not bound)
# menu-complete (not bound)
"\C-n": next-history
"\eOB": next-history
"\e[B": next-history
"\en": non-incremental-forward-search-history
# non-incremental-forward-search-history-again (not bound)
"\ep": non-incremental-reverse-search-history
# non-incremental-reverse-search-history-again (not bound)
"\C-o": operate-and-get-next
# paste-from-clipboard (not bound)
"\C-x!": possible-command-completions
"\e=": possible-completions
"\e?": possible-completions
"\C-x/": possible-filename-completions
"\C-x@": possible-hostname-completions
"\C-x~": possible-username-completions
"\C-x$": possible-variable-completions
"\C-p": previous-history
"\eOA": previous-history
"\e[A": previous-history
"\C-q": quoted-insert
"\C-v": quoted-insert
"\C-x\C-r": re-read-init-file
# redraw-current-line (not bound)
"\C-r": reverse-search-history
"\e\C-r": revert-line
"\er": revert-line
" ": self-insert
"!": self-insert
"\"": self-insert
"#": self-insert
"$": self-insert
"%": self-insert
"&": self-insert
"'": self-insert
"(": self-insert
")": self-insert
"*": self-insert
"+": self-insert
",": self-insert
"-": self-insert
".": self-insert
"/": self-insert
"0": self-insert
"1": self-insert
"2": self-insert
"3": self-insert
"4": self-insert
"5": self-insert
"6": self-insert
"7": self-insert
"8": self-insert
"9": self-insert
":": self-insert
";": self-insert
"<": self-insert
"=": self-insert
">": self-insert
"?": self-insert
"@": self-insert
"A": self-insert
"B": self-insert
"C": self-insert
"D": self-insert
"E": self-insert
"F": self-insert
"G": self-insert
"H": self-insert
"I": self-insert
"J": self-insert
"K": self-insert
"L": self-insert
"M": self-insert
"N": self-insert
"O": self-insert
"P": self-insert
"Q": self-insert
"R": self-insert
"S": self-insert
"T": self-insert
"U": self-insert
"V": self-insert
"W": self-insert
"X": self-insert
"Y": self-insert
"Z": self-insert
"[": self-insert
"\\": self-insert
"]": self-insert
"^": self-insert
"_": self-insert
"`": self-insert
"a": self-insert
"b": self-insert
"c": self-insert
"d": self-insert
"e": self-insert
"f": self-insert
"g": self-insert
"h": self-insert
"i": self-insert
"j": self-insert
"k": self-insert
"l": self-insert
"m": self-insert
"n": self-insert
"o": self-insert
"p": self-insert
"q": self-insert
"r": self-insert
"s": self-insert
"t": self-insert
"u": self-insert
"v": self-insert
"w": self-insert
"x": self-insert
"y": self-insert
"z": self-insert
"{": self-insert
"|": self-insert
"}": self-insert
"~": self-insert
"\200": self-insert
"\201": self-insert
"\202": self-insert
"\203": self-insert
"\204": self-insert
"\205": self-insert
"\206": self-insert
"\207": self-insert
"\210": self-insert
"\211": self-insert
"\212": self-insert
"\213": self-insert
"\214": self-insert
"\215": self-insert
"\216": self-insert
"\217": self-insert
"\220": self-insert
"\221": self-insert
"\222": self-insert
"\223": self-insert
"\224": self-insert
"\225": self-insert
"\226": self-insert
"\227": self-insert
"\230": self-insert
"\231": self-insert
"\232": self-insert
"\233": self-insert
"\234": self-insert
"\235": self-insert
"\236": self-insert
"\237": self-insert
" ": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
#"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"": self-insert
"\C-@": set-mark
"\e ": set-mark
"\e\C-e": shell-expand-line
"\C-x(": start-kbd-macro
# tab-insert (not bound)
"\e&": tilde-expand
"\C-t": transpose-chars
"\et": transpose-words
# tty-status (not bound)
"\C-x\C-u": undo
"\C-_": undo
# universal-argument (not bound)
"\C-u": unix-line-discard
"\C-w": unix-word-rubout
"\eu": upcase-word
# vi-append-eol (not bound)
# vi-append-mode (not bound)
# vi-arg-digit (not bound)
# vi-bWord (not bound)
# vi-back-to-indent (not bound)
# vi-bracktype (not bound)
# vi-bword (not bound)
# vi-change-case (not bound)
# vi-change-char (not bound)
# vi-change-to (not bound)
# vi-char-search (not bound)
# vi-column (not bound)
# vi-complete (not bound)
# vi-delete (not bound)
# vi-delete-to (not bound)
# vi-eWord (not bound)
# vi-editing-mode (not bound)
# vi-end-word (not bound)
# vi-eof-maybe (not bound)
# vi-eword (not bound)
# vi-fWord (not bound)
# vi-fetch-history (not bound)
# vi-first-print (not bound)
# vi-fword (not bound)
# vi-goto-mark (not bound)
# vi-insert-beg (not bound)
# vi-insertion-mode (not bound)
# vi-match (not bound)
# vi-movement-mode (not bound)
# vi-next-word (not bound)
# vi-overstrike (not bound)
# vi-overstrike-delete (not bound)
# vi-prev-word (not bound)
# vi-put (not bound)
# vi-redo (not bound)
# vi-replace (not bound)
# vi-search (not bound)
# vi-search-again (not bound)
# vi-set-mark (not bound)
# vi-subst (not bound)
# vi-tilde-expand (not bound)
# vi-yank-arg (not bound)
# vi-yank-to (not bound)
"\C-y": yank
"\e.": yank-last-arg
"\e_": yank-last-arg
"\e\C-y": yank-nth-arg
"\ey": yank-pop

Readline

Bash Reference Manual Readline Init File

Although the Readline library comes with a set of Emacs-like keybindings installed by default, it is possible to use a different set of keybindings. Any user can customize programs that use Readline by putting commands in an inputrc file, conventionally in his home directory. The name of this file is taken from the value of the shell variable INPUTRC. If that variable is unset, the default is `~/.inputrc'.

When a program which uses the Readline library starts up, the init file is read, and the key bindings are set.

In addition, the C-x C-r command re-reads this init file, thus incorporating any changes that you might have made to it.

8.3.1 Readline Init File Syntax   Syntax for the commands in the inputrc file.
8.3.2 Conditional Init Constructs   Conditional key bindings in the inputrc file.

 

8.3.3 Sample Init File   An example inputrc file.

etc/inputrc

etc/inputrc deals with the mapping of the keyboard for certain situations. This file is the start-up file used by readline - the input related library used by Bash and most other shells.

For more information see info bash -- Node: Readline Init file as well as info readline. There is a lot that can be done with this one rc file.

The following is a base /etc/inputrc along with comments to explain what the various options do.

Please note that comments can not be on the same line as commands in inputrc.

# Begin /etc/inputrc

# Make sure we don't output everything on the 1 line
set horizontal-scroll-mode Off

# Enable 8bit input
set meta-flag On 
set input-meta On

# Turns off 8th bit stripping
set convert-meta Off

# Keep the 8th bit for display
set output-meta On

# none, visible or audible
set bell-style none

# 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

# for linux console
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert

# for xterm
"\eOH": beginning-of-line
"\eOF": end-of-line

# End /etc/inputrc


Global values are set in /etc/inputrc. Personal user values as are set in ~/.inputrc. The ~/.inputrc file will override the global settings file. The previous page sets up Bash to use /etc/inputrc by default. If you want your system to use both, it might be a good idea to place a default .inputrc into the /etc/skel directory for use with new users.

The default behavior of the keyboard often leaves a lot to be desired. It is actually readline that handles this. Readline is a separate package that handles command line interfaces, providing the command history and filename completion, as well as some advanced line editing features. It is compiled into bash. By default, readline is configured using the file .inputrc in your home directory. The bash variable INPUTRC can be used to override this for bash.

Once bash has read the system-wide configuration file, it looks for your personal configuration file. It checks in your home directory for .bash_profile, .bash_login and .profile. It runs the first one of these it finds. If you want to change the way bash behaves for you, without changing the way it works for others, do it here. For example, many applications use environment variables to control how they work. I have the variable EDITOR set to vi so that I can use vi in Midnight Commander (an excellent console based file manager) instead of its editor.

Bash Config Files

How Bash executes startup files.

For Login shells (subject to the -noprofile option):

On logging in:
If `/etc/profile' exists, then source it.

If `~/.bash_profile' exists, then source it,
else if `~/.bash_login' exists, then source it,
else if `~/.profile' exists, then source it.

On logging out:
If `~/.bash_logout' exists, source it.

For non-login interactive shells (subject to the -norc and -rcfile options):
On starting up:
If `~/.bashrc' exists, then source it.

For non-interactive shells:
On starting up:
If the environment variable `ENV' is non-null, expand the variable and source the file named by the value. If Bash is not started in Posix mode, it looks for `BASH_ENV' before `ENV'.

So, typically, your `~/.bash_profile' contains the line
`if [ -f `~/.bashrc' ]; then source `~/.bashrc'; fi' after (or before) any login specific initializations.

If Bash is invoked as `sh', it tries to mimic the behavior of `sh' as closely as possible. For a login shell, it attempts to source only `/etc/profile' and `~/.profile', in that order. The `-noprofile' option may still be used to disable this behavior. A shell invoked as `sh' does not attempt to source any other startup files.

When Bash is started in POSIX mode, as with the `-posix' command line option, it follows the Posix 1003.2 standard for startup files. In this mode, the `ENV' variable is expanded and that file sourced; no other startup files are read.

My .bashrc can be found here.

My .bash_profile can be found here.

.inputrc (readline)--

Although the Readline library comes with a set of Emacs-like key bindings installed by default, it is possible that you would like to use a different set of keybindings. You can customize programs that use Readline by putting commands in an "init" file in your home directory. The name of this file is taken from the value of the shell variable `INPUTRC'. If that variable is unset, the default is `~/.inputrc'.

When a program which uses the Readline library starts up, the init file is read, and the key bindings are set.

In addition, the `C-x C-r' command re-reads this init file, thus incorporating any changes that you might have made to it.

Conditional Init Constructs within readline

Readline implements a facility similar in spirit to the conditional compilation features of the C preprocessor which allows key bindings and variable settings to be performed as the result of tests. There are three parser directives used.
 

`$if' The `$if' construct allows bindings to be made based on the editing mode, the terminal being used, or the application using Readline. The text of the test extends to the end of the line; no characters are required to isolate it.
`mode' The `mode=' form of the `$if' directive is used to test whether Readline is in `emacs' or `vi' mode. This may be used in conjunction with the `set keymap' command, for instance, to set bindings in the `emacs-standard' and `emacs-ctlx' keymaps only if Readline is starting out in `emacs' mode.
`term' The `term=' form may be used to include terminal-specific key bindings, perhaps to bind the key sequences output by the terminal's function keys. The word on the right side of the `=' is tested against the full name of the terminal and the portion of the terminal name before the first `-'. This allows SUN to match both SUN and SUN-CMD, for instance.
`application' The APPLICATION construct is used to include application-specific settings. Each program using the Readline library sets the APPLICATION NAME, and you can test for it. This could be used to bind key sequences to
functions useful for a specific program.
`$endif' This command terminates an `$if' command.
`$else' Commands in this branch of the `$if' directive are executed if the test fails.

The following command adds a key sequence that quotes the current or previous word in Bash:
$if bash
# Quote the current or previous word
"\C-xq": "\eb\"\ef\""
$endif
 

My .inputrc file is here

Last update by Hermann Heimhardt on October 7, 2001

BASH inputrc Function Binding to Key Ignored


From: William Bloom
Subject: BASH inputrc Function Binding to Key Ignored
Date: Thu, 7 Jun 2001 21:56:02 -0700 (MST)

I have built BASH 2.05.0(1)-release from source for Solaris
8 as well as FreeBSD 4.3 and have observed a difference from
BASH 2.04 in the handling of the TAB keybinding when 'vi'
editing mode is in use with a POSIX mode BASH session.
I've not seen comments about this in the archive, and the
new behavior continues even after I've applied all patches
from the BASH homepage.  I also don't see comments in the
changelog that seem relevant (perhaps I've missed it).

As an example, suppose  I have a very simple inputrc file as
follows...

        TAB: complete
        C-b: complete-into-braces

...as part of a profile that contains a 'set -o vi'.  The
login shell is /usr/local/bin/sh (a link to BASH) in order
to have a POSIX session.  The above inputrc is simply
intended to let TAB have the same completion behavior to
which some of my users are accustomed from non-POSIX BASH
use.

I find that in this case, the 'C-b' binding is honored but
the TAB binding is ignored.  -After- the session is started,
the TAB binding may be enabled using 'bind -f .inputrc', at
which time the TAB binding is not ignored.

Stranger yet, if the account is changed to use
/usr/local/bin/bash as the login shell, then the session
login now honors the TAB binding.  If the session switches
to POSIX mode (set -o posix) after login, however, then the
TAB binding automagically disappears (although the C-b binding
remains).

Is this behavior related to POSIX compliance, which (I
believe) does not call for TAB to be bound?  Are those users
who want POSIX mode and vi-style command line editing, but
yet aren't ready to give up their accustomed TAB-complete
binding, going to have to have an explicit...

        bind 'TAB: complete'

...to their login profile as of 2.0.5?


Bill

Lee D. Rothstein - Re remapping Cygwin 'bash' readline functions to PC keys

John, thanks for the <C-V> heads up! Others had
suggested, variations of 'cat < foo' and 'od -c'. (The
former I got to work, the latter remains a mystery.)
Your solution, besides being the most straight-forward,
is also a great tool to have around. Apparently, it's a
feature of Cygwin, or 'bash', since it doesn't work in
a naked 'cmd.exe' window. I'll be sure to add it to my
documentation.
 
Unfortunately the key combos I'm trying to map to
are: <^-->> and <^-<-> (control- and the right and left
arrow keys). It turns out that the character string
outputs for both the:
 
* naked key
* shift - and the naked key
* control- and the naked key


are all the same.

 

Actually, I no longer consider these to be KIDs; these
are the character string graphemic outputs of hitting
the key. I'll continue to reserve "KIDs" for when one
represents these [and the key isomorphisms]
with '/e...', 'C-...', etc. "notation".
 
Apparently (?), the only way to discriminate among these
three alternatives is with Scan Codes. Apparently, all
the -x-ish stuff I've used (Microemacs, Thompson shell
command line editing) that can discriminate among the
three alternatives all use Scan Codes (?).
 
 - Any way to map to Scan Codes to 'bash' 'readline'
   functions under Cygwin?
   + Or to key "names" like: '<CTRL-left-arrow>',
     '<CTRL-HOME>'
 - Any interest among Cygwin developers in adding
   this?
 
>At 2003-02-19 08:02 AM -0800, John Mapole wrote:
...
>You can build your own KID table. Once at the cygwin
>prompt you can type <C-V>, that's control-V, followed
>by the key.  On my machine, if I type <C-V><INSERT>, I
>see "^[[2~".  This is the same as "\e[2~".
>
>Why these mapping are like this relates to how windows
>maps them and then how cygwin maps them.  Something I
>am now very clear on.
>
>Hope this helps some.
>
>John Mapoles
>
>--- "Lee D. Rothstein" <lee at veritech dot com> wrote:
...
>> Q1 -- When you remap a 'bash' Edit Mode function in
>> .inputrc, it looks like this:
>>
>> "\e[3~":      delete-char # DEL key
>>
>> The entity in double quotes ("\e[3~"), I'm calling
>> the "key ID (KID)". In the above '.inputrc' declaration,
>> the function 'delete-char' being remapped from its
>> default key assignment to the KID -- "\e[3~" -- the
>> <DEL> key.
>>
>> What are the KIDs of the following IBM PC keys
>> (specified below with facsimiles of the key caps
>> contained in angle brackets -- '<...>')?
>>
>> Cursor control key pad
>> ----------------------
>> <HOME>
>> <END>
>> <left-arrow>
>> <right-arrow>
>> <PAGE_UP>
>> <PAGE_DOWN>
>> <INSERT>
>>
>> Numeric pad
>> -----------
>> <->
>> <+>
>> <ENTER>
>> </>


 

I should have included in the above lists, all variations
of the above with the control, alt and shift keys.


 

>> In general, I'd like a table that maps the KIDs for all
>> 104 keys on the keyboard I use. Or, better still, is
>> there a way to use scan codes?
>>
>> (Incidentally, what makes finding a table of these
>> KIDs so difficult is the failure of the documentation
>> to assign this concept a unique, or even a consistent
>> word.)
>>
>> Q2
>> --
>>
>> Is there a way to make the <INSERT> key a toggle
>> between the insert and overwrite modes of 'bash'
>> edit mode?
>>
>> I used to have these figured out for 'Microemacs',
>> but that was half a lifetime ago, for me, & Microemacs
>> supported scan codes, if I remember correctly.


--
Lee D. Rothstein -- lee at veritech dot com
VeriTech -- 603-424-2900
7 Merry Meeting Drive
Merrimack, NH 03054-2934

 

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Why can't solaris be more like linux...

Matthew Frederico pluglist@plug.org
16 May 2003 12:53:12 -0600

I agree with Nick on this one. I don't know about the inputrc stuff but
I do know that in the past, I would set my TERM to VT220 then all my
keys worked correctly.  Try:
% export TERM=VT220


On Fri, 2003-05-16 at 12:23, Nicholas Leippe wrote:
> On Friday 16 May 2003 10:14 am, you wrote:
> > I've been given access to a bunch of solaris 8 boxen here at work
> > lately, and i'm finding it difficult to move around in it because of
> > shell differences... i guess i've always taken the default setups of any
> > linux distro i've ever tried for granted.  On the solaris box, I've had
> > my shell set to BASH as that is my preference... but i still get "^?"
> > characters while trying to backspace in vi and from ftp... and i get "~"
> > when trying to "delete".  Anyone know of a quick way to get the shell
> > setup "correctly"?
> 
> Trying creating a ~/.inputrc file (see READLINE section in the bash man page).
> My global inputrc in linux (/etc/inputrc) is:
> 
> set meta-flag on
> set input-meta on
> set convert-meta off
> set output-meta on
> "\e0d": backward-word
> "\e0c": forward-word
> "\e[h": beginning-of-line
> "\e[f": end-of-line
> "\e[1~": beginning-of-line
> "\e[4~": end-of-line
> "\e[5~": beginning-of-history
> "\e[6~": end-of-history
> "\e[3~": delete-char
> "\e[2~": quoted-insert
> "\e[g": beginning-of-line
> "\e[e": beginning-of-line
> "\e[H": beginning-of-line
> "\e[F": end-of-line
> "\e[G": beginning-of-line
> "\e[E": beginning-of-line
> "\e[s": beginning-of-line
> DEL: backward-delete-char
> 
> 
> Some of that came from Redhat 6.2's /etc/inputrc.  You could also try copying 
> it from whatever distro you have installed nearby.  Also, check your TERM 
> variable.  When that's not correct, some things can get really wierd. (eg it 
> shouldn't be 'xterm' when in the console)
> 
> 
> Nick

-- 
Matthew Frederico
Unwired Networks
mfrederico@unplugthewire.com
http://www.unwirednetworks.com

Re [ale] Automating vi-style history editing in bash


On Wed, Mar 01, 2000 at 04:55:31PM -0500, David S. Jackson wrote:
> On Wed, Mar 01, 2000 at 03:09:22PM -0500 Fulton Green <me@FultonGreen.com> wrote:
> > I know how to set up bash to let me edit previous commands vi-style by typing
> > set -o vi
> > or
> > export EDITOR=vi
>
> These two things are not really the same at all. Your shell's
> editing mode (if it is bash) is set with set -o vi or set -o
> emacs. Or you can emulate yet another editor by setting the
> $readline variable in .inputrc.
>
> However, the $EDITOR variable is something else. Applications
> check if this variable exists if no editor is defined by default
> for that application. You can set emacs editing mode for the
> shell and set the $EDITOR variable to vi. No problem.
 

True for bash, and you can do this in ksh as well. However, ksh also examines
$EDITOR if the readline mode hasn't been set with 'set -o vi|emacs'. At least
this is the behavior on Solaris 2.6, whose Korn shell doesn't appear to do
the inputrc thing. My apologies for confusing Korn's behavior with bash's.
 

> > at the command line. My problem: under Red Hat 6.1, I can't seem to get
> > either of these to have an effect when I put either of them in .bash_profile
> > or .bashrc
>
> Again, the statements don't mean the same thing. But just open
> an Xterm (or whatever) and type set -o vi at the command prompt.
 

And that works for me.
 

> > In fact, doing the "set" command in .bashrc ensures that I won't
> > even be able to *manually* set the mode from the command line.
>
> This shouldn't be true. Using the set command shouldn't prohibit
> you from 'unsetting' the editing mode. I normally use emacs mode
 

It *is* true in my circumstance, but it's iff the 'set -o vi' is executed in
my .bashrc file. And at this point, I should mention that I didn't notice any
problem until I upgraded Red Hat to 6.0. I also confirmed the problem on a
fresh RH 6.1 box. I'm going to change the main runlevel in /etc/inittab from
5 to 3 (i.e., don't start out in an X server) to see if that affects anything.
 

> Are you using an .inputrc?
 

I'm not. That could very well be the problem if the global inputrc has
trash, as pointed out by earlier emails. I don't have the computer in question
in front of me at the moment, but I could almost swear that RH 6.0 or 6.1 did
away with /etc/inputrc . Or was that /etc/skel/.inputrc ?
 

Thanks for the help,

Fulton Green
http://www.FultonGreen.com/

Recommended Links

7.8. Creating the -etc-inputrc File

super-useful-inputrc




Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Haters Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least


Copyright 1996-2014 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine. This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to make a contribution, supporting hosting of this site with different providers to distribute and speed up access. Currently there are two functional mirrors: softpanorama.info (the fastest) and softpanorama.net.

Disclaimer:

The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

Last modified: February 19, 2014