0.1.34 • Published 1 year ago
cnip-snippet v0.1.34
cnip - Command-line Snippet CLI Manager
cnip is a simple command-line snippet management tool.
Install
$ npm i -g cnip-snippet
Usage
USAGE:
cnip [COMMAND]
AVAILABLE COMMANDS:
list Show all snippets
add Add a new snippet
edit Edit snippet
del Delete snippet
import Import snippets
sync Sync snippets
version Print version
OPTIONS:
-c Copy selected command to clipboard
--snippet [STRING] snippet file (default is $HOME/./config/cnip/snippet.json)
--input [STRING] Reads the specified text file into the command list (e.g. $HISTFILE, etc.)
--tag [STRING] Specify the tag to be selected for initial display
--select [STRING] Display aliases and commands that match the specified text
--pet-snippet [STRING] Read Pet snippet file
-h Print Help
Features
- Add shell snippets
- Interactive fuzzy search with edit, delete and copy to clipboard functionality
- Tabbed display by tag
- Import from History, Pet snippets and Navi Cheatsheet
- Sync to gist
Shell commands
bash
function cmd-select() {
if [ "$READLINE_LINE" = "" ]; then
BUFFER=$(cnip --input $HISTFILE -s usage-count --query "$READLINE_LINE")
else
BUFFER=$(cnip --input $HISTFILE -s usage-count)
fi
READLINE_LINE="$BUFFER"
READLINE_POINT=${#BUFFER}
}
bind -x '"\C-r": cmd-select'
zsh
function cmd-select() {
if [[ "$LBUFFER" == "" ]] then
BUFFER=$(cnip --input "$HISTFILE" -s "usage-count")
else
BUFFER=$(cnip --input "$HISTFILE" -s "usage-count" --query "$LBUFFER")
fi
CURSOR=$#BUFFER
zle redisplay
}
function cmd-expand() {
if [[ "$LBUFFER" != "" ]] then
BUFFER=$(cnip --select "$LBUFFER")
fi
CURSOR=$#BUFFER
zle redisplay
}
zle -N cmd-select
zle -N cmd-expand
bindkey '^r' cmd-select
bindkey '^e' cmd-expand
Sync to Gist
You will need to obtain a Github access token. (only "gist" scope is needed)
Create an environment variable name $CNIP_GITHUB_GIST_ACCESS_TOKEN
and set the access token.
Customization
You can customize the display by setting the following environment variables.
CNIP_HIGHLIGHT_COLOR="#FFBC00"
CNIP_CURRENT_LINE_COLOR="#FFBC00"
CNIP_PROMPT_COLOR="#6E4BEC"
CNIP_TEXT_COLOR="#D4D7DC"
CNIP_SELECTED_COLOR="#008000"
CNIP_SELECTED_TAB_COLOR="#6E4BEC"
CNIP_TAB_COLOR="#A9A9A9"
CNIP_POINTER_COLOR="#6E4BEC"
CNIP_BORDER_COLOR="#ADADAD"
CNIP_DESCRIPTION_COLOR="#3BBFBF"
CNIP_CURRENT_LINE_COLOR="#6E4BEC"
CNIP_SHOW_ICONS="1"
Build
- Build:
npm run build
- Clean:
npm run clean
- Build & watch:
npm run dev
Run
node src/Index.bs.js
License
MIT
0.1.34
1 year ago
0.1.33
1 year ago
0.1.32
1 year ago
0.1.31
1 year ago
0.1.30
1 year ago
0.1.29
1 year ago
0.1.28
1 year ago
0.1.27
1 year ago
0.1.26
1 year ago
0.1.25
1 year ago
0.1.24
1 year ago
0.1.22
1 year ago
0.1.21
1 year ago
0.1.20
1 year ago
0.1.19
1 year ago
0.1.18
1 year ago
0.1.17
1 year ago
0.1.16
1 year ago
0.1.11
1 year ago
0.1.12
1 year ago
0.1.13
1 year ago
0.1.14
1 year ago
0.1.15
1 year ago
0.1.10
1 year ago
0.1.9
1 year ago
0.1.8
1 year ago
0.1.7
1 year ago
0.1.6
2 years ago
0.1.5
2 years ago
0.1.4
2 years ago
0.1.3
2 years ago
0.1.2
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago