Created
October 21, 2019 02:05
-
-
Save gccpacman/69702550ca7ebcf9f35da57aa2983305 to your computer and use it in GitHub Desktop.
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
# import module | |
Import-Module PSReadLine | |
# oh-my-posh | |
# Import-Module posh-git | |
# Import-Module oh-my-posh | |
# Set-Prompt | |
# Set-Theme Agnoster | |
# Set-Theme tehrob | |
# Poshfuck | |
# Import-Module PoShFuck | |
# Persistent History | |
# Save last 200 history items on exit | |
# $MaximumHistoryCount = 100 | |
# $historyPath = Join-Path (split-path $profile) history.clixml | |
# Hook powershell's exiting event & hide the registration with -supportevent (from nivot.org) | |
# Register-EngineEvent -SourceIdentifier powershell.exiting -SupportEvent -Action { | |
# Get-History -Count $MaximumHistoryCount | Export-Clixml (Join-Path (split-path $profile) history.clixml) | |
# } | |
# Load previous history, if it exists | |
# if ((Test-Path $historyPath)) { | |
# Import-Clixml $historyPath | ? {$count++;$true} | Add-History | |
# Write-Host -Fore Green "`nLoaded $count history item(s).`n" | |
# } | |
# Set Linux bash like autocomplete | |
# https://stackoverflow.com/questions/8264655/how-to-make-powershell-tab-completion-work-like-bash | |
Set-PSReadlineKeyHandler -Key Tab -Function Complete | |
# Chocolatey profile | |
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" | |
if (Test-Path($ChocolateyProfile)) { | |
Import-Module "$ChocolateyProfile" | |
} | |
# $Host.UI.RawUI.WindowTitle='PS-'+$PID | |
# windows-screenfetch | |
# screenfetch | |
# alias | |
# Set-Alias -Name i -Value Invoke-History -Description "Invoke history alias" | |
Set-Alias -Name rms -Value 'Remove-ItemSafely' | |
Set-Alias -Name trash -Value 'Remove-ItemSafely' | |
#Rename-Item Alias:\h original_h -Force | |
#function h { Get-History -c $MaximumHistoryCount } | |
#function hg($arg) { Get-History -c $MaximumHistoryCount | out-string -stream | select-string $arg } | |
#function tt($arg) { $Host.UI.RawUI.WindowTitle=$arg } | |
# Produce UTF-8 by default | |
# https://news.ycombinator.com/item?id=12991690 | |
$PSDefaultParameterValues["Out-File:Encoding"] = "utf8" | |
function open($file) { | |
invoke-item $file | |
} | |
function explorer { | |
explorer.exe . | |
} | |
function settings { | |
start-process ms-setttings: | |
} | |
function limit-HomeDirectory($Path) { | |
$Path.Replace("$home", "~") | |
} | |
function refresh-path { | |
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + | |
";" + | |
[System.Environment]::GetEnvironmentVariable("Path","User") | |
} | |
function prompt { | |
$realLASTEXITCODE = $LASTEXITCODE | |
Write-Host '[' -NoNewline | |
Write-Host (Get-Date -UFormat '%T') -ForegroundColor Green -NoNewline | |
Write-Host ']:' -NoNewline | |
Write-Host $(limit-HomeDirectory("$pwd")) -ForegroundColor Yellow -NoNewline | |
Write-Host "$" -NoNewline | |
$global:LASTEXITCODE = $realLASTEXITCODE | |
Return " " | |
} | |
function out-default { | |
$input | Tee-Object -var global:lastobject | Microsoft.PowerShell.Core\out-default | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment