Created
March 29, 2016 03:00
-
-
Save uu59/415b6e83a9a809e2e7be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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