Skip to content

Instantly share code, notes, and snippets.

@DoggettCK
Created February 25, 2015 19:10
Show Gist options
  • Save DoggettCK/472ab258a041283c4da7 to your computer and use it in GitHub Desktop.
Save DoggettCK/472ab258a041283c4da7 to your computer and use it in GitHub Desktop.
# Make sure we're installing into user's own Powershell Module path, and not the global one
$PSModuleDir = "$($ENV:PsModulePath)".Split(";") | Select-String "$ENV:UserName" | foreach {$_.Line } | Select-Object -First 1
function ModuleInstalled([parameter(Mandatory=$true)][string] $moduleName) {
return ((Get-Module "$moduleName") -ne $null)
}
function InstallPlugins([parameter(Mandatory=$true)][string[]] $moduleNames) {
if (-NOT (Test-Path "$PSModuleDir\PsGet\PsGet.psm1")) {
New-Item -ItemType Directory -Force -Path "$PSModuleDir\PsGet" | Out-Null
Add-Content -Path "$PSModuleDir\PsGet\PsGet.psm1" -Value (New-Object Net.WebClient).DownloadString("https://raw.githubusercontent.com/psget/psget/master/PsGet/PsGet.psm1")
}
foreach ($moduleName in $moduleNames) {
if (-NOT (ModuleInstalled "$moduleName" )) {
Install-Module "$moduleName" | Out-Null
}
}
}
InstallPlugins(@("PSReadline", "Posh-Git"))
if ($host.Name -eq 'ConsoleHost') {
if (ModuleInstalled("PSReadline"))
{
Import-Module "PSReadline"
Set-PSReadlineOption -EditMode Emacs
}
if (ModuleInstalled("Posh-Git")) {
# Load posh-git example profile
. "$PSModuleDir\posh-git\profile.example.ps1"
$GitPromptSettings.EnableFileStatus = $false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment