Last active
December 30, 2015 07:18
-
-
Save arriolac/7794655 to your computer and use it in GitHub Desktop.
Useful Bash Aliases and Functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### aliases for vim ### | |
# Given two files, performs a diff | |
alias mvimdiff='mvim -d' | |
# Given two files, does a vertical split | |
alias mvimvsplit='mvim -O' | |
### git ### | |
# Deletes all branches that are already merged into the current branch | |
alias gitrmbr='git branch --merged | grep -v "\*" | xargs -n 1 git branch -d' | |
# Creates a pull request on GitHub for the currently checked out branch | |
function pr () { | |
if ["$1" == ""] | |
then | |
echo "Please provide the name of the branch to create a pull request against." | |
else | |
local repo=`git remote -v | grep -m 1 "(push)" | sed -e "s/.*github.com[:/]\(.*\)\.git.*/\1/"` | |
local branch=`git name-rev --name-only HEAD` | |
echo "... creating pull request for branch \"$branch\" in \"$repo\"" | |
open https://github.com/$repo/compare/$1...$branch | |
fi | |
} | |
# Fetches a pull request from GitHub given the pull request number | |
function fpr () { | |
echo git fetch origin pull/$1/head:pr$1 | |
git fetch origin pull/$1/head:pr$1 | |
echo git checkout pr$1 | |
git checkout pr$1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment