Key accelerators
Combination | Does |
---|
Ctrl-A | Jump to beginning of the line (beware screen stealing Ctrl-A) |
class="table-even">Ctrl-E | Jump to the end of the line |
Alt-F | Jump forward one word |
Alt-B | Jump back one word |
Ctrl-U | Delete all characters before cursor |
Ctrl-K | Delete all characters from cursor to end of line |
Ctrl-R | Enter history search mode Type Ctrl-R, then command fragment; Ctrl-R then scrolls through matching entries |
Alt-U | Make the word (or fragment of word) after the cursor uppercase |
Alt-L | Make the word (or fragment of word) after the cursor lowercase |
Alt-C | Capitalize 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:
"\M-[A":history-search-backward
"\M-[B":history-search-forward
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:
https://www.redhat.com/archives/shrike-list/2004-March/msg00187.html)
(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.