Skip to content

Zsh Git 相对路径插件 一个简单但实用的 Zsh 插件,它可以在你的命令提示符中显示相对于 Git 项目根目录的当前路径。这个插件是在 AI 的协助下在短短 10 分钟内完成的,展示了 AI 辅助开发的强大能力。

License

Notifications You must be signed in to change notification settings

cs-magic-open/zsh-git-relative-path

Repository files navigation

Zsh Git Relative Path Plugin

Zsh Git Relative Path Plugin Logo

A ZSH plugin that shows your current path relative to the git project root in your prompt.

Features

  • Works with any oh-my-zsh theme
  • Shows path relative to git project root when in a git repository
  • Falls back to normal path display when not in a git repository
  • Special support for popular themes (robbyrussell, agnoster, avit)
  • Zero configuration needed!

Prerequisites

Installation

Using npm (Recommended)

npm install -g @cs-magic-open/zsh-git-relative-path

That's it! The plugin will be automatically configured and activated after installation.

Alternative: Manual Installation

If you prefer to inspect the code first:

# 1. Clone the repository
git clone https://github.com/cs-magic-open/zsh-git-relative-path
cd zsh-git-relative-path

# 2. Install globally from local
npm install -g .

Usage

Once installed, the plugin will automatically modify your prompt to show paths relative to the git project root. No additional configuration is needed!

Example:

# Before (in /Users/username/projects/my-project/src/components)
username ~/projects/my-project/src/components $

# After (same directory)
username src/components $

Updating

To update to the latest version:

npm update -g @cs-magic-open/zsh-git-relative-path

Uninstallation

npm uninstall -g @cs-magic-open/zsh-git-relative-path

Development

To contribute or modify the plugin:

# Clone the repository
git clone https://github.com/cs-magic-open/zsh-git-relative-path
cd zsh-git-relative-path

# Install dependencies
npm install

# Make your changes...

# Bump version
npm version patch  # or minor/major

License

MIT

Author

cs-magic-open

About

Zsh Git 相对路径插件 一个简单但实用的 Zsh 插件,它可以在你的命令提示符中显示相对于 Git 项目根目录的当前路径。这个插件是在 AI 的协助下在短短 10 分钟内完成的,展示了 AI 辅助开发的强大能力。

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published