Last active
May 14, 2025 13:00
-
-
Save mklabs/6ac76c06d9eddcc4966ea16cbcf4cad1 to your computer and use it in GitHub Desktop.
windows dotfiles powershell profile
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
# Usually placed ~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 | |
# Prompt | |
## Starship | |
# https://starship.rs | |
# https://github.com/starship/starship | |
Invoke-Expression (&starship init powershell) | |
Invoke-Expression -Command $(starship completions powershell | Out-String) | |
# https://learn.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory | |
function Invoke-Starship-PreCommand { | |
$loc = $executionContext.SessionState.Path.CurrentLocation; | |
$prompt = "$([char]27)]9;12$([char]7)" | |
if ($loc.Provider.Name -eq "FileSystem") | |
{ | |
$prompt += "$([char]27)]9;9;`"$($loc.ProviderPath)`"$([char]27)\" | |
} | |
$host.ui.Write($prompt) | |
} | |
# Icons | |
# https://github.com/devblackops/Terminal-Icons | |
Import-Module Terminal-Icons | |
# PSReadLine | |
# https://github.com/PowerShell/PSReadLine | |
Set-PSReadLineOption -PredictionSource History | |
Set-PSReadLineOption -PredictionViewStyle ListView | |
# Fzf | |
# https://github.com/junegunn/fzf | |
# https://github.com/kelleyma49/PSFzf | |
Import-Module PSFzf | |
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+f' -PSReadlineChordReverseHistory 'Ctrl+r' | |
# Alias | |
Set-Alias vim nvim | |
Set-Alias g git | |
Set-Alias grep findstr | |
Set-Alias tig 'C:\Program Files\Git\usr\bin\tig.exe' | |
Set-Alias less 'C:\Program Files\Git\usr\bin\less.exe' | |
# Yazi | |
# https://github.com/sxyazi/yazi | |
function y { | |
$tmp = [System.IO.Path]::GetTempFileName() | |
yazi $args --cwd-file="$tmp" | |
$cwd = Get-Content -Path $tmp | |
if (-not [String]::IsNullOrEmpty($cwd) -and $cwd -ne $PWD.Path) { | |
Set-Location -LiteralPath $cwd | |
} | |
Remove-Item -Path $tmp | |
} | |
# eza | |
# https://github.com/eza-community/eza | |
function lls { | |
eza -a --color=always --git @args | |
} | |
function ll { | |
#eza -a --color=always --long --git --no-filesize --icons=always --no-time --no-user --no-permissions @args | |
eza -a --color=always --long --git --icons=always @args | |
} | |
function lll { | |
eza -a --color=always --long --git @args | |
} | |
function tree { | |
eza -a -T --level=2 @args | |
} | |
Set-Alias ls lls | |
# nvim | |
# Few utilities to start nvim with a different NVIM_APPNAME | |
function nvc { | |
$env:NVIM_APPNAME = 'nvim.custom'; | |
nvim @args | |
} | |
function nvk { | |
$env:NVIM_APPNAME = 'nvim.kickstart'; | |
nvim @args | |
} | |
function nvl { | |
$env:NVIM_APPNAME = 'nvim.lazy'; | |
nvim @args | |
} | |
function nva { | |
$env:NVIM_APPNAME = 'nvim.advent'; | |
nvim @args | |
} | |
# Utilities | |
function which($command) { | |
Get-Command -Name $command -ErrorAction SilentlyContinue | | |
Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue | |
} | |
# Completions | |
## Git | |
# https://github.com/dahlbyk/posh-git | |
Import-Module posh-git | |
## Deno | |
. C:\Users\danie\Documents\PowerShell\deno.completions.ps1 | |
## Chocolatey | |
# Import the Chocolatey Profile that contains the necessary code to enable | |
# tab-completions to function for `choco`. | |
# Be aware that if you are missing these lines from your profile, tab completion | |
# for `choco` will not function. | |
# See https://ch0.co/tab-completion for details. | |
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" | |
if (Test-Path($ChocolateyProfile)) { | |
Import-Module "$ChocolateyProfile" | |
} | |
## github cli | |
# https://cli.github.com/ | |
# https://github.com/cli/cli | |
Invoke-Expression -Command $(gh completion -s powershell | Out-String) | |
## Docker | |
# https://github.com/matt9ucci/DockerCompletion | |
Import-Module DockerCompletion | |
# ---- At the end ---- | |
## Zoxide | |
# https://github.com/ajeetdsouza/zoxide | |
Invoke-Expression (& { (zoxide init powershell | Out-String) }) | |
Set-Alias -Name cd -Value z -Option AllScope | |
# --- | |
# Pomodoro timers | |
# https://gist.github.com/bashbunni/f6b04fc4703903a71ce9f70c58345106 | |
function Show-TimerProgress([double]$minutes) { | |
$totalSeconds = [math]::Round($minutes * 60) | |
for ($i = 0; $i -le $totalSeconds; $i++) { | |
$percent = ($i / $totalSeconds) | |
$barWidth = 30 | |
$filled = [math]::Round($percent * $barWidth) | |
$empty = $barWidth - $filled | |
$bar = ('#' * $filled) + ('-' * $empty) | |
Write-Progress -Activity "Timer Running..." ` | |
-Status "[$bar] $i / $totalSeconds sec" ` | |
-PercentComplete ($percent * 100) | |
Start-Sleep -Seconds 1 | |
} | |
Write-Progress -Activity "Timer Done!" -Completed | |
} | |
function work([double]$minutes = 30) { | |
$timeout = $minutes * 60 | |
echo "Setting up timer with $timeout`s ($minutes`min)" | |
Show-TimerProgress $minutes | |
New-BurntToastNotification ` | |
-Text 'Take a Break 😊', 'Work Timer is up!' ` | |
-Sound 'Alarm2' | |
} | |
function rest([double]$minutes = 10) { | |
$timeout = $minutes * 60 | |
echo "Setting up timer with $timeout`s ($minutes`min)" | |
Show-TimerProgress $minutes | |
New-BurntToastNotification ` | |
-Text 'Get back to work 😬', 'Break is over!' ` | |
-Sound 'Alarm2' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment