Skip to content

Instantly share code, notes, and snippets.

@arriolac
Last active December 30, 2015 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arriolac/7794655 to your computer and use it in GitHub Desktop.
Save arriolac/7794655 to your computer and use it in GitHub Desktop.
Useful Bash Aliases and Functions
### 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