ASIC/FPGA Design and Verification Out Source Services
Some tips to handle history in bash shell.
This page is for sharing a perl script for line length control.
-
This pages describes the way I use history in bash. History can save a lot of key typing.
-
To start some useful aliases are needed:
#under bash
alias h=history
function hg () { history | grep $1; }
#under csh
alias hg 'h | grep \!:1'
The first one is trivial. The second, the hg alias passes a parameter, to display the history commands filtered by grep .
-
To farther display history command fetch features, lets do some commands first:
mkdir kuku
cd !$
date > a.txt
cp a.txt{,.bak}
vi a.txt
gvimdiff a.txt{.bak,}
ls a.txt{,.bak}
a.txt a.txt.bak
!cp:p
Puts the last command from history, which started with cp, as first in history. You can now use up arrow to refer to this command.
^R (control R) (reverse-i-search)`':da
and bash will complete with the last command, from history, starting with da
-
Recently I work on a TCSH, which does not have control R option. The closest I
could do, is to use the upper arrows in a similar way to ESP P.
So regular arrow
just goes forward or backward in history as usual. But If I put prefix, say
vi AA
then use the arrow it'll bring commands from history, which start with this
pattern: vi AA
bindkey -k down history-search-forward
bindkey -k up history-search-backward
bindkey "^R" i-search-back
|