Skip to content

Instantly share code, notes, and snippets.

@miry
Last active October 13, 2015 11:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miry/4188341 to your computer and use it in GitHub Desktop.
Save miry/4188341 to your computer and use it in GitHub Desktop.
Custom Zsh plugins
# Git
alias g="git"
# If your branch named like [issue_number]_some_description
gh_issue() {
ghissue=`echo $(current_branch) | sed -e 's/\([0-9]*\).*/\1/'`
if [ $ghissue ]; then
echo "$ghissue"
fi
}
# Get the orgonization from orginal url and build the hub params to send the PR
pull_request() {
local organization
if [ $1 ]; then
organization=$1
else
organization=$( git config --get remote.origin.url | sed "s/^[^:]*:\([^\/]*\)\/.*/\1/" )
fi
if [ $(gh_issue) ]; then
issue="-i $(gh_issue)"
else
issue=""
fi
branch=$(current_branch)
issue=$(echo $issue)
current_remote_with_branch=`git rev-parse --abbrev-ref --symbolic-full-name @{u}`
cmd="hub pull-request ${issue} -b ${organization}:master -h ${current_remote_with_branch}"
echo "$fg_bold[green]${cmd}$reset_color"
eval $cmd
}
#Pull request
alias gpr="pull_request"
alias pp_json='ruby -e "require \"json\"; require \"yaml\"; puts JSON.parse(STDIN.read).to_yaml"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment