Last active
June 20, 2019 08:22
-
-
Save chmouel/24709b9a08e322421227d223bdeb0876 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
titleonly= | |
if [[ $1 == "-t" ]];then | |
titleonly=t | |
fi | |
title=$(osascript -e 'tell application "Firefox" to return name of windows as text') | |
number=$(echo $title|gsed -r 's/.* Issue #([0-9]+) .*/\1/;') | |
[[ ${title} =~ .*Issue\ \#[0-9]{3,} ]] || { echo "I could not find a github Issue ###"; exit 1;} | |
if [[ ${titleonly} ]];then | |
echo -n "Fix #$number " | |
echo $title|gsed -r 's/(.*)...Issue #[0-9]+ .*/\1/;' | |
exit | |
fi | |
prefix=$(echo $title|gsed -r 's/(.*)...Issue #[0-9]+ .*/\L\1/;s/ /-/g') | |
prefix=$(echo $prefix|gawk -v len=25 '{ if (length($0) > len) print substr($0, 1, len-3); else print; }') | |
[[ $prefix == *- ]] && prefix=$(echo ${prefix}| sed 's/-$//') | |
if [[ -z ${title} || -z ${number} ]];then | |
echo "Can't get title or number" | |
exit | |
fi | |
echo issue-${number}-${prefix} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment