git-open

command module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 10 Imported by: 0

README

git-open

Утилита nazeebo для быстрого открытия Git-репозитория в браузере.

Build and Test Release Go Version

Описание

git open — это команда, которая автоматически находит remote репозитории в .git/config и открывает выбранный проект в браузере.

Возможности

  • 🔍 Автоматический поиск .git директории
  • 📝 Чтение и парсинг .git/config
  • 🌐 Поддержка SSH и HTTPS URL
  • 🎯 Интерактивный выбор remote, если их несколько
  • 🚀 Открытие в браузере по умолчанию
  • ⚡️ Скомпилированный бинарник без зависимостей

Требования

  • Go 1.16+ (только для сборки)
  • Git репозиторий с настроенными remotes

Установка

📦 Способ 1: Готовые бинарники (рекомендуется)

Скачайте готовый бинарник из последнего релиза.

macOS

Apple Silicon (M1/M2/M3):

# Скачать и установить
curl -L https://github.com/nazeebod/git-open/releases/latest/download/git-open-darwin-arm64.tar.gz | tar xz
sudo mv git-open-darwin-arm64 /usr/local/bin/git-open
chmod +x /usr/local/bin/git-open

# Или установить в ~/bin (без sudo)
mkdir -p ~/bin
mv git-open-darwin-arm64 ~/bin/git-open
chmod +x ~/bin/git-open

Intel:

# Скачать и установить
curl -L https://github.com/nazeebod/git-open/releases/latest/download/git-open-darwin-amd64.tar.gz | tar xz
sudo mv git-open-darwin-amd64 /usr/local/bin/git-open
chmod +x /usr/local/bin/git-open

# Или установить в ~/bin (без sudo)
mkdir -p ~/bin
mv git-open-darwin-amd64 ~/bin/git-open
chmod +x ~/bin/git-open
Linux

AMD64:

# Скачать и установить
curl -L https://github.com/nazeebod/git-open/releases/latest/download/git-open-linux-amd64.tar.gz | tar xz
sudo mv git-open-linux-amd64 /usr/local/bin/git-open
chmod +x /usr/local/bin/git-open

# Или установить в ~/bin (без sudo)
mkdir -p ~/bin
mv git-open-linux-amd64 ~/bin/git-open
chmod +x ~/bin/git-open

ARM64 (Raspberry Pi, серверы ARM):

# Скачать и установить
curl -L https://github.com/nazeebod/git-open/releases/latest/download/git-open-linux-arm64.tar.gz | tar xz
sudo mv git-open-linux-arm64 /usr/local/bin/git-open
chmod +x /usr/local/bin/git-open
Windows

PowerShell:

# Скачать
Invoke-WebRequest -Uri "https://github.com/nazeebod/git-open/releases/latest/download/git-open-windows-amd64.zip" -OutFile "git-open.zip"

# Распаковать
Expand-Archive -Path git-open.zip -DestinationPath .

# Переместить в директорию в PATH
Move-Item git-open-windows-amd64.exe C:\Windows\System32\git-open.exe

# Или добавить текущую директорию в PATH

Вручную:

  1. Скачайте git-open-windows-amd64.zip из релизов
  2. Распакуйте архив
  3. Переименуйте git-open-windows-amd64.exe в git-open.exe
  4. Переместите в директорию из PATH (например, C:\Windows\System32\)
🔧 Способ 2: Сборка из исходников
# Клонировать репозиторий
git clone https://github.com/nazeebod/git-open.git
cd git-open

# Собрать и установить (используя Makefile)
make install          # установка в /usr/local/bin (требует sudo)
# или
make install-user     # установка в ~/bin (без sudo)

# Или вручную
go build -o git-open
sudo mv git-open /usr/local/bin/
🐹 Способ 3: Установка через go install
go install github.com/nazeebod/git-open@latest

# Убедитесь, что $GOPATH/bin в вашем PATH
export PATH=$PATH:$(go env GOPATH)/bin
⚙️ Настройка PATH

Если установили в ~/bin:

macOS/Linux (bash):

echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

macOS/Linux (zsh):

echo 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Windows (PowerShell):

# Добавить текущую директорию пользователя в PATH
$env:Path += ";$HOME\bin"
[Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::User)

Использование

Перейдите в любую директорию внутри Git репозитория и выполните:

git open
Примеры

Один remote:

$ git open
Opening origin: https://github.com/nazeebod/git-open

Несколько remotes:

$ git open
Multiple remotes found:
  1. origin (git@github.com:nazeebod/git-open.git)
  2. gitlab (git@gitlab.com:nazeebod/git-open.git)

Select remote (number or name): 1
Opening origin: https://github.com/nazeebod/git-open

Вы можете выбрать remote по номеру (1, 2) или по имени (origin, cu).

Только вывод remote url в терминал :

$ git open
Opening origin: https://github.com/nazeebod/git-open

Поддерживаемые форматы URL

Утилита автоматически конвертирует Git URL в браузерные:

  • SSH с портом: ssh://git@gitlab.com:2202/ci/repo.githttps://gitlab.com/ci/repo
  • SSH без порта: ssh://git@gitlab.com/user/repo.githttps://gitlab.com/user/repo
  • SSH стандартный: git@github.com:user/repo.githttps://github.com/user/repo
  • HTTPS: https://github.com/user/repo.githttps://github.com/user/repo

Поддерживаемые платформы

  • ✅ macOS
  • ✅ Linux
  • ✅ Windows

Разработка

Структура проекта
git-open/
├── main.go           # Основной код утилиты
├── go.mod           # Go модуль
├── README.md        # Документация
└── config-example   # Пример .git/config
Сборка
# Используя Makefile (рекомендуется)
make build           # Собрать для текущей платформы
make install         # Собрать и установить в /usr/local/bin
make install-user    # Собрать и установить в ~/bin
make clean          # Удалить артефакты сборки
make release        # Собрать для всех платформ
make fmt            # Форматировать код
make lint           # Проверить код
make help           # Показать все команды

# Или вручную
go build -o git-open
go test ./...
go fmt ./...
Создание релиза
# Сборка для всех платформ
./build-all.sh  # или вручную используйте GOOS/GOARCH

# Создание архивов
tar -czf git-open-darwin-amd64.tar.gz git-open-darwin-amd64
tar -czf git-open-linux-amd64.tar.gz git-open-linux-amd64
zip git-open-windows-amd64.zip git-open-windows-amd64.exe

Устранение проблем

"Command not found":

  • Убедитесь, что бинарник в PATH: echo $PATH
  • Проверьте установку: which git-open

"Not a git repository":

  • Выполните команду внутри Git репозитория
  • Проверьте наличие .git директории: ls -la | grep .git

"No remotes found":

  • Убедитесь, что у репозитория есть хотя бы один remote: git remote -v
  • Проверьте содержимое .git/config

"Error opening browser" (Linux):

  • Установите xdg-utils: sudo apt-get install xdg-utils

Технологии

  • Язык: Go (Golang)
  • Зависимости: только стандартная библиотека
  • Размер бинарника: ~2-3 MB

Преимущества Go версии

  • ⚡️ Мгновенный запуск (скомпилированный код)
  • 📦 Один бинарник без зависимостей
  • 🔄 Кросс-платформенность из коробки
  • 🪶 Небольшой размер
  • 🛡 Строгая типизация и безопасность памяти

Лицензия

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL