InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

Menu
  • Home
  • Sitemap

Python Programming Language Best Tutorials and Code Examples

Learn Python Right Now!
Home
Bash
Adjusting readline Behavior Using .inputrc in bash
Bash

Adjusting readline Behavior Using .inputrc in bash

InfinityCoder April 5, 2017

You’d like to adjust the way bash handles input, especially command completion. For example, you’d like it to be case-insensitive.

Edit or create a ~/.inputrc or /etc/inputrc file as appropriate. There are many parameters you can adjust to your liking.

To have readline use your file when it initializes, set $INPUTRC; for example, set INPUTRC=’~/.inputrc’.

To re-read the file and apply or test after making changes, use bind -f filename.

We recommend you explore the bind command and the readline documentation, especially bind -v, bind -l, bind -s, and bind -p, though the last one is rather long and cryptic.
Some useful settings for users from other environments, notably Windows, are (see the section “Readline Init File Syntax” in Appendix A):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# settings/inputrc: # readline settings
# To re-read (and implement changes to this file) use:
# bind -f $SETTINGS/inputrc
 
# First, include any systemwide bindings and variable
# assignments from /etc/inputrc
# (fails silently if file doesn't exist)
$include /etc/inputrc
 
$if Bash
# Ignore case when doing completion
  set completion-ignore-case on
# Completed dir names have a slash appended
  set mark-directories on
# Completed names which are symlinks to dirs have a slash appended
  set mark-symlinked-directories on
# List ls -F for completion
  set visible-stats on
# Cycle through ambiguous completions instead of list
  "\C-i": menu-complete
# Set bell to audible
  set bell-style audible
# List possible completions instead of ringing bell
  set show-all-if-ambiguous on
 
# From the readline documentation at
# http://tiswww.tis.case.edu/php/chet/readline/readline.html#SEC12
# Macros that are convenient for shell interaction
# edit the path
  "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
# prepare to type a quoted word -- insert open and close double quotes
# and move to just after the open quote
  "\C-x\"": "\"\"\C-b"
# insert a backslash (testing backslash escapes in sequences and macros)
  "\C-x\\": "\\"
# Quote the current or previous word
  "\C-xq": "\eb\"\ef\""
# Add a binding to refresh the line, which is unbound
  "\C-xr": redraw-current-line
# Edit variable on current line.
  #"\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
  "\C-xe": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
$endif

You will want to experiment with these and other settings. Also note the $include to use thesystem settings, but make sure you can change them if you like.
Many people are not aware of how customizable, not to mention powerful and flexible, the GNU Readline library is.

Having said that, there is no “one size fits all” approach. You should work out a configuration that suits your needs and habits.
Note the first time readline is called it performs its normal startup file processing, including looking at $INPUTRC, or defaulting to ~/.inputrc if that’s not set.

Share
Tweet
Email
Prev Article
Next Article

Related Articles

Finding and Running Commands in bash
You need to find and run a particular command under …

Finding and Running Commands in bash

Getting Information About Files in PHP
You need more information about a file, such as what …

Getting Information About Files in PHP

About The Author

InfinityCoder
InfinityCoder

Leave a Reply

Cancel reply

Recent Tutorials InfinityQuest

  • Adding New Features to bash Using Loadable Built-ins in bash
    Adding New Features to bash Using Loadable …
    June 27, 2017 0
  • Getting to the Bottom of Things in bash
    Getting to the Bottom of Things in …
    June 27, 2017 0

Recent Comments

  • fer on Turning a Dictionary into XML in Python
  • mahesh on Turning a Dictionary into XML in Python

Categories

  • Bash
  • PHP
  • Python
  • Uncategorized

InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

About Us

Start learning your desired programming language with InfinityQuest.com.

On our website you can access any tutorial that you want with video and code examples.

We are very happy and honored that InfinityQuest.com has been listed as a recommended learning website for students.

Popular Tags

binary data python CIDR convert string into datetime python create xml from dict python dictionary into xml python how to create xml with dict in Python how to write binary data in Python IP Address read binary data python tutorial string as date object python string to datetime python

Archives

  • June 2017
  • April 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
Copyright © 2021 InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more
Programming Tutorials | Sitemap