Simply add the file into ~/.local/bin and you will be able to use it wherever by typing 'search' within your terminal.
Example:
$ history | search pacman DOS do-re-mi
Matched pattern -> pacman
202- 231 vim src/main.c
203: 232 sudo pacman -S distrobox
204: 233 sudo pacman -S podman
205- 234 distrobox create --name vi-ew-dev --image archlinux
Unused pattern(s) -> DOS do-re-mi