Skip to content

Instantly share code, notes, and snippets.

@joshbooks
Created May 28, 2019 19:00
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 joshbooks/68c24fa1bd7f3b264fd20b9684fe785a to your computer and use it in GitHub Desktop.
Save joshbooks/68c24fa1bd7f3b264fd20b9684fe785a to your computer and use it in GitHub Desktop.
view your pull requests for the git repo in the current directory assuming you have GITHUB_USERNAME set
#!/bin/bash
read -ra gitUrls <<< `git remote -v | awk '{print $2}' | sort -u`
if [[ ${#gitUrls[@]} -eq 1 ]]
then
selection=0
else
selections=0
for gitUrl in ${gitUrls[@]}
do
echo "[$selections] $gitUrl"
done
echo "which git url would you like to use?"
read selection
fi
selectedUrl=${gitUrls[$selection]}
echo "$selectedUrl"
if [[ ! -z `echo $selectedUrl | grep '.*@.*:.*\.git'` ]]
then
repoUrl=`echo $selectedUrl | sed -e 's|.*\@\(.*\):\(.*\).git|\1/\2|'`
else
repoUrl=`echo $selectedUrl | sed 's/.git$//'`
fi
echo "https://$selectedUrl/pulls/$GITHUB_USERNAME"
open "https://$repoUrl/pulls/$GITHUB_USERNAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment