2 个不稳定版本
0.2.0 | 2024年3月10日 |
---|---|
0.1.0 | 2024年3月3日 |
#2462 in 命令行工具
每月 55 次下载
15KB
295 行
Dev Workspaces
一个帮助管理工作区目录及其项目的简单工具。
入门指南
安装方法
# From crates.io
cargo install dev-workspaces --bin workspaces
# From github repository
cargo install dev-workspaces --git https://github.com/czifro/dev-workspaces --bin workspaces
示例
# $HOME/.config/workspaces/workspaces.yaml
root: ~/
workspaces:
src:
workspaces:
nested:
workspaces:
projects:
project_a:
project_b:
project_c:
projects:
project_1:
project_2:
project_3:
# Run:
# $ workspaces list workspaces
# /<expanded-home-dir>/src
# /<expanded-home-dir>/src/nested
#
# Run:
# $ workspaces list projects
# /<expanded-home-dir>/src/project_1
# /<expanded-home-dir>/src/project_2
# /<expanded-home-dir>/src/project_3
# /<expanded-home-dir>/src/nested/project_a
# /<expanded-home-dir>/src/nested/project_b
# /<expanded-home-dir>/src/nested/project_c
CLI 使用
$ workspaces help
A dev tool to simplify working with workspace directories
Usage: workspaces <COMMAND>
Commands:
list List out managed paths
doctor Show doctor diagnosis on managed workspaces and projects
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
$ workspaces help list
List out managed paths
Usage: workspaces list <COMMAND>
Commands:
workspaces List workspace paths
projects List project paths
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
$ workspaces list help workspaces
List workspace paths
Usage: workspaces list workspaces
Options:
-h, --help Print help
-V, --version Print version
$ workspaces list help projects
List project paths
Usage: workspaces list projects
Options:
-h, --help Print help
-V, --version Print version
$ workspaces help doctor
Show doctor diagnosis on managed workspaces and projects
Usage: workspaces doctor
Options:
-h, --help Print help
-V, --version Print version
$ workspaces help config
Show config path
Usage: workspaces config [OPTIONS]
Options:
-q, --quiet Quiet extraneous output
-h, --help Print help
-V, --version Print version
用例
Tmux 会话管理器
使用 workspaces
与 tmux 会话工具一起,可以直接在项目路径打开新的 tmux 会话
if [[ $# -eq 1 ]]; then
selected=$1
else
selected=$(workspaces list projects | fzf)
fi
if [[ -z $selected ]]; then
exit 0
fi
selected_name=$(basename "$selected" | tr . _)
tmux_running=$(pgrep tmux)
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
tmux new-session -s $selected_name -c $selected
exit 0
fi
if ! tmux has-session -t=$selected_name 2> /dev/null; then
tmux new-session -ds $selected_name -c $selected
fi
tmux switch-client -t $selected_name
恢复 Git 克隆
(待定功能)
意外删除项目或工作区,使用 workspaces
工具重新克隆项目,或重新构建工作区并重新克隆工作区中的所有项目。
依赖项
~3–12MB
~118K SLoC