Skip to content

lutefd/p-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

p-switch

A beautiful TUI to switch between Git profiles (personal/work) on macOS.

Features

  • Pretty terminal UI with Charm Bracelet
  • Keeps your emails private (config.yaml is gitignored)
  • Switches both SSH config and Git user config
  • GPG key signing support per profile
  • Easy keyboard navigation

Setup

Option 1: Install from GitHub (Recommended)

go install github.com/lutefd/p-switch@latest

Then run p-switch once to generate the config file at ~/.config/p-switch/config.yaml, edit it with your details, and run again!

Option 2: Build from source

git clone https://github.com/lutefd/p-switch.git
cd p-switch
go build -o p-switch
chmod +x p-switch
sudo ln -sf $(pwd)/p-switch /usr/local/bin/p-switch

Config Setup

On first run, p-switch will create ~/.config/p-switch/config.yaml for you. Edit it with your details:

profiles:
  personal:
    name: "Your Name"
    email: "your.personal@email.com"
    sshIdentityFile: "~/.ssh/personal"
    gpgKey: ""  # GPG key ID for commit signing (optional, leave empty to disable)
  work:
    name: "Your Name"
    email: "your.work@email.com"
    sshIdentityFile: "~/.ssh/work"
    gpgKey: "ABC123"  # GPG key ID for commit signing (optional, leave empty to disable)

sshConfigPath: "~/.ssh/config"

Usage

Switch profiles

p-switch

Use arrow keys or j/k to navigate, Enter to select, q to quit.

Edit config

p-switch --edit    # Opens config in $EDITOR (defaults to vim)

Find config location

p-switch --config  # Prints: ~/.config/p-switch/config.yaml

Or just edit directly:

vim ~/.config/p-switch/config.yaml

How it works

When you select a profile, p-switch will:

  1. Update your ~/.ssh/config to use the correct IdentityFile for github.com
  2. Update your global git config for user.email and user.name
  3. Configure GPG commit signing if a gpgKey is set (or disable it if empty)

Note: p-switch sets global git config. Local repo-level config (.git/config) will take precedence over these settings.

About

Collection of scripts on my personal machine to switch profiles and other stuff

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages