Skip to content

Instantly share code, notes, and snippets.

@chmouel
Last active June 20, 2019 08:22
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 chmouel/24709b9a08e322421227d223bdeb0876 to your computer and use it in GitHub Desktop.
Save chmouel/24709b9a08e322421227d223bdeb0876 to your computer and use it in GitHub Desktop.
#!/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