Skip to content

Instantly share code, notes, and snippets.

View courtney-miles's full-sized avatar

Courtney Miles courtney-miles

  • Brisbane, Australia
View GitHub Profile
<?php echo "Hello world!";
@courtney-miles
courtney-miles / .bashrc
Created March 16, 2016 09:22
Resume use of ssh-agent
env=~/.ssh/agent.env
agent_load_env () {
. "$env" >| /dev/null ; }
agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ; }
agent_load_env
@courtney-miles
courtney-miles / start-ssh-agent.sh
Created March 16, 2016 09:24
Start ssh-agent and add ssh key
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
@courtney-miles
courtney-miles / gfstatus.sh
Last active May 17, 2018 11:14
Git Status for Forks
#!/usr/bin/env bash
set -o errexit
set -o nounset
repl() { printf "$1"'%.s' $(eval "echo {1.."$(($2))"}"); }
get_ahead() {
git rev-list --count $1..$2
}
@courtney-miles
courtney-miles / git-branch-status.sh
Created May 17, 2018 23:46
Prints the ahead and behind status for each tracked branch.
#!/bin/bash
# Adapted from https://stackoverflow.com/a/7774433/2045006
git for-each-ref --format="%(refname:short) %(upstream:short)" refs/heads | \
while read local remote
do
[ -z "$remote" ] && continue
git rev-list --left-right ${local}...${remote} -- 2>/dev/null >/tmp/git_upstream_status_delta || continue
LEFT_AHEAD=$(grep -c '^<' /tmp/git_upstream_status_delta)
RIGHT_AHEAD=$(grep -c '^>' /tmp/git_upstream_status_delta)