Advertisement
awakun

PSprofile

Sep 16th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. # _ _ _ _ _ _ ______ __
  2. # | | | | (_) | | | | | | | ___ \ / _|
  3. # | | | | __ _ _ __ _ __ _| |__ | | ___ ___ __ _ _ __ __| | | |_/ / __ ___| |_ ___ _ __ ___ _ __ ___ ___ ___
  4. # | | | |/ _` | '__| |/ _` | '_ \| |/ _ \/ __| / _` | '_ \ / _` | | __/ '__/ _ \ _/ _ \ '__/ _ \ '_ \ / __/ _ \/ __|
  5. # \ \_/ / (_| | | | | (_| | |_) | | __/\__ \ | (_| | | | | (_| | | | | | | __/ || __/ | | __/ | | | (_| __/\__ \
  6. # \___/ \__,_|_| |_|\__,_|_.__/|_|\___||___/ \__,_|_| |_|\__,_| \_| |_| \___|_| \___|_| \___|_| |_|\___\___||___/
  7.  
  8. $ProgressPreference = 'SilentlyContinue'
  9.  
  10. #Shortcuts to common folders
  11. $docs = "$([System.Environment]::GetFolderPath('mydocuments'))"
  12. $downloads = "$HOME\Downloads"
  13. $workspace = "$([System.Environment]::GetFolderPath('mydocuments'))\workspace"
  14.  
  15. <#
  16. _____ _ _ _
  17. / ____| | | /\ | (_)
  18. | (___ ___| |_ / \ | |_ __ _ ___ ___ ___
  19. \___ \ / _ \ __| / /\ \ | | |/ _` / __|/ _ \/ __|
  20. ____) | __/ |_ / ____ \| | | (_| \__ \ __/\__ \
  21. |_____/ \___|\__| /_/ \_\_|_|\__,_|___/\___||___/
  22. #>
  23. #This is for the chrome alias since chrome can be in 3 different default locations, so check if it's needed first.
  24. if (-not (Get-Alias -Name 'chrome' -ErrorAction SilentlyContinue))
  25. {
  26. #Find chrome, prioritize canary > 64bit > 32bit
  27. $potentialChromePaths = @($env:LOCALAPPDATA, $env:ProgramFiles, ${env:ProgramFiles(x86)})
  28. foreach ($path in $potentialChromePaths)
  29. {
  30. $chromePath = (Get-ChildItem -Path $path -Filter 'chrome.exe' -Recurse -ErrorAction SilentlyContinue).FullName
  31. if ($chromePath)
  32. {
  33. New-Alias -name 'chrome' -Value $chromePath
  34. break
  35. }
  36. }
  37. }
  38.  
  39. # Check for alias
  40. if (-not (Get-Alias -Name 'note' -ErrorAction SilentlyContinue))
  41. {
  42. # Check for np++
  43. if ([IO.File]::Exists("$env:ProgramFiles\Notepad++\notepad++.exe"))
  44. {
  45. New-Alias -Name 'note' -Value "$env:ProgramFiles\Notepad++\notepad++.exe"
  46. }
  47. }
  48.  
  49. if (-not (Get-Alias -Name 'code' -ErrorAction SilentlyContinue))
  50. {
  51. $codePath = (Get-ChildItem -Path "$env:LOCALAPPDATA\Programs\Microsoft VS Code Insiders" -Filter "code*.exe")
  52. if ([IO.File]::Exists($codePath.Fullname))
  53. {
  54. New-Alias -Name 'code' -Value $codePath.FullName
  55. }
  56. }
  57.  
  58. if ($IsCoreCLR)
  59. {
  60. if (-not (Get-Alias -Name 'scb' -ErrorAction SilentlyContinue)) { New-Alias -Name 'scb' -Value Set-ClipboardText }
  61. }
  62.  
  63. function Update-Path {
  64. $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
  65. }
  66.  
  67. #Get rid of backspace beep maybe Not needed now? leaving for now just commenting out
  68. Set-PSReadlineOption -BellStyle None
  69.  
  70. function Get-ZombrigCred
  71. {
  72. if ($IsCoreCLR)
  73. {
  74. Import-Module AWSPowerShell.NetCore
  75. }
  76. else
  77. {
  78. Import-Module AWSPowerShell
  79. }
  80.  
  81. Set-AWSCredential -ProfileName personal
  82. $region = 'us-west-2'
  83.  
  84. $user = (Get-SSMParameter -Name riglogin -Region $region).Value
  85. $pass = (Get-SSMParameter -Name brains -WithDecryption:$true -Region $region).Value | ConvertTo-SecureString -AsPlainText -Force
  86.  
  87. New-Object -TypeName pscredential -ArgumentList ($user,$pass)
  88. }
  89.  
  90. # Start a transcript
  91. #
  92. if (!(Test-Path "$Env:USERPROFILE\Documents\WindowsPowerShell\Transcripts"))
  93. {
  94. if (!(Test-Path "$Env:USERPROFILE\Documents\WindowsPowerShell"))
  95. {
  96. $rc = New-Item -Path "$Env:USERPROFILE\Documents\WindowsPowerShell" -ItemType directory
  97. }
  98. $rc = New-Item -Path "$Env:USERPROFILE\Documents\WindowsPowerShell\Transcripts" -ItemType directory
  99. }
  100. $curdate = $(get-date -Format "yyyyMMddhhmmss")
  101. Start-Transcript -Path "$Env:USERPROFILE\Documents\WindowsPowerShell\Transcripts\PowerShell_transcript.$curdate.txt"
  102.  
  103. #Prompt customization
  104. function prompt
  105. {
  106. if ($host.UI.RawUI.WindowTitle -match 'Administrator')
  107. {
  108. Write-Host 'AS ADMIN: ' -NoNewLine -ForegroundColor Red
  109. $host.ui.rawui.WindowTitle = $CurrentUser.Name + ".Administrator Line: " + $host.UI.RawUI.CursorPosition.Y
  110. }
  111. else
  112. {
  113. $host.ui.rawui.WindowTitle = $CurrentUser.Name + " Line: " + $host.UI.RawUI.CursorPosition.Y
  114. }
  115.  
  116. Write-Host "PS $($PSVersionTable.PSVersion) " -NoNewline -ForegroundColor DarkBlue
  117. Write-Host "$env:UserName@ " -ForegroundColor DarkMagenta -NoNewline
  118. Write-Host ('{0}: ' -f $env:COMPUTERNAME) -NoNewLine -ForegroundColor Green
  119. Write-Host ('{0}>' -f $(Get-Item -Path .\).Name) -NoNewLine -ForeGroundColor DarkCyan
  120. return " "
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement