-
-
Save qinshulei/c786c766cd14cbdaab1b to your computer and use it in GitHub Desktop.
improve history command with grep and percol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
function show_usage { | |
cat <<- _EOF_ | |
Search Bash History using Grep and Percol | |
Examples: | |
$ h ssh | |
$ h 'ssh user@' | |
_EOF_ | |
exit 1 | |
} | |
#Sanity check - Need one argument | |
if [ $# -ne 1 ]; then | |
show_usage | |
fi | |
#If bash_history doesn't exist | |
if [ -f ~/.zsh_history ]; then | |
cat ~/.zsh_history | grep $1 | percol | |
elif [ -f ~/.bash_history ]; then | |
cat ~/.zsh_history | grep $1 | percol | |
else | |
show_usage | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment