diff options
Diffstat (limited to 'templates/.zsh/functions/dirty.zsh')
-rw-r--r-- | templates/.zsh/functions/dirty.zsh | 24 |
1 files changed, 24 insertions, 0 deletions
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 +} |