English | 中文
A TUI tool for running multiple code snippets, in a single terminal tab.
Install SnipFly first:
brew install txperl/tap/snipfly # or go install github.com/txperl/snipfly@latestThen, create a .snipfly/ directory in your project and add a snippet:
mkdir .snipfly echo 'echo Hello from SnipFly!' > .snipfly/hello.shLet's snipfly!
snipflySnipFly will automatically detect snippets from the subfolder (.snipfly/) in the working directory.
If there's no that folder, SnipFly will look for snippets of working directory directly.
# snipfly -h Usage: snipfly [options] [directory] Options: -e, --exact use exact directory without auto-detecting ./.snipfly/ -g, --global scan global snippets directory (~) -v, --version print version information # Run snippets in the current directory snipfly snipfly . # Run snippets in a specific directory snipfly /path/to/project # Run global snippets snipfly -g| Key | Action |
|---|---|
↑ | Move up |
↓ | Move down |
Space | Run/stop snippet |
r | Restart snippet |
Tab | Switch to output panel |
q | Quit |
project/ └── .snipfly/ ├── deploy.sh # Root level (no group) ├── dev/ # Group: "dev" │ ├── server.sh │ └── watch.ts └── tools/ # Group: "tools" ├── lint.sh └── format.py Add annotations as comments at the top of your snippet files. The parser reads lines starting with # or // until the first non-comment, non-empty line.
| Annotation | Type | Default | Description |
|---|---|---|---|
@name | string | filename (no ext) | Display name in the list |
@desc | string | -- | Short description |
@type | string | oneshot | oneshot, service, or interactive |
@dir | string | snippet's directory | Working directory (~ supported) |
@env | string | -- | Environment variable KEY=VALUE (repeatable) |
@interpreter | string | auto-detect | Override interpreter command |
@pty | boolean | false | Allocate a pseudo-terminal |
Example:
# @name: Clock Server # @desc: Print current time every second # @type: service # @dir: /tmp # @env: TZ=UTC # @env: LANG=en_US.UTF-8 # @pty: true while true; do date; sleep 1; doneMinimum example:
echo "Hello from SnipFly!"git clone https://github.com/txperl/snipfly.git cd snipfly go build -o snipfly .