Skip to main content

wtsh shell v26

Project description

wtsh - 基于cmd2的插件化交互式命令行Shell

wtsh 是一个基于 Python cmd2 库开发的交互式命令行 Shell,提供了基本的文件系统操作和容器环境检测功能。

托管仓库

功能特性

  • 交互式命令行界面:基于 cmd2 框架,支持命令自动补全和历史记录
  • 文件系统操作:支持 ls、cat、cd、clear 等基本命令
  • 容器环境检测:自动识别 Docker、Podman、LXC 等容器运行时环境
  • 彩色提示符:显示用户名、当前目录和操作系统平台信息

安装要求

  • Python 3.10+ (Windows7不支持)
  • cmd2 库

快速开始

运行方式

python wtsh.py

如果安装后运行:

wtsh

启动后会显示欢迎信息:

Welcome to the wtsh shell!wtsh version 26.5.17
username@/current/directory:platform>

命令列表

基础命令

命令 描述 示例
ls 列出当前目录下的文件和文件夹 ls
cat <file> 显示文件内容 cat README.md
cd <dir> 切换目录 cd /home/user
clear 清屏 clear
exit 退出 Shell exit

系统信息

命令 描述
aboutus 显示 wtsh 版本和系统信息
whichcontainer 检测当前是否运行在容器环境中
restore_prompt 还原提示符为默认样式

命令详解

ls

列出当前目录下的所有文件和目录:

username@/home:linux> ls
Documents
Downloads
Desktop

cat

显示指定文件的内容:

username@/home:linux> cat example.txt
Hello, wtsh!

cd

切换到指定目录:

username@/home:linux> cd Documents
username@/home/Documents:linux>

clear

清除终端屏幕内容。

exit

退出 wtsh Shell,返回系统命令行。

aboutus

显示 wtsh 的版本信息和运行时平台:

username@/home:linux> aboutus
wtsh version: 26.5.17
wtsh plugin protocol version: 7.2.0
wtsh plugin protocol name: wtsh.plugins
wtsh plugin protocol platform: entry_points
wtsh main runtime platform(OS platform): linux
supported plugin types: entrypoints+cmd2.commandset

whichcontainer

检测当前运行环境是否为容器,并显示容器运行时和名称:

username@/home:linux> whichcontainer
docker my-container

支持检测的容器类型:

  • Docker
  • Podman
  • LXC
  • Host(非容器环境)

restore_prompt

将提示符恢复为默认样式,移除容器信息显示。

提示符说明

wtsh 的提示符包含以下信息(带颜色):

\033[32m{username}\033[0m@\033[34m{current_dir}\033[0m:\033[33m{platform}\033[0m>
  • 绿色:用户名
  • 蓝色:当前工作目录
  • 黄色:操作系统平台

插件系统

wtsh 支持通过插件机制扩展功能,采用 Python entry_points 作为插件发现机制。

插件机制

wtsh 在启动时会自动扫描 wtsh.plugins 组下的所有 entry points,并动态加载:

for ep in entry_points(group="wtsh.plugins"):
    ep.load()
    print(f'Loaded plugin {ep.name}')

插件协议信息

  • 插件协议名称wtsh.plugins
  • 插件协议版本:7.2.0
  • 插件平台entry_points
  • 支持的插件类型entrypoints+cmd2.commandset

插件加载

插件会在 wtsh 启动时自动加载,加载成功后会显示:

Loaded plugin plugin_name

如果没有找到插件或加载失败,会显示相应的提示信息。

支持的平台

wtsh 可以在以下操作系统上运行:

  • Linux
  • Windows
  • macOS
  • KaihongOS (只支持在兼容层中安装,不支持直接在KaihongOS上运行,因为KaihongOS没有用户态python环境。之后KaihongOS会逐步开放用户可达的docker)

许可证

Apache License 2.0

版本历史

  • 26.5.17:当前版本,优化whl打包、docker镜像和容器检测功能,容器检测功能移除“自动附加到提示符”以防止信息泄露
  • 26.5.0:初始版本,包含基础文件操作和容器检测功能

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wtsh-26.5.17.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wtsh-26.5.17-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file wtsh-26.5.17.tar.gz.

File metadata

  • Download URL: wtsh-26.5.17.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for wtsh-26.5.17.tar.gz
Algorithm Hash digest
SHA256 fdd893ec3084408efed395b53fb0cacd4ad784f07d8e6d55f45c877bde216208
MD5 ab653970ec1c07a366e39b3ee6e34099
BLAKE2b-256 32e8a69e2a2defcdc928e895dc13578655556cfcb67b7a80581c8e4e583b12b5

See more details on using hashes here.

File details

Details for the file wtsh-26.5.17-py3-none-any.whl.

File metadata

  • Download URL: wtsh-26.5.17-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for wtsh-26.5.17-py3-none-any.whl
Algorithm Hash digest
SHA256 e688dab9ba44ef6a6e5fdb8a2283297b1a6093e85f08e2c97c7af9e4cd665a56
MD5 ddbfba0da1a2e27301236bc690d17fa6
BLAKE2b-256 8452eb65a55a70d3534043c5e1f072d73bfe0b9ffaa4feb3edb0a12a1805f57b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page