Skip to content

Latest commit

 

History

History
221 lines (165 loc) · 5.85 KB

File metadata and controls

221 lines (165 loc) · 5.85 KB

git-chord

Vim-style composable git commands for zsh. Chain multiple git operations in a single keystroke sequence.

g acp "Fix bug"              # add → commit → push
g x"feature"ac"WIP"p         # checkout feature → add → commit "WIP" → push  
g ac"Done"R                  # commit → sync-rebase from main (auto-returns to branch)

Why?

Most git alias systems will give you shortcuts like ga for git add.

That's fine, but you still need to type:

ga && gc "message" && gp

But with git-chord, you just type:

g acp "message"

The chord acp is parsed character-by-character: add, commit, push.

Arguments are bound automatically to the commands that need them.

Features

  • Single-char commands compose into chords
  • Inline quoted args for explicit binding: g x"main"ac"msg"p
  • Positional args consumed left-to-right: g xacp main "msg"
  • Macros that capture your current branch and return to it
  • Sensible defaults (xx main, rr main)

Install

# Clone
git clone https://github.com/socket-link/git-chord.git ~/.git-chord

# Add to ~/.zshrc
echo 'source ~/.git-chord/git-chord.zsh' >> ~/.zshrc
source ~/.zshrc

Or just copy git-chord.zsh anywhere and source it.

Quick Reference

Key Command Key Command
a git add . s git stash
c git commit -m "<msg>" p git push
P git push --force f git fetch
F git pull l git log --oneline
u git reset HEAD^ --soft L git log
x git checkout [main] n git checkout -b <branch>
d git branch -D <branch> b git branch
m git merge <branch> r git rebase [main]
e git commit --amend E git commit --amend --no-edit
S git stash pop

Multi-char Commands

Chord Command
pf git push --force
pu git push -u origin HEAD
ra git rebase --abort
rc git rebase --continue
rs git rebase --skip
sa git stash apply
sl git stash list
sp git stash pop
sd git stash drop

Macros

Macros capture your current branch at chord start and can return to it.

Macro Expands To Use Case
R xFx {branch}r Sync-rebase from main
M xFx {branch}m main Sync-merge from main
W px Push & return to main

Example: On branch feature-123:

g ac"WIP"R

Expands to:

→ git add .
→ git commit -m "WIP"
⚡ Macro R → expanding for branch 'feature-123'
→ git checkout main
→ git pull
→ git checkout feature-123
→ git rebase main

Argument Binding

Commands that need arguments get them in two ways:

Positional (left-to-right)

g xacp feature "Add feature"
#      │       │
#      │       └─ "Add feature" → c (commit)
#      └──── "feature" → x (checkout)

Inline Quoted

g x"feature"ac"Add feature"p
#  │        │ │            │
#  │        │ │            └─ p (push, no arg)
#  │        │ └─ "Add feature" → c (commit)
#  │        └─ a (add, no arg)
#  └─ "feature" → x (checkout)

Quoted args bind explicitly to the command immediately before them. This is useful when the argument order would otherwise be ambiguous.

Workflows

# Morning sync
g xF                             # checkout main, pull

# Quick commit
g acp "Fix typo"                 # add, commit, push

# Start feature
g n"feature-123"                 # new branch
g acp "Implement feature"        # work...
g R                              # sync-rebase from main
g P                              # force push (after rebase)

# Stash & switch
g s                              # stash
g xF                             # main, pull
g x"feature"S                    # back, unstash

# Oops, bad commit
g u                              # uncommit
g ac "Better message"            # recommit

# Squash into previous
g aE                             # add + amend no-edit

# Done with branch
g W                              # push, back to main

Mnemonics

Key Mnemonic
x "check" (as in checkout)
n "new" branch
u "uncommit"
s "stash"
S "stash pop"
e "edit" commit
E "Edit silently"
R "sync Rebase"
M "sync Merge"
W "Wrap up"

Convenience Mappings

For improved muscle-memory usage, aliases for common commands are included at the bottom.

These alias allow you to omit space after typing g, speeding up the chord typing (ga, gc, gx, etc.).

Extending

Edit the associative arrays in git-chord.zsh:

# Add a single-char command
GIT_CHORD_CMDS[w]="1:git worktree add {}"

# Add a multi-char command
GIT_CHORD_MULTI[df]="git diff --name-only"

# Add a macro
GIT_CHORD_MACROS[Q]="s:x:F:x {branch}:S"  # stash, sync, unstash

Help

ghelp

License

Copyright 2026 Miley Chandonnet, Stedfast Softworks LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.