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

Bash

Created by dave. Last edited by dave, 6 years and 78 days ago. Viewed 3,802 times. #7
[diff] [history] [edit] [rdf]
labels
attachments

Key accelerators

class="table-even">
CombinationDoes
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"

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.

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:


snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt