A command-line application for 30 seconds of code snippets

Usage no npm install needed!

<script type="module">
  import min from 'https://cdn.skypack.dev/1min';


30s 命令应用

A command-line application for 30 seconds of code snippets(一个基于 30 seconds of code 的命令应用).

NPM build status coveralls dependabot status semantic-release license



  • Written in JavaScript (ES6)(使用 ES6 编写)
  • View, view by tag and search snippets(查看,按标签查看并搜索代码片段)
  • Show what you find necessary by picking a layout(通过选择布局显示您认为必要的内容)
  • Colorful output or JSON(高亮色彩输出或者输出 JSON 格式)
  • Copy all code to clipboard(拷贝所有的代码到剪切板)
  • Automatically updates with new snippet changes(自动更新新的代码片段)
  • Works on Linux, Mac and Windows(适用于 Linux,Mac 和 Window 系统)


Pick one of the following options to install the command-line application:(选择以下选项中的一种来安装命令行应用)

Option 1: NPM / Yarn(选项 1:NPM / Yarn)

npm install -g 30s
yarn add -g 30s

Option 2: Source(选项 2:源码)

$ git clone https://github.com/effiyichengliang/30s-command-line.git
$ cd 30s-command-line/
$ npm install
$ node lib/index.js <command> <query>



Short version Long version Description(描述)
r random View random snippet(随机产看代码片段)
s search Fuzzy search (RegExp) snippets by id(通过 ID 来模糊搜索(正则表达式)代码片段)
t tag View snippets by tag(通过标签来查看代码片段)
v view View snippet with id(查看带有 ID 的代码片段)


Short version Long version Description(描述)
-c --cp Copy snippet code to clipboard(拷贝代码片段到剪切板)
-j --json Print output in JSON format(以 JSON 格式打印输出)
-l --layout Print output with specified layout (default: "itced")
-h --help Output usage information
Layout key Description
i Output snippet id
t Output snippet tags
c Output snippet code
e Output snippet examples
d Output snippet description


Example Description
30s v head View snippet with id head
30s view head View snippet with id head
30s r View random snippet
30s random View random snippet
30s t array View snippets by tag array
30s tag array View snippets by tag array
30s s all Find all snippets with an id that contains all
30s search all Find all snippets with an id that contains all
30s view merge --cp View snippet with id merge and copy its code
30s view merge --json View snippet with id merge and output as JSON
30s search all --layout ce Find all snippets with an id that contains all and output code and example


Bug reports & feature requests(Bug 报告 & 功能需求)

Please use the issue tracker to report bugs or file feature requests(请使用issue tracker来报告 Bug 和提交功能需求).


Pull requests are more than welcome. Do the following to start helping out(请使用拉请求的方式,并遵循以下规则来提供您的帮助):

  1. Fork this repository to your own GitHub account and then clone it to your local device(Fork 这个项目到你自己的 GitHub 账号,然后 clone 它到你的本地机器上).
  2. Run npm install in the created directory to install all necessary dependencies(在 clone 下来的项目目录下运行 npm install 来安装必须的依赖包).

Optional steps (可选步骤):

  1. Uninstall 30s if it's already installed(如果你已经装过 30,请先卸载): npm uninstall -g 30s
  2. Link it to the global module directory: npm link(将本项目软链接到你的全局模块目录)

Style guide & conventions(风格指南 & 协议约定)

Try to follow functional programming best practices. Use pure functions and Ramda when possible(尽量遵循函数式编程来练习。尽可能的使用纯函数和 Ramda 表达式).

Write commits following(遵循日志提交书写格式): Angular Commit Message Conventions. This enables us to automatically release new versions together with(保证我们的自动版本更新遵循) semantic-release on fix and feat commit types.

prettier and eslint-config-sqve (a config based on standardjs) enforces our styling and formatting. It runs automatically on pre-commit and is also checked for issues on Travis CI(强制使用 standardjs) 配置 prettiereslint-config-sqve)来保持我们的风格和格式化。我们将在你日志提交时运行自动化检测.


See the development board for a detailed development roadmap. Below are a short outline of important improvements:

  • Autocomplete with omelette
  • Replace commander with basic yargs and own logic


A big thank you to the core team and all the contributers at 30-seconds-of-code for creating an awesome curated collection of snippets.


Creative Commons License
CC0 1.0 Universal