Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save xqin/1e9a9c477b6e1305375cdd90cc143d79 to your computer and use it in GitHub Desktop.
Save xqin/1e9a9c477b6e1305375cdd90cc143d79 to your computer and use it in GitHub Desktop.
checkout git branch with ⌘+Click in ITerm2
  1. Go to Preferences->Advanced
  2. Under Smart Selection, click the Edit button
  3. Click the + to add a new rule
  4. For the Regular expression, use ^\s*(?:remotes/origin/)?([a-z0-9A-Z][a-zA-Z0-9\/\.\-\_]*)$
  5. For priority, choose Very Low
  6. Click Edit Actions
  7. Click the + to add a new action
  8. Title Switch Git Branch
  9. Action Run Coprocess...
  10. Parameter ~/sw.sh \1
  11. Create sw.sh file in $HOME folder with follow content:
#!/bin/bash

echo "git checkout '$1' --"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment