SnippetVault is a command-line tool written in Rust for securely and efficiently managing code snippets. It provides utilities to create, edit, list, and organize code snippets with support for fuzzy searching and markdown previewing.
- Create Snippets: Create a new snippet with language and optional tags.
- List Snippets: Fuzzy-search and preview existing snippets.
- Edit Snippets: Use a fuzzy finder to locate and edit snippets.
- Supported Languages: View all supported programming languages.
- Customization: Choose your preferred editor and directory for storing snippets.
- Integrated Tools: Utilizes tools like
fzf
andglow
for an enhanced CLI experience.
- Rust (for building the binary)
Install Rust via rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Dependencies:
fzf
: Fuzzy finderbrew install fzf
glow
: Markdown preview toolbrew install glow
- Clone the repository:
git clone https://github.com/<your-username>/SnippetVault.git cd SnippetVault
- Build the binary:
cargo build --release
- Add the binary to your PATH:
echo 'export PATH="$PATH:$(pwd)/target/release"' >> ~/.zshrc source ~/.zshrc
- Verify the installation:
snippet_vault --help
Below are the primary commands provided by SnippetVault:
Create a new snippet with a specific programming language and optional tags:
snippet_vault --create_snippet <language> [tags]
Example:
snippet_vault --create_snippet rust utility cli-tool
List and fuzzy-search through existing snippets:
snippet_vault --list_snippets
Locate a snippet using fuzzy search and open it for editing:
snippet_vault --edit_snippet
List all supported programming languages:
snippet_vault --languages
Display the current version of SnippetVault:
snippet_vault --version
By default, snippets are stored in:
$HOME/Documents/myObsidianDoc/mysnippetsCollection
To customize the directory, modify the SNIPPET_DIR
constant in the source code.
SnippetVault attempts to use nvim
as the default editor. You can configure
your preferred editor by modifying the get_default_editor
function in the
source code.
-
Create a Snippet:
snippet_vault --create_snippet python flask api
Opens the snippet in
nvim
for editing. -
List Snippets:
snippet_vault --list_snippets
Use
fzf
to locate and preview snippets. -
Edit Snippets:
snippet_vault --edit_snippet
Locate and edit a snippet directly.
-
Check Supported Languages:
snippet_vault --languages
This project is licensed under the MIT License. See the LICENSE file for details.