Skip to content
/ dirauto Public

dirauto — Rust 编写的轻量级目录感知环境管理器:进入目录自动加载环境/脚本,离开自动清理,保持每个项目环境独立、干净。 dirauto — A lightweight, directory-aware environment manager written in Rust. Auto-loads env/hooks on enter, auto-cleans on leave, keeping every project isolated and clean.

Notifications You must be signed in to change notification settings

fb0sh/dirauto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dirauto

智能环境管理工具 | Smart Environment Management Tool

Crates.io Rust License: MIT

English | 中文


简介

dirauto — Rust 编写的轻量级目录感知环境管理器:进入目录自动加载环境,离开自动清理,让每个项目都有独立的 ENV 与自动化脚本。

  • 它是单一职责、纯粹的“目录进出规则控制器”,没有臃肿的插件系统,也不包办一切,只做一件事:让每个项目都有干净、隔离的环境。

特性

  • 自动切换:进入目录时自动加载环境,离开时自动清理
  • 项目隔离:每个项目独立配置,互不干扰
  • 快速响应:Rust 编写,性能卓越
  • 简单配置:使用 TOML 格式,通俗易懂
  • HOOKS: 支持 on_enter / on_leave 自动执行脚本

演示

asciicast

快速开始

1. 安装

# 从源码安装
cargo install dirauto

# 或本地构建
git clone https://github.com/fb0sh/dirauto
cd dirauto
cargo build --release

2. 配置 Shell

# Bash
eval "$(dirauto hook --shell bash)"

# Zsh  
eval "$(dirauto hook --shell zsh)"

把上述命令添加到你的 ~/.bashrc~/.zshrc 文件中。

3. 创建配置

# 在项目目录创建配置文件
dirauto init

这会创建一个 .dirauto.toml 文件,编辑它来配置你的环境:

# Dirauto configuration file
# Environment variables to set when entering this directory
[env]
DIRAUTO_VAR = "dirauto initialized successfully"

# Actions to perform when entering/leaving this directory
[actions]
on_enter = [
    "echo 'Entering project directory'",
#     "source .venv/bin/activate"
]

on_leave = [
    "echo 'Leaving project directory'",
#     "deactivate"
]

4. 验证配置

重新加载你的 shell 配置或重启终端,然后验证 dirauto 是否正常工作:

# 检查环境变量
env | grep 'DIRAUTO'

你应该能看到类似输出:

DIRAUTO_VERSION=1.0.0
DIRAUTO_OLD_PWD=/home/yourusername
DIRAUTO_SHELL_TYPE=bash

5. 完成!

现在切换到项目目录,环境会自动加载。离开目录时,环境会自动清理。

命令说明

  • dirauto init - 创建配置文件
  • dirauto hook --shell <bash|zsh> - 生成 Shell 钩子
  • dirauto status - 查看当前配置状态

License

MIT

About

dirauto — Rust 编写的轻量级目录感知环境管理器:进入目录自动加载环境/脚本,离开自动清理,保持每个项目环境独立、干净。 dirauto — A lightweight, directory-aware environment manager written in Rust. Auto-loads env/hooks on enter, auto-cleans on leave, keeping every project isolated and clean.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages