Last active
November 17, 2021 15:50
-
-
Save drewbrokke/3885bde5f0122c98aab9707d5bcb86d8 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 | |
check_dependency fzf gsed pup || exit | |
DELIMITER=" : " | |
function getUsers() { | |
URL="${1}" | |
MARKUP="$(curl -s "https://github.com${URL}")" | |
NEXT_PAGE_LINK="$(echo "${MARKUP}" | pup 'a[class="next_page"] attr{href}')" | |
if [ "${NEXT_PAGE_LINK}" ]; then | |
getUsers "${NEXT_PAGE_LINK}" & | |
fi | |
USER_LINKS="$(echo "${MARKUP}" | pup 'a[id*="member-"]')" | |
if [ -z "${USER_LINKS}" ]; then | |
exit 1 | |
fi | |
for i in $(seq 1 "$(echo "${USER_LINKS}" | pup -n 'a')"); do | |
USER_LINK="$(echo "${USER_LINKS}" | pup "a:nth-of-type($i)")" | |
USER_NAME="$(echo "${USER_LINK}" | pup "a attr{id}" | gsed 's/member-//')" | |
FULL_NAME="$( | |
echo "${USER_LINK}" | | |
pup "a text{}" | | |
gsed -e '/^$/d' -e 's/\s*//' \ | |
-e 's/&/\&/g' \ | |
-e "s/'/\'/g" \ | |
; | |
)" | |
echo "${FULL_NAME}${DELIMITER}${USER_NAME}" | |
done | |
} | |
# Set up clipboard command per OS. Default to Linux xsel. | |
CLIPBOARD_CMD="xsel --input" | |
[ "${OSTYPE//[0-9.]/}" = "darwin" ] && CLIPBOARD_CMD="pbcopy" | |
getUsers "/orgs/liferay/people?query=${1}" | | |
fzf \ | |
--bind="enter:execute(printf {2} | ${CLIPBOARD_CMD})+accept" \ | |
--bind="ctrl-o:execute(open https://github.com/{2})" \ | |
--delimiter="${DELIMITER}" \ | |
--exit-0 \ | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment