Last active
February 17, 2025 17:02
-
-
Save gimmi/6079390 to your computer and use it in GitHub Desktop.
Settings for CMD and PowerShell
This file contains hidden or 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
@ECHO OFF | |
REM HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun => "%USERPROFILE%\cmdrc.cmd" | |
doskey subl="%ProgramFiles%\Sublime Text 3\subl.exe" $* | |
doskey ls=dir /O:GN /D $* | |
doskey x="%windir%\explorer.exe" . | |
doskey cdh=CD "%USERPROFILE%" | |
doskey cdt=CD "%USERPROFILE%\Temp" | |
doskey gitex="%ProgramFiles(x86)%\GitExtensions\gitex.cmd" | |
doskey mvn="%USERPROFILE%\Tools\apache-maven\bin\mvn" $* | |
doskey ant="%USERPROFILE%\Tools\apache-ant\bin\ant" $* | |
doskey sqlcmd="%ProgramFiles%\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\sqlcmd.exe" $* | |
doskey ssh="%ProgramFiles%\Git\usr\bin\ssh" $* | |
doskey gpg="%ProgramFiles%\Git\usr\bin\gpg" $* | |
doskey msbuild="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" $* |
This file contains hidden or 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
# Edit profile with the following command | |
# notepad $PROFILE | |
function prompt { | |
Write-Host -ForegroundColor DarkGray $executionContext.SessionState.Path.CurrentLocation | |
[char]::ConvertFromUtf32(0x276f) + ' ' | |
} | |
Invoke-Command -ScriptBlock { | |
Write-Host " User: " -ForegroundColor DarkGray -NoNewline | |
$WindowsIdentity = [Security.Principal.WindowsIdentity]::GetCurrent() | |
Write-Host -Object $WindowsIdentity.Name | |
Write-Host "Admin: " -ForegroundColor DarkGray -NoNewline | |
# See https://blogs.technet.microsoft.com/undocumentedfeatures/2016/11/28/checking-for-an-elevated-powershell-prompt/ | |
$WindowsIdentity = [System.Security.Principal.Windowsidentity]::GetCurrent() | |
$WindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal($WindowsIdentity) | |
$AdministratorRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator | |
Write-Host -Object $WindowsPrincipal.IsInRole($AdministratorRole) | |
} | |
Remove-Item Alias:\curl # This way, C:\Windows\system32\curl.exe will take precedence | |
Set-Alias -Name x -Value "$env:windir\explorer.exe" -Option Constant | |
Set-Alias -Name subl -Value "$env:Programfiles\Sublime Text\subl.exe" -Option Constant | |
Set-Alias -Name rider -Value "$env:Programfiles\JetBrains\JetBrains Rider 2022.2.2\bin\rider64.exe" -Option Constant | |
Set-Alias -Name gitex -Value "${env:ProgramFiles(x86)}\GitExtensions\gitex.cmd" -Option Constant | |
Set-PSReadLineOption -PredictionViewStyle ListView | |
Set-PSReadLineKeyHandler -Chord Ctrl+t -ScriptBlock { | |
$PreviewCmd = 'bat --color always --style changes --line-range :100 {}' | |
fzf --multi --walker file --style full --preview $PreviewCmd | Out-String -Stream | ForEach-Object { | |
$_ = if ($_ -match '\s') { "'$_' " } else { "$_ " } | |
[Microsoft.PowerShell.PSConsoleReadLine]::Insert($_) | |
} | |
} | |
Set-PSReadLineKeyHandler -Chord Alt+c -ScriptBlock { | |
fzf --walker dir --style full | ForEach-Object { | |
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() | |
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("Push-Location '$_'") | |
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine() | |
} | |
} | |
Set-PSReadLineKeyHandler -Chord Ctrl+r -ScriptBlock { | |
$Path = Get-PSReadLineOption | Select-Object -ExpandProperty HistorySavePath | |
$Content = Get-Content -Path $Path -Raw | |
$First = $true | |
$Content -replace "```n", "`n" -replace "`r`n", "`0" | fzf --style full --read0 | ForEach-Object { | |
if ($First) { [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() } | |
else { [Microsoft.PowerShell.PSConsoleReadLine]::AddLine() } | |
$First = $false | |
[Microsoft.PowerShell.PSConsoleReadLine]::Insert($_) | |
} | |
} |
This file contains hidden or 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
// To view the default settings, hold "alt" while clicking on the "Settings" button. | |
// For documentation on these settings, see: https://aka.ms/terminal-documentation | |
{ | |
"$schema": "https://aka.ms/terminal-profiles-schema", | |
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", | |
"initialCols": 160, | |
"initialRows": 50, | |
"multiLinePasteWarning": false, | |
"profiles": | |
{ | |
"defaults": { | |
// Put settings here that you want to apply to all profiles | |
"colorScheme": "Campbell", | |
"fontFace": "JetBrains Mono", | |
// Copy this: https://forum.level1techs.com/t/man-do-i-love-the-new-windows-terminal/146087 | |
// here: %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState | |
"backgroundImage" : "ms-appdata:///roaming/lowps.png", | |
"backgroundImageOpacity" : 0.5 | |
}, | |
"list": [{ | |
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", | |
"name": "Windows PowerShell", | |
"startingDirectory" : "." | |
},{ | |
// cmd | |
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", | |
"name": "cmd" | |
}, { | |
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}", | |
"name": "Azure Cloud Shell", | |
"hidden": false, | |
"source": "Windows.Terminal.Azure" | |
}, { | |
"guid": "{4334fd4c-3939-49c2-ae7f-3a1d0c361a20}", | |
"commandline" : "\"%PROGRAMFILES%\\git\\usr\\bin\\bash.exe\" -i -l", | |
"icon" : "%PROGRAMFILES%\\Git\\mingw64\\share\\git\\git-for-windows.ico", | |
"name" : "Git Bash", | |
"startingDirectory" : "%USERPROFILE%" | |
}] | |
}, | |
// Add custom color schemes to this array | |
"schemes": [], | |
// Add any keybinding overrides to this array. | |
// To unbind a default keybinding, set the command to "unbound" | |
"keybindings": [] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment