Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maaslalani/nap
Code snippets in your terminal
https://github.com/maaslalani/nap
Last synced: 6 days ago
JSON representation
Code snippets in your terminal
- Host: GitHub
- URL: https://github.com/maaslalani/nap
- Owner: maaslalani
- Created: 2022-11-12T03:55:57.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-18T15:20:50.000Z (7 months ago)
- Last Synced: 2024-11-29T11:09:25.680Z (13 days ago)
- Language: Go
- Homepage:
- Size: 182 KB
- Stars: 1,902
- Watchers: 6
- Forks: 50
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
- awesome-tuis - nap
- awesome-helix - Code snippets in your terminal
- jimsghstars - maaslalani/nap - Code snippets in your terminal (Go)
README
# Nap
zzz
Nap is a code snippet manager for your terminal. Create and access new snippets
quickly with the command-line interface or browse, manage, and organize them with the
text-user interface. Keep your code snippets safe, sound, and well-rested in your terminal.
## Text-based User Interface
Launch the interactive interface:
```bash
nap
```Key Bindings
| Action | Key |
| :--- | :--- |
| Create a new snippet | n |
| Edit selected snippet (in `$EDITOR`) | e |
| Copy selected snippet to clipboard | c |
| Paste clipboard to selected snippet | p |
| Delete selected snippet | x |
| Rename selected snippet | r |
| Set folder of selected snippet | f |
| Set language of selected snippet | L |
| Move to next pane | tab |
| Move to previous pane | shift+tab |
| Search for snippets | / |
| Toggle help | ? |
| Quit application | q ctrl+c |## Command Line Interface
Create new snippets:
```bash
# Quick save an untitled snippet.
nap < main.go# From a file, specify Notes/ folder and Go language.
nap Notes/FizzBuzz.go < main.go# Save some code from the internet for later.
curl https://example.com/main.go | nap Notes/FizzBuzz.go# Works great with GitHub gists
gh gist view 4ff8a6472247e6dd2315fd4038926522 | nap
```Output saved snippets:
```bash
# Fuzzy find snippet.
nap fuzzy# Write snippet to a file.
nap go/boilerplate > main.go# Copy snippet to clipboard.
nap foobar | pbcopy
nap foobar | xclip
```List snippets:
```bash
nap list
```Fuzzy find a snippet (with [Gum](https://github.com/charmbracelet/gum)).
```bash
nap $(nap list | gum filter)
```## Installation
Install with Go:
```sh
go install github.com/maaslalani/nap@main
```Or download a binary from the [releases](https://github.com/maaslalani/nap/releases).
## Customization
Nap is customized through a configuration file located at `NAP_CONFIG` (`$XDG_CONFIG_HOME/nap/config.yaml`).
```yaml
# Configuration
home: ~/.nap
default_language: go
theme: nord# Colors
background: "0"
foreground: "7"
primary_color: "#AFBEE1"
primary_color_subdued: "#64708D"
green: "#527251"
bright_green: "#BCE1AF"
bright_red: "#E49393"
red: "#A46060"
black: "#373B41"
gray: "240"
white: "#FFFFFF"
```The configuration file can be overridden through environment variables:
```bash
# Configuration
export NAP_CONFIG="~/.nap/config.yaml"
export NAP_HOME="~/.nap"
export NAP_DEFAULT_LANGUAGE="go"
export NAP_THEME="nord"# Colors
export NAP_PRIMARY_COLOR="#AFBEE1"
export NAP_RED="#A46060"
export NAP_GREEN="#527251"
export NAP_FOREGROUND="7"
export NAP_BACKGROUND="0"
export NAP_BLACK="#373B41"
export NAP_GRAY="240"
export NAP_WHITE="#FFFFFF"
```
## License
[MIT](https://github.com/maaslalani/nap/blob/master/LICENSE)
## Feedback
I'd love to hear your feedback on improving `nap`.
Feel free to reach out via:
* [Email](mailto:[email protected])
* [Twitter](https://twitter.com/maaslalani)
* [GitHub issues](https://github.com/maaslalani/nap/issues/new)---
zzz