Last active
November 6, 2019 12:15
-
-
Save ay65535/d66f73bc8b4b71a56163967964747509 to your computer and use it in GitHub Desktop.
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
/Modules/ |
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
if ($Host.Name -eq 'ConsoleHost') { | |
if ("${env:OS}" -eq 'Windows_NT') { | |
#Import-Module PackageManagement | |
function cgls() { Get-Package -ProviderName ChocolateyGet } | |
function cgfind() { Find-Package -ProviderName ChocolateyGet $args[0] } | |
function cginst() { Install-Package -ProviderName ChocolateyGet $args[0] } | |
function cgrm() { Uninstall-Package -ProviderName ChocolateyGet $args[0] } | |
# if ($PSVersionTable.PSVersion.Major -ge 6) { | |
# # Add `-Scope CurrentUser` if you're installing as non-admin | |
# Install-Module WindowsPSModulePath -Force -Scope CurrentUser | |
# # Add this line to your profile if you always want Windows PowerShell PSModulePath | |
# Add-WindowsPSModulePath | |
# } | |
} | |
#Import-Module PowershellGet | |
Import-Module PSReadline | |
Set-PSReadlineOption -EditMode Emacs | |
Set-PSReadlineOption -BellStyle None | |
} | |
### functions | |
## quasi-which | |
function which($arg) { | |
Get-Command $arg | Format-List | |
} | |
function poshgit() { | |
Import-Module posh-git | |
} | |
function Out-Utf8File() { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Position = 0)] | |
[string] | |
$Path, | |
[Parameter(Mandatory = $true, | |
Position = 1, | |
ValueFromPipeline = $true)] | |
[ValidateNotNull()] | |
[ValidateNotNullOrEmpty()] | |
$Content | |
) | |
if (-not(Test-Path -LiteralPath "$Path")) { | |
# file not exists | |
New-Item -Path "$Path" | Out-Null | |
} | |
$fullPath = (Get-Item $Path).FullName | |
$utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $false | |
[System.IO.File]::WriteAllText($fullPath, $Content, $utf8NoBomEncoding) | |
} | |
## alias functions | |
function q() { exit } | |
### aliases | |
Set-Alias -name touch -value New-Item | |
### add path | |
if ($env:Path -split ';' -notcontains "$HOME\bin") { | |
$env:Path += ";$HOME\bin" | |
} | |
### cd to $HOME | |
#Set-Location $HOME | |
### PowerShell\profile.ps1 | |
# $pwshProfileDir = Get-Item $profile.CurrentUserAllHosts.Replace('\profile.ps1', '') | |
# $windowPoerShellProfilePath = Join-Path ($pwshProfileDir).Parent.FullName 'WindowsPowerShell\profile.ps1' | |
# if (Test-Path -LiteralPath $windowPoerShellProfilePath) { | |
# . $windowPoerShellProfilePath | |
# } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment