codetainer
Version:
A clean and simple CLI to manage and store code snippets with ease.
178 lines (108 loc) β’ 2.81 kB
Markdown
# π Codetainer Usage Guide
Welcome to the **Codetainer** full documentation. This guide covers everything from installation to advanced usage. Codetainer is your terminal-based code snippet managerβblazing fast, powerful, and developer-friendly.
## π Installation
Install globally with your preferred package manager:
```bash
npm install -g codetainer
```
or
```bash
yarn global add codetainer
```
## βοΈ Getting Started
After installation, initialize your snippet storage:
```bash
ctn init
```
This sets up your local vault at `~/.codetainer/snippets.json`.
## βοΈ Add a Snippet
```bash
ctn add
```
- You'll be prompted to:
- Select a language
- Add optional tags
- Enter your code in a code editor window
## π Search Snippets
```bash
ctn search <query>
```
- Searches **title**, **content**, **tags**, and **language**
- Use filters:
- `--tag` to filter by tag
- `--lang` to filter by language
## π List Snippets
```bash
ctn list
```
- Lists all saved snippets with metadata (name, language, tags).
## π Get Snippet Content
```bash
ctn get <name>
```
- Prints the code of the specified snippet directly to the terminal.
## π Copy Snippet to Clipboard
```bash
ctn copy <name>
```
- Instantly copies the snippet code to your clipboard.
## βοΈ Edit Snippet
```bash
ctn edit <name> "new content"
```
- Updates the snippet content inline.
**OR** open in your default editor for richer editing:
```bash
ctn watch <name>
```
- Supports syntax highlighting, linting, and formatting.
- Recognizes snippet language.
Use `--r` to edit or watch a **remote** snippet.
## π₯ Import Snippets
```bash
ctn import ./my-snippet.py
```
- Imports a file from your local directory.
Optional:
```bash
ctn import ./my-snippet.py -a mySnippet
```
- Assigns a custom name to the imported snippet.
## π€ Export Snippets
### Export one:
```bash
ctn export <name>
```
- Saves the snippet in the current directory with proper file extension.
### Export all:
```bash
ctn export-all
```
- Saves **all** snippets to the current directory.
- Files are named and typed correctly.
## β Delete a Snippet
```bash
ctn delete "my snippet title"
```
- Permanently removes the snippet from storage.
## π§ Pro Tips
- Use tags to organize snippets into themes or frameworks
- Use `ctn list` regularly to maintain your vault
- Export before reformatting or migrating machines
## π€ Contributions
We welcome improvements! See `CONTRIBUTING.md` for how to help.
Happy hacking with Codetainer π§ββοΈ