# Styling # Import-Module posh-git # Import-Module oh-my-posh # Set-Theme Robbyrussell # See: https://github.com/felixrieseberg/windows-development-environment # Increase history $MaximumHistoryCount = 10000 # Produce UTF-8 by default $PSDefaultParameterValues["Out-File:Encoding"]="utf8" # Show selection menu for tab Set-PSReadlineKeyHandler -Chord Tab -Function MenuComplete # Use Starship shell $Env:STARSHIP_CONFIG = "$Env:USERPROFILE\.starship.toml" Invoke-Expression (&starship init powershell) # Go to the Alpine directory function wsla { Set-Location '\\wsl$\Alpine\home\gcanal' } function wsll { wsl -l -v } function wsls { wsl --shutdown } # Helper Functions ####################################################### function reload-profile { & $profile } function find-file($name) { ls -recurse -filter "*${name}*" -ErrorAction SilentlyContinue | foreach { $place_path = $_.directory echo "${place_path}\${_}" } } function print-path { ($Env:Path).Split(";") } function unzip ($file) { $dirname = (Get-Item $file).Basename echo("Extracting", $file, "to", $dirname) New-Item -Force -ItemType directory -Path $dirname expand-archive $file -OutputPath $dirname -ShowProgress } # Unixlike commands ####################################################### function which($name) { (Get-Command $name).Path } function df { get-volume } function sed($file, $find, $replace){ (Get-Content $file).replace("$find", $replace) | Set-Content $file } function sed-recursive($filePattern, $find, $replace) { $files = ls . "$filePattern" -rec foreach ($file in $files) { (Get-Content $file.PSPath) | Foreach-Object { $_ -replace "$find", "$replace" } | Set-Content $file.PSPath } } function grep($regex, $dir) { if ( $dir ) { ls $dir | select-string $regex return } $input | select-string $regex } function grepv($regex) { $input | ? { !$_.Contains($regex) } } function export($name, $value) { set-item -force -path "env:$name" -value $value; } function pkill($name) { ps $name -ErrorAction SilentlyContinue | kill } function pgrep($name) { ps $name } function touch($file) { "" | Out-File $file -Encoding ASCII }