citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

commit ce1d6a5ff36c2398a9282df2cfd16d5b7d19ef69
parent 53620fe137bdb08aa447741671615ca04c356591
Author: William Casarin <jb55@jb55.com>
Date:   Sat,  7 Nov 2020 21:21:17 -0800

bin: add srht-clone

Diffstat:
Abin/srht-clone | 38++++++++++++++++++++++++++++++++++++++
Mdotfiles/.bash_aliases | 4++--
2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/bin/srht-clone b/bin/srht-clone @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -e + +usage () { + printf "usage: srht-clone <owner>[/]<repo>\n" >&2 + exit 1 +} + +already_exists () { + printf "%s\n" "$2" + exit 2 +} + +root=${SRHT_ROOT:-"$HOME/dev/srht"} +owner="$1" + +shift + +[ -z "$owner" ] && usage + +IFS='/' read -ra parsed <<< "$owner" +owner="${parsed[0]}" +repo="${parsed[1]}" +if [ -z "$owner" ] || [ -z "$repo" ]; then + usage +fi + +dest="$root/$owner" +dir="$dest/$repo" + +[ -d "$dir" ] && already_exists "$owner/$repo" "$dir" + +mkdir -p "$dest" +cd "$dest" +git clone "$@" "srht:$owner/$repo" + +printf "%s\n" "$dest/$repo" diff --git a/dotfiles/.bash_aliases b/dotfiles/.bash_aliases @@ -80,8 +80,8 @@ ghclone () { cd "$(gh-clone "$@")" } -glclone () { - cd "$(gl-clone "$@")" +srhtclone () { + cd "$(srht-clone "$@")" } cdnp () {