Skip to content

Instantly share code, notes, and snippets.

View bonelifer's full-sized avatar

William Jacoby bonelifer

View GitHub Profile
@bonelifer
bonelifer / github_repo_create.sh
Created September 3, 2020 19:46 — forked from igk1972/github_repo_create.sh
Github repo create
#!/bin/sh
# [ -z "$1" ] || ACCESS_TOKEN="$1"
[ -z "$1" ] || ACCESS_AUTH="$1"
[ -z "$2" ] || REPO_NAME="$2"
# [ -z "$ACCESS_TOKEN" ] && { echo "Token not set" ; exit 1; }
[ -z "$ACCESS_AUTH" ] && { echo "Username[:Password] not set" ; exit 1; }
[ -z "$REPO_NAME" ] && { echo "Repo not set" ; exit 1; }
@bonelifer
bonelifer / backup_github.sh
Last active September 3, 2020 19:48 — forked from dskarataev/backup_github.sh
Backup GitHub repositories
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files
GHBU_ORG=${GHBU_ORG-"tterp"} # the GitHub organization whose repos will be backed up
GHBU_UNAME=${GHBU_UNAME-"dskarataev"} # the username of a GitHub account (to use with the GitHub API)
GHBU_PASSWD=${GHBU_PASSWD-"xc4cv0q0"} # the password for that account
GHBU_GITHOST=${GHBU_GITHOST-"github.com"} # the GitHub hostname (see comments)
GHBU_PRUNE_OLD=${GHBU_PRUNE_OLD-true} # when `true`, old backups will be deleted
GHBU_PRUNE_AFTER_N_DAYS=${GHBU_PRUNE_AFTER_N_DAYS-3} # the min age (in days) of backup files to delete
@bonelifer
bonelifer / dump.sh
Created September 3, 2020 19:49 — forked from bashkirtsevich/dump.sh
Dump github user
username=$1
repos=$(curl -s https://api.github.com/users/$username/repos?per_page=1000 | jq -r '.[] | .name + "|" + .clone_url')
for repo in $(echo $repos | tr " " "\n")
do
name=$(echo $repo | cut -d"|" -f1)
clone_url=$(echo $repo | cut -d"|" -f2)
git clone --mirror $clone_url ./$username/$name.git && tar -czvf ./$username/$name.tgz -C ./$username/$name.git .
rm -rf ./$username/$name.git
@bonelifer
bonelifer / gist-all-clone
Created September 3, 2020 20:09 — forked from vbyndych/gist-all-clone
gists-clone-push
#!/bin/sh
GITHUB_TOKEN=${1}
LIST_URL=https://${GITHUB_TOKEN}:@api.github.com/users/vbyndych/gists
SINGLE_URL=https://${GITHUB_TOKEN}:@api.github.com/gists
curl -qs $LIST_URL | grep '"id": "' | sed 's/"id": "\([a-z0-9]*\)",/\1/g'|
while read GIST_ID
do
DESCRIPTION=$(curl -qs "$SINGLE_URL/$GIST_ID" | grep '"description": "' | sed 's/"description": "\(.*\)",/\1/g' | tr -d '[:space:]')
@bonelifer
bonelifer / .bash_profile
Created September 3, 2020 20:10 — forked from ceruleanotter/.bash_profile
github bash profile enhancements
### GIT ENHANCEMENT START ###
# Git enhancement settings
unset GIT_PS1_SHOWSTASHSTATE
# Git enhancements
source ~/.git-completion.sh
source ~/.git-prompt.sh
# colors!
cyan=$(tput setaf 33)
@bonelifer
bonelifer / github-install.sh
Created September 3, 2020 20:12 — forked from dkorolev/github-install.sh
github-install-v2.sh
#!/bin/bash
#
# This script downloads the specified GitHub repository and installs it in current directory.
set -u -e
# Command-line parameters.
GITHUB_REPO=${1:-Bricks}
GITHUB_USER=${2:-KnowSheet}
GITHUB_BRANCH=${3:-master}
@bonelifer
bonelifer / backup_my_repos.sh
Created September 3, 2020 20:14 — forked from justinian/backup_my_repos.sh
GitHub & Bitbucket backup scripts
#!/bin/bash
BACKUP_DIR="/home/justin/backups/git"
cd "$BACKUP_DIR"
for repo_url in `list_my_repos.sh`; do
repo_dir=`echo $repo_url | sed 's/^....//' | tr ':/@' '___'`
git clone --mirror "$repo_url" "/tmp/$repo_dir" > /dev/null 2>&1
git --git-dir "/tmp/$repo_dir" bundle create "$repo_dir.bundle.new" --all > /dev/null 2>&1
if [ -f "$repo_dir.bundle" ]; then rm "$repo_dir.bundle"; fi
@bonelifer
bonelifer / label.sh
Created September 3, 2020 20:18 — forked from JamesKingdom/label.sh
GitHub label creator
USER=username
PASS=password
ACC=account
REPO=repo
# Delete default labels
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$ACC/$REPO/labels/bug"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$ACC/$REPO/labels/duplicate"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$ACC/$REPO/labels/enhancement"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$ACC/$REPO/labels/invalid"
#!/bin/bash
team="teamname"
org="orgname"
repos=$(hub api orgs/$org/repos --paginate | jq -rc '.[] | select(.archived == false and .disabled == false) | .name')
IFS=$'\n'
for repo in $repos
do
echo "Adding $repo"
@bonelifer
bonelifer / SetupLabels.sh
Created September 3, 2020 20:23
Setup GitHub Labels
#!/bin/sh
echo -n "GitHub User: "
read USER
echo -n "GitHub Password: "
read -s PASS
echo ""
echo -n "GitHub Repo (e.g. foo/bar): "
read REPO