ut:用 Rust 开发的开发者 CLI 工具集
提供常用开发操作的实用 CLI 工具库,用 Rust 编写。可直接提升命令行开发效率。
提供常用开发操作的实用 CLI 工具库,用 Rust 编写。可直接提升命令行开发效率。
一个快速、轻量级的 CLI 工具包,为开发者和 IT 专业人士服务。ut 在单个二进制文件中提供了全面的常用工具集,无需安装和记忆多个实用程序,也无需为执行简单任务而搜索随机网站。
brew install ksdme/tap/ut
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/ksdme/ut/releases/latest/download/ut-installer.sh | sh
powershell -ExecutionPolicy Bypass -c "irm https://github.com/ksdme/ut/releases/latest/download/ut-installer.ps1 | iex"
cargo install --git https://github.com/ksdme/ut.git
你也可以直接从发布页面下载预编译二进制文件。
ut 支持 bash、zsh、fish、nushell、elvish 和 PowerShell 的 shell 完成。启用 Tab 补完:
# 生成完成脚本并保存到 fpath
ut completions zsh > ~/.zsh/completions/_ut
# 或直接添加到 .zshrc(每次 ut 更新都需要重新加载)
echo 'eval "$(ut completions zsh)"' >> ~/.zshrc
ut completions bash > ~/.local/share/bash-completion/completions/ut
# 或添加到 .bashrc
echo 'eval "$(ut completions bash)"' >> ~/.bashrc
ut completions fish > ~/.config/fish/completions/ut.fish
ut completions nushell > ~/.config/nushell/completions/ut.nu
# 或使用短别名
ut completions nu > ~/.config/nushell/completions/ut.nu
ut completions powershell | Out-File -FilePath $PROFILE -Append
设置完成后,重启 shell 或 source 配置文件。
├── Encoding
│ ├── base64 - Base64 编码/解码
│ │ ├── encode
│ │ └── decode
│ └── url - URL 工具
│ ├── parse
│ ├── encode
│ └── decode
├── Hashing & Security
│ ├── hash - 密码学哈希摘要
│ │ ├── md5
│ │ ├── sha1
│ │ ├── sha224
│ │ ├── sha256
│ │ ├── sha384
│ │ └── sha512
│ ├── bcrypt - 密码哈希和验证
│ │ ├── hash
│ │ └── verify
│ └── jwt - JWT (JSON Web Token) 工具
│ ├── encode
│ ├── decode
│ └── verify
├── Data Generation
│ ├── uuid - 生成 UUID
│ │ ├── v1
│ │ ├── v3
│ │ ├── v4
│ │ ├── v5
│ │ └── v7
│ ├── token (secret, password) - 生成安全随机令牌
│ ├── lorem - 生成 lorem ipsum 文本
│ └── random - 生成随机数
├── Text Processing
│ ├── case - 转换文本大小写格式
│ │ ├── lower
│ │ ├── upper
│ │ ├── camel
│ │ ├── title
│ │ ├── constant
│ │ ├── header
│ │ ├── sentence
│ │ ├── snake
│ │ └── kebab
│ ├── pretty-print (pp) - 取消转义换行符和制表符
│ └── diff - 比较文本并显示可视化差异
├── Development Tools
│ ├── calc (cal) - 表达式计算器
│ ├── json - JSON 构建器和工具
│ │ └── builder
│ ├── regex - 交互式正则表达式测试器
│ ├── crontab - Cron 工具
│ │ └── schedule
│ └── datetime (dt) - 解析和转换日期时间
├── Web & Network
│ ├── ip - IP 和 CIDR 工具
│ │ └── cidr
│ │ └── describe
│ ├── http - HTTP 工具
│ │ └── status
│ ├── serve - 本地 HTTP 文件服务器
│ └── qr - 生成二维码
├── Color & Design
│ └── color - 颜色工具
│ └── convert
└── Reference
└── unicode - Unicode 符号参考
使用 Base64 编码来编码和解码数据。
支持标准和 URL 安全字符集
可从文件或 stdin 读取
ut base64 encode "hello world"
ut base64 decode "aGVsbG8gd29ybGQ="
ut base64 encode --urlsafe "hello world"
echo -n "hello world" | ut base64 encode -
ut url parse "https://example.com:8080/path?key=value#section"
ut url encode "hello world"
ut url decode "hello%20world"
printf "hello world" | ut url encode -
生成各种算法的密码学哈希摘要。
支持 MD5、SHA-1、SHA-224、SHA-256、SHA-384 和 SHA-512
可从文件或 stdin 读取
ut hash sha256 "hello world"
ut hash md5 - < file.txt
echo -n "password" | ut hash sha256 -
使用 bcrypt 算法对密码进行哈希和验证。
带可配置成本因子的安全密码哈希
为每个哈希内置盐值生成
验证返回 "valid" 或 "invalid"
成本因子范围:4-31(默认:12,越高越安全但速度越慢)
# 使用默认成本因子 (12) 哈希密码
ut bcrypt hash "mypassword"
echo -n "mypassword" | ut bcrypt hash -
# 错误密码验证
ut bcrypt verify "wrongpassword" '$2b$12$...'
# 输出:invalid
用于编码、解码和验证 token 的 JWT (JSON Web Token) 工具。
支持 HMAC 算法 (HS256、HS384、HS512)
使用自定义声明(iss、sub、aud、exp)编码
在不验证的情况下解码(检查 token)
使用签名验证进行验证
# 使用自定义声明编码 JWT
ut jwt encode --payload '{"user":"alice"}' --secret "my-secret" --issuer "my-app" --expires-in 3600
# 在不验证的情况下解码 JWT
ut jwt decode eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
# 使用签名验证来验证 JWT
ut jwt verify TOKEN --secret "my-secret" --issuer "my-app"
生成各种版本的 UUID。
v3:命名空间 + MD5 哈希
v5:命名空间 + SHA-1 哈希
v7:基于时间戳,可排序
ut uuid v4
ut uuid v4 --count 5
ut uuid v5 --namespace DNS --name example.com
ut uuid v7
ut uuid v7 --count 5
生成密码学安全的随机令牌。
可自定义长度和字符集
使用操作系统级别的安全随机性
可用于密码、API 密钥、会话令牌等
# 生成一个 32 字符的令牌
ut token --length 32
# 生成密码(使用别名)
ut password --length 16
# 生成不含符号的令牌
ut secret --no-symbols --length 64
# 生成不含大写字母的令牌
ut token --no-uppercase --length 20
生成 lorem ipsum 占位符文本。
可自定义段落数和句子结构
ut lorem --paragraphs 5
ut lorem --min-sentences 2 --max-sentences 6
在指定范围内生成随机数。
支持带步长参数的十进制精度
可一次生成多个值
ut random --min 1 --max 100
ut random --min 0 --max 1 --step 0.01 --count 10
在不同的大小写格式之间转换文本。
小写、大写、驼峰式、蛇形、烤肉串式、标题大小写、常量大小写、标题大小写、句子大小写
ut case lower "Hello World"
ut case camel "hello_world"
ut case snake "HelloWorld"
ut case kebab "HelloWorld"
echo -n "Hello :)" | ut case lower -
解决文本中转义的换行符和制表符。
ut pretty-print "hello\nworld\ttab"
ut pp "hello\nworld\ttab"
使用可视化 diff 输出比较文本内容。
支持文件比较或交互式编辑
彩色编码的字符级差异
ut diff -a file1.txt -b file2.txt
ut diff # 为两个输入打开编辑器
支持多种数字格式和数学函数的表达式计算器。
支持算术运算、幂运算、函数(sin、cos、tan、log、exp、sqrt、abs、floor、ceil、round)
二进制 (0b)、十六进制 (0x) 和十进制数字格式
数学常数(pi、e)
十进制、十六进制和二进制格式的结果显示
ut calc "2 + 2 * 3"
ut cal "sin(pi / 2)"
ut calc "0xFF + 0b1010"
ut calc "sqrt(16) ^ 2"
echo -n "2 + 2" | ut calc -
包括强大的 JSON 构建器的 JSON 工具。
使用点符号构建复杂的 JSON 结构
支持嵌套对象和数组
数组索引和追加操作
ut json builder a.b.c=hello a.b.d=world
ut json builder "user.name=John" "user.age=30" "user.tags[]=dev" "user.tags[]=rust"
ut json builder "items[0].id=1" "items[0].name=first" "items[1].id=2"
具有实时高亮显示的交互式正则表达式测试器。
实时模式匹配可视化
捕获组的多色高亮
从文件加载测试字符串
ut regex
ut regex --test sample.txt
解析 crontab 表达式并显示即将执行的时间。
支持传统的 5 字段 cron 表达式
支持扩展的 6 字段 cron 表达式(带秒数)
可配置的结果数量,使用 -n / --count
可配置的开始时间,使用 -a / --after
ut crontab schedule "0 9 * * 1-5"
ut crontab schedule "0 0 * * *" --count 3
ut crontab schedule "0 9 * * 1-5" --after "2024-01-01T00:00:00Z"
echo -n "0 9 * * 1-5" | ut crontab schedule -
在时区之间解析和转换日期时间。
支持 ISO 8601 和自定义格式字符串
在时区之间转换
"now" 关键字用于当前时间
ut datetime now
ut dt "2025-10-04T15:30:00Z" --target-timezone "Asia/Tokyo"
ut datetime "October 04, 2025 03:30 PM" --source-timezone UTC --parse-format "MonthName Day2, Year4 Hour12:Minute2 AMPM"
echo -n "2025-10-04T15:30:00Z" | ut datetime -
IP 和 CIDR 工具,包括描述 CIDR 块的工具。
ut ip cidr describe 192.168.1.100/24
ut ip cidr describe 10.0.0.0/8
ut ip cidr describe 172.16.0.1/16
包括状态码查询的 HTTP 工具。
ut http status 404
ut http status # 列出所有状态码
启动本地 HTTP 文件服务器。
可自定义主机和端口
目录列表支持
可选的 HTTP 基本身份验证
ut serve --port 8080
ut serve --directory ./public --auth username:password
终端显示或保存为 PNG 文件
ut qr "https://example.com"
ut qr "Hello World" --output qrcode.png
echo -n "Hello World" | ut qr -
用于处理不同颜色格式的颜色工具。
支持 hex、rgb、rgba、hsl、hwb、lab、lch、oklab、oklch
解析任何 CSS 兼容的颜色格式
ut color convert "#FF5733"
ut color convert "rgb(255, 87, 51)"
ut color convert "hsl(9, 100%, 60%)"
printf "#FF5733" | ut color convert -
显示 Unicode 符号参考表。
ut unicode
# 运行项目
cargo run -- <tool> [args]
# 格式化代码
cargo fmt
# 运行测试
cargo test
本项目的部分内容是使用 Claude Code(一个 AI 驱动的编码助手)在人工监督和协作下构建的。
欢迎贡献!请随时提交拉取请求。