-
-
Save manveru/1329004 to your computer and use it in GitHub Desktop.
Create basic .gitconfig file
This file contains 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
#!/usr/bin/ruby | |
def ask(question, retries = 3) | |
fail "Failed to get user input" if retries <= 0 | |
print question | |
if got = gets | |
got.strip | |
else | |
puts "Invalid input" | |
ask(question, retries - 1) | |
end | |
end | |
$stdout.sync = true | |
system('git', 'config', '--global', '--replace-all', 'ui.color', 'true') | |
user_name = `git config --global --get user.name`.strip | |
user_name = ask('Enter your name: ') if user_name.empty? | |
system('git', 'config', '--global', '--replace-all', 'user.name', user_name) | |
user_email = `git config --global --get user.email`.strip | |
user_email = ask('Enter your email: ') if user_email.empty? | |
system('git', 'config', '--global', '--replace-all', 'user.email', user_email) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment