Skip to content

Instantly share code, notes, and snippets.

@manveru
Forked from eykanal/setup_gitconfig.rb
Created October 31, 2011 21:25
Show Gist options
  • Save manveru/1329004 to your computer and use it in GitHub Desktop.
Save manveru/1329004 to your computer and use it in GitHub Desktop.
Create basic .gitconfig file
#!/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