Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. param (
  2. [Parameter(Mandatory=$false)]
  3. [string]$username,
  4. [Parameter(Mandatory=$false)]
  5. [string]$email,
  6. [Parameter(Mandatory=$false)]
  7. [string]$profile
  8. )
  9. [string]$GIT_CONFIG_FILE_PATH = '.gitconfig';
  10. [string]$GIT_CONFIG_FILE_TEMPLATE =
  11. '[user]
  12. name = {0}
  13. email = {1}
  14. [credential]
  15. helper = manager
  16. [diff]
  17. tool = vimdiff
  18. [difftool]
  19. prompt = false
  20. [alias]
  21. d = difftool';
  22.  
  23. [string[]]$profiles = 'work', 'home';
  24.  
  25. [string]$output = '';
  26.  
  27. if(![string]::IsNullOrEmpty($profile))
  28. {
  29. switch ($profile)
  30. {
  31. 'work' { $output = $GIT_CONFIG_FILE_TEMPLATE -f 'Petromil Pavlov', 'petromil.pavlov@softwaregroup.com' }
  32. 'home' { $output = $GIT_CONFIG_FILE_TEMPLATE -f 'Dominent', 'petromilpavlov@gmail.com' }
  33. default { Write-Error "Unknown Profile!: $profile"}
  34. }
  35. }
  36.  
  37. [System.Text.UTF8Encoding]$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
  38.  
  39. [string]$outputFilePath = [System.IO.Path]::Combine($env:HOMEPATH, $GIT_CONFIG_FILE_PATH);
  40.  
  41. [System.IO.File]::WriteAllText($outputFilePath, $output, $Utf8NoBomEncoding)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement