Created
May 9, 2015 00:12
-
-
Save geowarin/5c28d54cf4f16d4a58b8 to your computer and use it in GitHub Desktop.
Publish the current repository to github with fish shell and httpie
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
function gh-create-repo | |
if not is_installed http | |
echo "Please install httpie" | |
return 1 | |
end | |
set -l username (git config --global user.name) | |
echo -n "Enter password for $username : " | |
stty -echo | |
head -n 1 | read -l password | |
stty echo | |
echo | |
set -l repoName (basename (pwd)) | |
echo "This will create a repository named $repoName" | |
if read_confirm | |
if http --check-status -a "$username:$password" -h POST https://api.github.com/user/repos name=$repoName | |
if not is_git_repo | |
echo "Not a git repo, creating one" | |
echo "This will add everything to the stage" | |
if not read_confirm | |
exit 1 | |
end | |
git init | |
git add -A | |
git commit -am "Initial commit" | |
end | |
git remote add origin "https://github.com/$username/$repoName.git" | |
git push -u origin master | |
echo "Repository created: https://github.com/$username/$repoName" | |
end | |
end | |
end |
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
function is_git_repo | |
git rev-parse --git-dir ^ /dev/null > /dev/null | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment