bash.jpg

Summary

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)

Rationale

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).

Scope

Any bash shell, any user with a color monitor.

Design

Big Picture

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

Implementation

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

Code

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
 
$endif

Data preservation and migration

Unresolved issues

BoF agenda and discussion

References

TODO

Comments

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


CategorySpec

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