Skip to content

cookie891124/bash-wt-menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bash in Windows Terminal — Right-Click Context Menu

English | 中文

Adds "Bash (Windows Terminal)" to the Windows right-click context menu. Right-click any folder → open Git Bash in Windows Terminal, pre-positioned in that directory.

Screenshot


English

Why This Tool?

Claude Code runs best in a bash environment on Windows. While PowerShell and CMD can work, bash provides:

  • Native Unix toolchaingrep, find, sed, and other tools behave exactly as Claude Code expects
  • Consistent path handling/c/Users/... instead of backslash/forward-slash confusion
  • Better script execution — Claude Code frequently generates and runs bash snippets
  • Cross-platform parity — same shell experience as macOS/Linux teammates

This tool eliminates the friction of manually cd-ing from your home directory. Right-click where you want to work → you're there in bash, ready to run claude.

Prerequisites

  • Git for Windows — provides bash.exe (download)
  • Windows Terminal — pre-installed on Windows 11, or winget install Microsoft.WindowsTerminal

Install

powershell -ExecutionPolicy Bypass -File install.ps1

No admin rights required. The installer:

  1. Auto-detects bash.exe and wt.exe on your system
  2. Generates a launcher script in ~/bin/
  3. Writes registry entries under HKCU\Software\Classes

Usage

Right-click in any folder (or empty space inside a folder) → Bash (Windows Terminal).

Then simply type claude to start your Claude Code session in that directory.

Uninstall

powershell -ExecutionPolicy Bypass -File ~/bin/uninstall-bash-wt-menu.ps1

Or re-run the installer and copy the uninstall command from its output.

How It Works

Right-click → Registry → PowerShell launcher → wt.exe -d <dir> -- bash.exe

The launcher handles two Windows command-line edge cases:

Problem Fix
Start-Process -ArgumentList doesn't quote paths with spaces (PowerShell 5.1 bug) Manual ProcessStartInfo.Arguments construction
Drive root paths like D:\" break argument parsing (backslash escapes closing quote) Doubles trailing backslash: D:\\
Windows Terminal version upgrades change wt.exe path Searches all drives at runtime

Files

File Purpose
install.ps1 One-shot installer — the only file you need

The installer generates ~/bin/open-bash-wt.ps1 (launcher) and ~/bin/uninstall-bash-wt-menu.ps1 at install time.


中文

为什么需要这个工具?

Claude Code 在 Windows 上最适合在 bash 环境 中运行。PowerShell 和 CMD 虽然也能用,但 bash 提供:

  • 原生 Unix 工具链grepfindsed 等工具的行为与 Claude Code 预期完全一致
  • 路径处理一致 — 使用 /c/Users/... 格式,避免反斜杠与正斜杠的混淆
  • 更好的脚本兼容 — Claude Code 经常生成并执行 bash 代码片段
  • 跨平台统一 — 与 macOS/Linux 团队成员使用相同的 shell 体验

这个工具省去了手动 cd 到目标目录的麻烦。在任意文件夹右键 → 直接进入 Windows Terminal 中的 bash 环境,立即就能运行 claude

前置条件

  • Git for Windows — 提供 bash.exe下载
  • Windows Terminal — Windows 11 预装,或 winget install Microsoft.WindowsTerminal

安装

powershell -ExecutionPolicy Bypass -File install.ps1

无需管理员权限。安装器会:

  1. 自动检测系统中的 bash.exewt.exe
  2. ~/bin/ 生成启动脚本
  3. HKCU\Software\Classes 写入注册表项

使用

在任意文件夹(或文件夹内空白处)右键 → Bash (Windows Terminal)

然后输入 claude 即可在该目录启动 Claude Code 会话。

卸载

powershell -ExecutionPolicy Bypass -File ~/bin/uninstall-bash-wt-menu.ps1

技术细节

右键菜单 → 注册表 → PowerShell 启动器 → wt.exe -d <目录> -- bash.exe

启动器处理了两个 Windows 命令行的边界问题:

问题 解决方案
PowerShell 5.1 的 Start-Process -ArgumentList 不给含空格的参数加引号 手动构造 ProcessStartInfo.Arguments 字符串
盘符根目录 D:\"\ 会把引号转义,破坏参数边界 运行时检测并加倍末尾反斜杠:D:\\
Windows Terminal 升级会改变 wt.exe 路径 每次运行时动态搜索所有驱动器

文件说明

文件 用途
install.ps1 一键安装脚本(唯一需要的文件)

安装器在运行时生成 ~/bin/open-bash-wt.ps1(启动器)和 ~/bin/uninstall-bash-wt-menu.ps1(卸载脚本)。


License

MIT

About

Add Bash (Windows Terminal) to Windows right-click context menu. Open Git Bash in any folder with one click - optimized for Claude Code users on Windows.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors