You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Windows Cmdr/ConEmu中配置goweb别名打开当前GitHub分支网页?

How to create a goweb alias in Cmder/ConEmu to open your GitHub branch page

Got it, let's walk through setting up that goweb alias you need in Cmder or ConEmu. We'll start with a fixed repository (as you requested) and then add the auto-detection for remote repos later.

Step 1: Create a batch script for the goweb functionality

First, we'll make a small batch script that fetches your current Git branch and opens the right GitHub page. Here's how:

  1. Open Notepad and paste this code (replace your-username and your-repo with your actual GitHub repo details):
@echo off
setlocal
:: Grab the current Git branch name
for /f "tokens=*" %%i in ('git rev-parse --abbrev-ref HEAD') do set BRANCH=%%i
:: Your fixed repository URL
set REPO_URL=https://github.com/your-username/your-repo
:: Build the full branch page URL
set PAGE_URL=%REPO_URL%/tree/%BRANCH%
:: Open the URL in your default browser
start "" "%PAGE_URL%"
endlocal
  1. Save this file as goweb.bat.
  2. Move the file to %CMDER_ROOT%\bin (if using Cmder) — this directory is already in your Cmder PATH, so the script will be accessible anywhere. If you're using plain ConEmu, add the folder containing goweb.bat to your system PATH.

Step 2: Set up the alias (optional but clean)

Cmder lets you define aliases in its config file to keep things consistent with your Oh My Zsh workflow:

  1. Open Cmder, then press Win + Alt + P to open the settings.
  2. Go to Startup > Tasks, or directly edit the user aliases file at %CMDER_ROOT%\config\user_aliases.cmd.
  3. Add this line to the file:
goweb=goweb.bat $*
  1. Save the file and restart Cmder. Now you can just type goweb in any Git repo (your fixed one) to open the current branch's GitHub page.

Step 3: Optimize for auto-detecting remote repos

To make this work with any repo (instead of a fixed one), update your goweb.bat script to automatically pull the remote repository URL from Git:

@echo off
setlocal
:: Get current branch
for /f "tokens=*" %%i in ('git rev-parse --abbrev-ref HEAD') do set BRANCH=%%i
:: Get the origin remote URL
for /f "tokens=*" %%i in ('git config --get remote.origin.url') do set REMOTE_URL=%%i
:: Convert SSH URLs to HTTPS (so it works in the browser)
set HTTPS_URL=%REMOTE_URL:.git=%
set HTTPS_URL=%HTTPS_URL:git@github.com:=https://github.com/%
:: Build the branch page URL
set PAGE_URL=%HTTPS_URL%/tree/%BRANCH%
:: Open in default browser
start "" "%PAGE_URL%"
endlocal

This script will handle both HTTPS and SSH remote URLs, so it works no matter how you cloned your repo.

Notes for ConEmu users

If you're using plain ConEmu without Cmder, you can set the alias using doskey directly in your ConEmu startup task:

  1. Open ConEmu settings (Win + Alt + P).
  2. Go to Startup > Tasks, edit your default shell task.
  3. Add this line at the end of the command list:
doskey goweb=goweb.bat $*

Save and restart ConEmu, and the alias will work globally.

内容的提问来源于stack exchange,提问作者Ambrose Little

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:05:49