Last active
November 19, 2015 07:17
-
-
Save tcg/381dba155117a2e7a545 to your computer and use it in GitHub Desktop.
Some current aliases and functions from my .profile/.bashrc/.zshrc, etc
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
# List Git branches in order of most-recently-updated. | |
# https://gist.github.com/tcg/381dba155117a2e7a545 | |
alias gitbranchesbydate="git for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:iso8601) %09 %(refname) %09 %(authorname)' | sed -e 's-refs/heads/--'" | |
# Output looks like: | |
# 2014-06-06 12:58:53 -0500 tcg/donate_language_updates Tommy George | |
# 2014-06-06 10:28:04 -0500 integration Brad | |
# 2014-06-05 16:13:30 -0500 super_dev_branch Chris | |
# List files that SHOULD now be ignored by .gitignore, but might not yet be. | |
# Use this if you just added your .gitignore file and want to make sure that | |
# you don't have any stray files around. | |
# http://stackoverflow.com/questions/7527982/applying-gitignore-to-committed-files | |
# http://stackoverflow.com/questions/466764/show-ignored-files-in-git | |
alias gitignoremissing="git ls-files -ci --exclude-standard" | |
# cURL a URL, but just get the headers. Because the args are a little | |
# hard to have memorized. You could just do a HEAD request, but maybe you | |
# want to peek at the headers for a POST, etc? | |
# USAGE: `curlheaders {url}` | |
# Prints just the headers. | |
alias curlheaders="curl -s -o /dev/null -D - " | |
# Alternatively, this just does a verbose curl (to get both request and | |
# response headers), but dumps the response body. | |
# USAGE: `curlv {url}` | |
alias curlv="curl -v -s -o /dev/null " | |
# Pushes current branch to origin, and opens a pull request window in github | |
# for the current branch. | |
function pr () { | |
local repo=`git remote -v | grep -m 1 "(push)" | sed -e "s/.*github.com[:/]\(.*\)\.git.*/\1/"` | |
local branch=`git name-rev --name-only HEAD` | |
# Make sure the branch is up to date | |
if [[ "$branch" == "master" ]]; then | |
echo "On branch master, please checkout a new branch before submitting a pull request." | |
return 1 | |
fi | |
if [[ "$branch" == "integration" ]]; then | |
echo "On branch integration, please checkout a new branch before submitting a pull request." | |
return 1 | |
fi | |
git push origin $branch | |
echo "... creating pull request for branch \"$branch\" in \"$repo\"" | |
open https://github.com/$repo/pull/new/$branch | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment