This script finds commands in bash history by a regular expression.
$ lasth.sh "^ssh "
Welcome to lasth. Checking for history entries that match "^ssh "
[001] ssh root@localhost -i test.key
[002] ssh [email protected]
[003] ssh [email protected]
[004] ssh [email protected] -L 8080:localhost:8080
[005] ssh [email protected] -p 2180
[006] ssh -i /cygdrive/d/private/uberspace_blechert [email protected]
[007] ssh [email protected]
Please choose [1-7]: 7
Run `ssh [email protected]`...
Verification code:
Password:
mkdir -p ~/bin/
cd ~/bin/
wget "https://raw.githubusercontent.com/perryflynn/lasth/master/lasth.sh" -O "lasth.sh"
chmod a+x "lasth.sh"
In your ~/.bashrc
:
export PATH="$PATH:~/bin/"
In your ~/.bashrc
:
alias lastssh='lasth.sh "^ssh "'
alias lastcurl='lasth.sh "^curl "'
alias lastgit='lasth.sh "^git "'
Result:
$ lastssh
Welcome to lasth. Checking for history entries that match "^ssh "
[...]