Add custom loader for Powershell, improve its implementation in Cmder

Fixes #104, fixes #53, fixes #65 (my bad), related to #136, and should
fix #139
This commit is contained in:
Léo Colombaro 2014-09-17 09:55:15 +02:00
parent dcc9f5e59a
commit 98350e14e8
5 changed files with 2277 additions and 11 deletions

9
.gitignore vendored
View File

@ -1,13 +1,12 @@
## Those files should be taken from their repositary
vendor/*
!vendor/*.md
!vendor/*.bat
!vendor/*.json
vendor/*/*
!vendor/*
!vendor/psmodules/PsGet
config/.history
Thumbs.db
*.exe
build/
Version v*
Version v*

View File

@ -419,8 +419,8 @@
<value name="KeyMacro03.Text" type="string" data="FontSetSize(1,2)"/>
<value name="KeyMacro04" type="dword" data="000011d1"/>
<value name="KeyMacro04.Text" type="string" data="FontSetSize(1,-2)"/>
<value name="KeyMacro05" type="dword" data="00000000"/>
<value name="KeyMacro05.Text" type="string" data=""/>
<value name="KeyMacro05" type="dword" data="0012a032"/>
<value name="KeyMacro05.Text" type="string" data="Task(&quot;PowerShell as Admin&quot;)"/>
<value name="KeyMacro06" type="dword" data="00000000"/>
<value name="KeyMacro06.Text" type="string" data=""/>
<value name="KeyMacro07" type="dword" data="00000000"/>
@ -487,7 +487,7 @@
<value name="Count" type="dword" data="00000002"/>
<key name="Task1" modified="2014-01-21 18:36:36" build="131215">
<value name="Name" type="string" data="{cmd}"/>
<value name="GuiArgs" type="string" data=" /icon &quot;%CMDER_ROOT%\cmder.exe&quot;"/>
<value name="GuiArgs" type="string" data="/icon &quot;%CMDER_ROOT%\cmder.exe&quot;"/>
<value name="Cmd1" type="string" data="cmd /k &quot;%ConEmuDir%\..\init.bat&quot; -new_console:d:%USERPROFILE%"/>
<value name="Active" type="dword" data="00000000"/>
<value name="Count" type="dword" data="00000001"/>
@ -495,13 +495,21 @@
</key>
<key name="Task2" modified="2014-01-21 18:36:36" build="131215">
<value name="Name" type="string" data="{PowerShell}"/>
<value name="GuiArgs" type="string" data="/dir &quot;%userprofile%&quot;"/>
<value name="Cmd1" type="string" data="powershell"/>
<value name="GuiArgs" type="string" data="/icon &quot;%CMDER_ROOT%\cmder.exe&quot;"/>
<value name="Cmd1" type="string" data="PowerShell -NoLogo -NoProfile -NoExit -Command &quot;Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''&quot; -new_console:d:&quot;%USERPROFILE%&quot;"/>
<value name="Active" type="dword" data="00000000"/>
<value name="Count" type="dword" data="00000001"/>
<value name="Hotkey" type="dword" data="00000000"/>
</key>
</key>
<key name="Task3" modified="2014-09-17 09:17:41" build="140903">
<value name="Name" type="string" data="{PowerShell as Admin}"/>
<value name="Hotkey" type="dword" data="00000000"/>
<value name="GuiArgs" type="string" data="/icon &quot;%CMDER_ROOT%\cmder.exe&quot;"/>
<value name="Cmd1" type="string" data="* PowerShell -NoLogo -NoProfile -NoExit -Command &quot;Invoke-Expression '. ''%ConEmuDir%\..\custom.ps1''' &quot; -new_console:d:&quot;%USERPROFILE%&quot;"/>
<value name="Active" type="dword" data="00000000"/>
<value name="Count" type="dword" data="00000001"/>
</key>
</key>
<key name="Apps" modified="2014-01-21 18:36:36" build="131215">
<value name="Count" type="dword" data="00000000"/>
</key>

39
vendor/profile.ps1 vendored Normal file
View File

@ -0,0 +1,39 @@
# Global modules directory
$global:PsGetDestinationModulePath = $PSScriptRoot + "\..\vendor\psmodules"
# Push to modules location
Push-Location -Path ($PsGetDestinationModulePath)
# Load modules from current directory
Get-ChildItem -Directory | `
Foreach-Object{
Import-Module .\$_\$_
}
# Come back to PWD
Pop-Location
# Set up a Cmder prompt, adding the git prompt parts inside git repos
function global:prompt {
$realLASTEXITCODE = $LASTEXITCODE
$Host.UI.RawUI.ForegroundColor = "white"
Write-Host($pwd.ProviderPath) -NoNewLine -ForegroundColor "green"
if (Get-Module posh-git) {
Write-VcsStatus
}
$global:LASTEXITCODE = $realLASTEXITCODE
return "`nλ "
}
# Load special features come from posh-git
if (Get-Module posh-git) {
Enable-GitColors
Start-SshAgent -Quiet
}
# Move to the wanted location
if (Test-Path Env:\CMDER_START) {
Set-Location -Path $Env:CMDER_START
} elseif ($Env:CMDER_ROOT -and $Env:CMDER_ROOT.StartsWith($pwd)) {
Set-Location -Path $Env:USERPROFILE
}

88
vendor/psmodules/PsGet/PsGet.psd1 vendored Normal file
View File

@ -0,0 +1,88 @@
@{
# These modules will be processed when the module manifest is loaded. This is only supported in PS 3.0
#RootModule = "PsGet.psm1"
#This is required for PS 2.0
ModuleToProcess = "PsGet.psm1"
# The version of this module.
ModuleVersion = '1.0'
# This GUID is used to uniquely identify this module.
GUID = '638FF397-8108-4B94-981A-D9BDAB4774B2'
# The author of this module.
Author = 'Mike Chaliy'
# The company or vendor for this module.
CompanyName = ''
# The copyright statement for this module.
Copyright = '(c) 2013'
# Description of the functionality provided by this module
Description = 'PsGet module for installing PowerShell modules'
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '2.0'
# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''
# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of the .NET Framework required by this module
DotNetFrameworkVersion = '2.0'
# Minimum version of the common language runtime (CLR) required by this module
CLRVersion = '2.0'
# Processor architecture (None, X86, Amd64) required by this module
ProcessorArchitecture = 'None'
# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @()
# Functions to export from this module
FunctionsToExport = '*'
# Cmdlets to export from this module
CmdletsToExport = '*'
# Variables to export from this module
VariablesToExport = '*'
# Aliases to export from this module
AliasesToExport = '*'
# List of all modules packaged with this module.
# ModuleList = @()
# List of all files packaged with this module
# FileList = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess
# PrivateData = ''
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}

2132
vendor/psmodules/PsGet/PsGet.psm1 vendored Normal file

File diff suppressed because it is too large Load Diff