Last active
April 30, 2024 14:51
-
-
Save gokselgoktas/6c5c518ec6e25de821dc8cae36211496 to your computer and use it in GitHub Desktop.
A custom PowerShell profile
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
$env:LC_ALL = 'C.UTF-8' | |
Set-Location D: | |
function Import-VisualStudio () { | |
$installationPath = & "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe" ` | |
-property installationPath | |
Import-Module (Join-Path $installationPath "Common7\\Tools\\Microsoft.VisualStudio.DevShell.dll") | |
Enter-VsDevShell -VSInstallPath $installationPath -SkipAutomaticLocation ` | |
-DevCmdArguments '-arch=x64 -host_arch=x64 -no_logo' | |
} | |
function Write-BranchName () { | |
Write-Host " [" -NoNewline -ForegroundColor Gray | |
try { | |
$branch = git rev-parse --abbrev-ref HEAD | |
if ($branch -eq "HEAD") { | |
$branch = git rev-parse --short HEAD | |
Write-Host $branch -NoNewline -ForegroundColor Red | |
} | |
else { | |
Write-Host $branch -NoNewline -ForegroundColor Green | |
} | |
} | |
catch { | |
Write-Host '?' -NoNewline -ForegroundColor Yellow | |
} | |
Write-Host ']' -NoNewline -ForegroundColor Gray | |
} | |
function prompt { | |
$username = [Environment]::UserName.ToLower() | |
$computerName = $Env:ComputerName.ToLower() | |
$location = (Split-Path (Get-Location) -NoQualifier).ToLower() | |
Write-Host $username -NoNewline -ForegroundColor Green | |
Write-Host '@' -NoNewline -ForegroundColor White | |
Write-Host $computerName -NoNewline -ForegroundColor Gray | |
Write-Host ':' -NoNewline -ForegroundColor White | |
Write-Host $location -NoNewline -ForegroundColor Magenta | |
If ($? -eq $True) { | |
Write-Host ' $' -NoNewline -ForegroundColor DarkRed | |
} | |
Else { | |
Write-Host ' $' -NoNewline -ForegroundColor Red | |
} | |
If (Test-Path .git) { | |
Write-BranchName | |
} | |
" " | |
} | |
Import-VisualStudio |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment