From 8e4d61fb77ed68f896b6fe3dc0bbbcd078668ede Mon Sep 17 00:00:00 2001 From: Ben Burwell Date: Tue, 13 Aug 2019 23:33:32 -0400 Subject: zsh: adopt --- templates/.zsh/functions/dirty.zsh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 templates/.zsh/functions/dirty.zsh (limited to 'templates/.zsh/functions/dirty.zsh') diff --git a/templates/.zsh/functions/dirty.zsh b/templates/.zsh/functions/dirty.zsh new file mode 100644 index 0000000..19a550d --- /dev/null +++ b/templates/.zsh/functions/dirty.zsh @@ -0,0 +1,24 @@ +function dirty() { + base=~/code/src/github.com/virtyx-technologies + yellow='\033[0;33m' + green='\033[0;32m' + nc='\033[0m' + for repo in $(ls "$base"); do + p="$base/$repo" + is_dirty=$(git --git-dir="$p/.git" --work-tree="$p" diff --shortstat 2> /dev/null | tail -n1) + branch=$(git --git-dir="$p/.git" --work-tree="$p" rev-parse --abbrev-ref HEAD 2> /dev/null) + if [[ $branch != "master" && $branch != "HEAD" ]]; then + pr=$(curl --silent "https://benburwell:$GITHUB_TOKEN@api.github.com/repos/virtyx-technologies/$repo/pulls?state=open&head=virtyx-technologies:$branch" | jq --raw-output --monochrome-output '.[0]._links.html.href') + pr_link=$([[ $pr != "null" ]] && echo "($pr)") + if [[ $is_dirty != "" ]]; then + echo "$repo: ${yellow}$branch${nc} $pr_link" + else + echo "$repo: ${green}$branch${nc} $pr_link" + fi + else + if [[ $is_dirty ]]; then + echo "$repo: ${yellow}$branch${nc} $pr_link" + fi + fi + done +} -- cgit v1.2.3