cod

cod is a completion daemon for bash/fish/zsh
授权协议 Apache-2.0 License
开发语言 SHELL
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 惠野
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

https://github.com/dim-an/cod/workflows/Go/badge.svg

Cod is a completion daemon for {bash,fish,zsh}.

It detects usage of --help commands parses their output and generates auto-completions for your shell.

https://asciinema.org/a/h0SrrNvZVcqoSM4DNyEUrGtQh.svg

Install

Download or build cod binary for your OS and put it into your $PATH.

Then you need to edit your init script and add few lines.

Bash

Add to ~/.bashrc

source <(cod init $$ bash)

Zsh

Add to ~/.zshrc

source <(cod init $$ zsh)

Or, use a plugin manager like zinit:

zinit wait lucid for \
  dim-an/cod

Fish

Add to ~/.config/fish/config.fish

cod init $fish_pid fish | source

Supported shells and operating systems

cod is known to work with latest version of zsh (tested: v5.5.1 and 5.7.1) on macOS and Linux.

cod also works with with latest version of bash (tested: 4.4.20 and v5.0.11) on Linux.

Note that default bash that is bundled with macOS is too old and cod doesn’t support it.

cod works with latest version of fish (tested: =v3.1.2”) on Linux (I didn’t have a chance to test it on macOS).

Build

Go v1.16 is recommended.

git clone https://github.com/dim-an/cod.git
cd cod
go build

or

go get -u github.com/dim-an/cod

Overview

Cod checks each command you run in the shell. When cod detects usage of --help flag it asks if you want it to learn this command. If you choose to allow cod to learn this command cod will run command itself parse the output and generate completions based on the --help output.

How cod detects help commands

Cod performs following checks to decide if command is help invocation:

  • checks if --help flag is used;
  • checks that command is simple i.e. doesn’t contain any pipes, file descriptor redirections, and other shell magic;
  • checks that command exit code is 0.

If cod cannot automatically detect that your command is help invocation you can use learn subcommand to learn this command anyway.

How cod runs help commands

Cod always uses absolute paths to run program. (So it finds binary in PATH or resolves relative path if required). Other arguments except binary path are left unchanged.

Current shell environment and current shell working directory will be used.

If program is successfully executed cod will store:

  • absolute path to binary;
  • used arguments;
  • working directory;
  • environment variables.

This info will be used to update command if required (check: cod help update).

How cod parses help output

cod has generic parser that works with most of help pages and recognizes flags (starting with -) but doesn’t recognize subcommands.

It also has a special parser tuned for python argparse library that recognizes flags and subcommands.

Configuration

Cod will search config in $XDG_CONFIG_HOME/cod/config.toml file (default: ~/.config/cod/config.toml).

Config file allows to specify rules to ignore executables or always trust them.

cod example-config prints example configuration to stdout. cod example-config --create writes example configuration to proper config file.

Data directories

Cod uses $XDG_DATA_HOME/cod (default: ~/.local/share/cod) to store all generated data files.

 相关资料
  • fish 是适用于 Linux、macOS 的命令行 Shell,其名字取于"the friendly interactive shell"的简称,最大特点就是方便易用、功能强大、智能并且用户友好。很多其他 Shell 需要配置才有的功能,fish 默认提供,不需要任何配置。 主要特性 自动补全 支持丰富的 VGA 颜色 开箱即用 可搜索的命令历史 基于网页的配置功能 能够提升性能的内置命令

  • Fish Redux 是一个基于 Redux 数据管理的组装式 Flutter 应用框架,它特别适用于构建中大型的复杂应用。 函数式编程 可预测的状态容器 可插拔组件化 无损性能 它的特点是配置式组装。一方面将一个大的页面,对视图和数据层拆解为互相独立的 Component|Adapter,上层负责组装,下层负责实现;另一方面将 Component|Adapter 拆分为 View、Reducer

  •   fish-ui 是基于vue2开发的一套ui组件库,其中css部分借鉴了semantic-ui的样式 demo: https://myliang.github.io/fish-ui/ github: https://github.com/myliang/fish-ui 安装 npm install less less-loader -Snpm install fish-ui -S  快速使用

  • fish-nvm NVM wrapper for fish-shell. Install Make sure you have NVM installed first. With Fisher fisher install FabioAntunes/fish-nvm edc/bass With oh-my-fish omf install https://github.com/fabioantun

  • Fish Sync 是一个文件同步工具,可在多个机器间传输多个目录。该工具不需要在每台机器上都安装,只需要发起初始同步的机器上安装即可。

  • Fish Fillets NG是一个益智游戏,目标是让两只鱼都安全通过关卡。注意:两只鱼都很容易受伤,比如一只鱼顶着一个物体而另一只鱼推此物体,将会杀死下面的哪只鱼,导致失败。 拥有78个关卡,原版Fish Fillets有70关,贡献者制作了8个新关卡和关卡编辑器。 Fish Fillets原来是ALTAR interactive.1998年发布的商业游戏,2002年放出为免费软件,2004年,

  • fish 是 OS X、Linux和家族其他成员的智能和友好的命令行shell。 它的特性有: 语法突出显示; 自动建立即时类型; 以及无需配置的标签功能。 fish 要求 C++ 11编译器,要想构建成功还需要 g++ 4.8 或更高版本,或clang 3.3或更高版本。 

  • fish-admin 是一个简单的前后台分离的开发模板 前台(ui)部分是基于 fish-ui 开发 后台(api)部分是基于 spring boot 开发, 提供json api接口供ui调用 使用方法 $ git clone https://github.com/myliang/fish-admin.git# 1 创建数据库 create database fish#   插入api/db/i