Skip to content

Instantly share code, notes, and snippets.

@uu59
Created March 29, 2016 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uu59/415b6e83a9a809e2e7be to your computer and use it in GitHub Desktop.
Save uu59/415b6e83a9a809e2e7be to your computer and use it in GitHub Desktop.
#!/bin/bash
set -ue
ask() {
local default=${2:-""}
printf "%s" "${1}: (${default}) " >&2
read in
echo ${in:-$default}
}
die() {
echo $1 >&2
exit 1
}
ghq-transform() {
local root="$(ghq root)"
local domain="github.com"
local org="$(ask "org" "treasure-data")"
[[ -z $org ]] && die "org is required"
local repo="$(ask "repo" "$(basename $PWD)")"
[[ -z $repo ]] && die "repo is required"
local fullpath="${root}/${domain}/${org}/${repo}"
read -p "${fullpath} ? (Y/n)" yn
[[ $yn == "n" ]] && die "canceled."
old="$PWD"
cd /
mv "$old" "$fullpath"
cd $fullpath
}
ghq-transform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment