Simple bash script to search a text content from a reference text file.
Useful if you keep a bunch of information in a text file and want them to be easily accessible through your terminal. E.g. shell commands, useful links, commonly used node tasks.
Create an executable file:
mkdir ~/bin
vim ~/bin/ref
Paste the content from ref.sh
into the new ~/bin/ref
file
Make ~/bin/ref
executable
chmod +x ~/bin/ref
Add the following entry in your ~/.bashrc
file:
PATH="$PATH:$HOME/bin"
In a new terminal, run
ref
It will open the reference file in a text editor.
You can edit the location of the reference file by changing the REF_FILE
variable value in ~/bin/ref
.
You can add information in any format you want. The search logic will print all occurrences case-insensitive.
However if you want an optimized search result, you can format your content in the following way:
search term >> desired value
Examples:
local smtp email for dev >> docker run -p 3000:80 -p 2525:25 -d --name smtpdev rnwood/smtp4dev
eslint vscode reference >> https://github.com/microsoft/vscode-eslint/issues/733
Run ref <search term>
, e.g.
ref email
This will print:
all search results:
local smtp email for dev >> docker run -p 3000:80 -p 2525:25 -d --name smtpdev rnwood/smtp4dev
search:
local smtp email for dev
commands:
docker run -p 3000:80 -p 2525:25 -d --name smtpdev rnwood/smtp4dev