Skip to content

Instantly share code, notes, and snippets.

@star-szr
Last active December 23, 2015 09:09
Show Gist options
  • Save star-szr/6612251 to your computer and use it in GitHub Desktop.
Save star-szr/6612251 to your computer and use it in GitHub Desktop.
Bash aliases for testing and applying patches based on the URL on your clipboard. If you're on OS X, grab the first three lines and add to your ~/.bash_profile. If you're on Linux, grab lines 5-8 and add to your ~/.bash_profile or ~/.bashrc or whatnot :)Testbot uses git to apply patches, I only include the `patch` version here because sometimes …
# These ones are for OS X.
alias cav='curl `pbpaste` | git apply -v --check'
alias capv='curl `pbpaste` | patch -p1 --dry-run'
# These are untested but should work on many flavours of Linux. If they don't,
# please leave a comment!
alias cav='curl `xsel --clipboard --output` | git apply -v --check'
alias capv='curl `xsel --clipboard --output` | patch -p1 --dry-run'
# Patch shortcuts (some duplication of the above, but covers more use cases).
#
# Replace `pbpaste` with `xsel --clipboard --output` for Linux!
#
# Copy a patch URL to the clipboard, then run one of these commands to download
# the patch and apply it. Hat tip to @chrisjlee for making me reconsider curl.
#
# Apply
alias cap='curl `pbpaste` | git apply -v'
# Apply and stage
alias cape='curl `pbpaste` | git apply -v --index'
# Apply with `patch`
alias capp='curl `pbpaste` | patch -p1'
# Reverse apply
alias carp='curl `pbpaste` | git apply -Rv'
# Reverse apply and stage
alias carpe='curl `pbpaste` | git apply -Rv --index'
# Verify patch
alias cav='curl `pbpaste` | git apply -v --check'
# Verify patch with `patch`
alias capv='curl `pbpaste` | patch -p1 --dry-run'
@heddn
Copy link

heddn commented Sep 18, 2013

The Linux commands work on Ubuntu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment