Snipository is a Go-based project that provides a way to manage your bash snippets without leaving your terminal.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. you can also install snipository as a ZSH plugin.
- Go
- ZSH Shell
To build a local version of the project, run the following command:
make build-localThis will create a binary named snipository in your current directory.
To install snipository as a ZSH plugin, first run the following script from zsh:
ZSH_CUSTOM=$ZSH_CUSTOM ./install_as_plugin.sh
the ZSH_CUSTOM variable is the path to your custom plugins directory, it should be set if you are using oh-my-zsh.
it is required here like this because the script runs on a different shell session, and thus, does not have access to the originalZSH_CUSTOM variable.
this will:
- create a directory named
snipositoryin your custom plugins directory. - copy the
snipository.plugin.zshfile to the newly created directory. - copy the
snipositorybinary to the newly created directory. - adding
snipositorycompletion command to your .zshrc - adding
export HISTFILE=$HISTFILEto your .zshrc (this is required for thesnipositorycompletion command to work properly the HISTFILE is the path for the file that contains the history of your commands, and required as env var that the snipository binary can access)
next, you need to add snipository to your plugins list in your .zshrc file:
plugins=(... snipository)
in order to make auto-completion work, you need to add the following line to your .zshrc file:
source <(snipository completion zsh)
Then, restart your ZSH shell to use snipository.
before first run, you might want to add the local data file:
mkdir -p ~/.config/snipository && touch ~/.config/snipository/snipository_data.json
snipository --help
snipository push-latest <COMMAND NAME>
this will add the latest command from history to the snipository.
snipository get-snip <COMMAND NAME>
this will copy the command to your clipboard.
notice, that the completion in this app works for all the data, so you can use the TAB key to complete the command name,
or switch between the commands using the TAB key.