Skip to content

leonaves/git-sw-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-sw-plugin

Interactive CLI tool to install git skip-worktree aliases and prompt info for bash and zsh shells.

Features

  • Git Aliases: Convenient commands for managing skip-worktree files

    • git-sw-list - List all skip-worktree files
    • git-sw - Add modified files to skip-worktree
    • git-unsw - Remove all files from skip-worktree
  • Prompt Info: Display skip-worktree file count in your shell prompt

    • Customizable icon/emoji
    • Customizable colors
    • Automatic integration with Oh-My-Zsh themes (bullet-train, agnoster, etc.)
    • Live preview during configuration

Installation

Using npx (Recommended)

npx git-sw-plugin install

Uninstall

npx git-sw-plugin uninstall

Supported Shells

  • Bash (with .bashrc, .bash_profile, or .profile)
  • Zsh (with .zshrc)
  • Oh-My-Zsh themes (automatic detection)

How It Works

  1. Auto-Detection: Detects your shell, RC files, and Oh-My-Zsh setup
  2. Interactive Configuration: Choose features, icons, and colors with live preview
  3. Smart Installation: Uses the best strategy for your prompt setup:
    • Oh-My-Zsh with prompt order: Fully automatic
    • Oh-My-Zsh themes: Segment function + instructions
    • Custom prompts: Function + manual integration guide
  4. Safe Modifications: Creates backups before making changes

Usage Examples

Git Aliases

After installation:

# List skip-worktree files
git-sw-list

# Add modified files to skip-worktree
git-sw

# Remove all files from skip-worktree
git-unsw

Prompt Display

When you have files marked as skip-worktree, your prompt will show:

~/projects/myapp (main) 🔒 SW:3 ❯

The count updates automatically as you add/remove skip-worktree files.

What is skip-worktree?

Git's skip-worktree feature allows you to tell Git to ignore changes to tracked files. This is useful for:

  • Local configuration files you don't want to commit
  • Development environment customizations
  • Temporary modifications for testing

Unlike .gitignore, skip-worktree works on tracked files.

Development

Project Structure

install-git-sw-plugin/
├── bin/
│   └── cli.js              # Executable entry point
├── src/
│   ├── index.js            # Main orchestrator
│   ├── shell-detector.js   # Shell and environment detection
│   ├── rc-file-manager.js  # Safe RC file modifications
│   ├── prompt-parser.js    # Parse existing prompts
│   ├── prompt-builder.js   # Generate shell-specific code
│   ├── preview.js          # Preview system (hybrid)
│   ├── ui.js               # Interactive UI with enquirer
│   └── installer.js        # Installation logic
├── package.json
└── README.md

Technologies

  • enquirer: Interactive CLI prompts
  • chalk: Terminal colors and styling
  • Node.js built-in modules for shell execution and file operations

Troubleshooting

"No RC file found"

Create an RC file first:

# For bash
touch ~/.bashrc

# For zsh
touch ~/.zshrc

"Cannot write to RC file"

Check file permissions:

chmod u+w ~/.zshrc  # or ~/.bashrc

Prompt not showing skip-worktree info

  1. Make sure you've reloaded your shell: source ~/.zshrc
  2. Check if manual integration is required (shown during installation)
  3. For Oh-My-Zsh: Verify gitskipworktree was added to your prompt order

Contributing

This is a local development project. To contribute:

  1. Make changes in the appropriate module
  2. Test with both bash and zsh
  3. Test with and without Oh-My-Zsh

License

MIT

About

Interactive CLI tool to install git skip-worktree aliases and prompt info.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published