Add helpful bash shortcuts that will help users better utilize their system. This will allow the user to see commands they typed, and give a reasonable history setting. Currently page-up and page-down scroll through history, but they don't match partially typed commands. There are other bindings for these, but this is by far the most intuitive system I have seen. Also use some colors that are available to us (this issue is a gnome-terminal type identification issue Bug #103929)


Bash gives us features that make it very efficient, and intuitive.

Use cases

User wants to recall a command where they ssh'd into a box. User types ssh then page up to see all the different variations they have used. User then wants to find occurrence of ssh in a file. Runs grep -ni ssh * and it shows the results, with their string ssh highlighted (this is dependent on the grep change which is not a part of the main spec).


Any bash shell, any user with a color monitor.


Big Picture

This will allow shells to share history, and to search through that history with ease

  • Bind pageup to history-search-backward
    • This will allow page-up to match previously typed commands from partial input
  • Bind pagedown to history-search-forward
    • This will allow page-down to match previously typed commands from partial input
  • Add shopt -s histappend
    • This will make bash append to the history file instead of overwrite it
  • Add PROMPT_COMMAND='history -a'
    • This will append the previous command to history each time a prompt is shown


Add the specified commands to /etc/profile, /etc/inputrc, /etc/skel/.bashrc


For searching history: If you want these to be system wide, add those lines to /etc/inputrc instead.

echo "\"\e[5~\": history-search-backward" >> ~/.inputrc
echo "\"\e[6~\": history-search-forward" >> ~/.inputrc

Make sure all terminals save history

echo "shopt -s histappend" >> ~/.bashrc
echo "PROMPT_COMMAND=\"history -a; \$PROMPT_COMMAND\"" >> ~/.bashrc

More sane command matching: Put these in /etc/inputrc to be system wide.

echo "set match-hidden-files off" >> ~/.inputrc
echo "set page-completions off" >> ~/.inputrc
echo "set completion-query-items 350" >> ~/.inputrc
echo "set show-all-if-ambiguous on" >> ~/.inputrc

Increase history size: Save more commands by default

echo "export HISTSIZE=1000" >> ~/.bashrc
echo "export HISTFILESIZE=1000" >> ~/.bashrc

This is optional and not a part of the spec I am pushing for as hard

Use GREP color features by default: This will highlight the matched words / regexes

echo "export GREP_OPTIONS='--color=auto'" >> ~/.bashrc

Dash / Bash only: In input RC we need to check which shell, so our options only get used in bash or dash

$if Bash
    # Search history back and forward using page-up and page-down
    "\e[5~": history-search-backward
    "\e[6~": history-search-forward

    # Completion
    set match-hidden-files off
    set page-completions off
    set completion-query-items 350
    set show-all-if-ambiguous on

Data preservation and migration

Unresolved issues

BoF agenda and discussion



  • Create wishlist bug
  • Create patches to RPM to apply changes, post to bug


  • I propose some unintrusive but IMHO useful tweaks to the TAB autocomplete feature:

    • In /etc/bash.bashrc:
      • complete -d cd mkdir rmdir (only list directories for cd, mkdir and rmdir)

      • I think this one is already in ubuntu. -- StevenHarms (6 Apr 2007)

    • In /etc/inputrc:
      • set match-hidden-files off (do not show hidden files in the list: really useful when working in your home directory)

      • set page-completions off (removes the annoying "-- more --" prompt for long lists)

      • set completion-query-items 1000 (show the "Display all 123 possibilities? (y or n)" prompt only for really long lists)

      • set show-all-if-ambiguous on (show the list at first TAB, instead of beeping and and waiting for a second TAB to do that)

    -- RobePisc (14 Nov 2006)

  • Is there anything which can be done to reduce the amount of time spent processing /etc/bash_completions on startup?
    • This provides lots of useful completions but also takes a loooong time to process.
    -- Robert Knight (14 Nov 2006)
  • First of all I really like binding the history search keys but I would bind them to the arrow keys instead. You don't lose any functionality by doing this. Also I'd suggest to enable aliases such as ll, la etc. and color output by default
    • -- Jaap Haitsma (6 Apr 2007)
    • Since this is already the default in SuSe linux, it is already well established and well known. The page up page down keys just seem to be the most intuitive fit for this. Also, color is already on by default. -- StevenHarms (6 Apr 2007)

    • Yeah, colors are good. Ie:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

(standard colors put in .bashrc but not enabled by default). -- AzraelNightwalker

  • * It's also good to have an indication of the current command and current directory in the window title bar title, and the name of the machine if it is not a local machine. That can be done by setting the prompt: http://www.cs.pitt.edu/~philip/tech/.prompt . Most terminal emulator windows one opens are on the local machine and so the name should be omitted to save space. --Philip Ganchev (14 Aug 2007)

  • Looks to me like the issue is gnome-terminal should identify its terminal type as xterm-color and then prompt will happen. Opened bug: https://bugs.launchpad.net/ubuntu/+source/bash/+bug/103929 -- someone please confirm it - StevenHarms (6 Apr 2007)

  • You might want to add export HISTCONTROL=ignoredups to .bashrc to only save unique history entries. -- Mh21 (20 Apr 2007)

    • I believe this is already enabled by default? StevenHarms (20 Apr 2007)

  • Why not use the Friendly Interactive Shell (http://fishshell.org) instead? It has many unique features, like completion descriptions, syntax highlighting, multi-line editing, per-word history search and sensible defaults. Or use Zsh; it shows completions underneath the cursor which I think cleanly separates them from the output above; and it can iterate through possible completions, highlighting the current one and printing it at the cursor. --Philip Ganchev (14 Aug 2007)

  • You can also improve the default prompt of "less":

    export LESS="-P ?c<- .?f%f:Standard input.  ?n:?eEND:?p%pj\%.. .?c%ccol . ?mFile %i of %m  .?xNext\ %x.%t   Press h for help" 
    --Philip Ganchev (14 Aug 2007)
  • shopt -s cdspell -- minor errors in the spelling of a directory component in a cd command will be corrected

  • shopt -s lithist -- if the cmdhist option is enabled, multi-line commands are saved to the history with embedded newlines rather than using semicolon separators where possible

  • shopt -s nocaseglob -- match filenames in a case-insensitive fashion when performing pathname expansion

  • set completion-ignore-case on -- readline performs filename matching and completion in a case-insensitive fashion

  • Just want to say I've been using most of these defaults for years, which you can see in my settings files: -- Pádraig Brady (29 Aug 2007)
  • AFAIK in hardy bash completion scripts have been split to a separate package: bash-completion. -- AzraelNightwalker 2008-03-10 13:24:30


Spec/EnhancedBash (last edited 2009-08-29 19:27:36 by f005)