For When You Can't Have The Real Thing
[ start | index | login ]
start > Linux > Bash


Created by dave. Last edited by dave, 4 years and 63 days ago. Viewed 5,343 times. #8
[diff] [history] [edit] [rdf]

Key accelerators

Ctrl-AJump to beginning of the line (beware screen stealing Ctrl-A)
Ctrl-EJump to the end of the line
Alt-FJump forward one word
Alt-BJump back one word
Ctrl-UDelete all characters before cursor
Ctrl-KDelete all characters from cursor to end of line
Ctrl-REnter history search mode
Type Ctrl-R, then command fragment; Ctrl-R then scrolls through matching entries
Alt-UMake the word (or fragment of word) after the cursor uppercase
Alt-LMake the word (or fragment of word) after the cursor lowercase
Alt-CCapitalize the word (or letter) the cursor is on

Excluding things from the history

export HISTIGNORE="&:ls:[bf]g:exit"

Additionally, if you have

export HISTCONTROL=ignoreboth
somewhere in the dotfiles, the history won't record commands that are prefixed with a space.

Making bash history completion work automatically

Here is a way to jump directly to the command in the .bash_history file. Edit your /etc/inputrc file and add the following:

Then restart bash type the first letter or 2 of a previously typed command and you will jump to that command. The more letter you type in first the more you will narrow the search to.

By typing part of a previously used command, and then pressing the up or down arrows, scrolling is limited to only those command which match the letters that have been typed.

(Source: >>

(Note that this seems to have the side-effect of breaking cursor-key left/right functionality on Suns.)

Syslogging everything done from a bash session

Add something like this to .bashrc

# export PROMPT_COMMAND='history -a >(tee -a ~/.bash_history./$$ | logger -t "bash[$$][$USER]$SSH_CONNECTION")'

Note: this isn't for security because it would be trivial to evade. The intention is to discreetly log everything that's done through bash, presumably for auditing purposes.

no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful: | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt