Skip to content

Instantly share code, notes, and snippets.

@somian
Created March 20, 2015 07:48
Show Gist options
  • Save somian/692cb2ac39bfa3f8806b to your computer and use it in GitHub Desktop.
Save somian/692cb2ac39bfa3f8806b to your computer and use it in GitHub Desktop.
PS launcher for Vim (on Wyhnnows) that finds alternate personal rcfile location
# /Call it OneShotSet.ps1 if you want/
Push-Location
Set-Location HKCU:\Console
New-Item '.\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe'
Set-Location '.\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe'
# Not working to change after the initial setup ...
## midnightblue -ish behind light gold
New-ItemProperty . ColorTable00 -type DWORD -value 0x00281100
New-ItemProperty . ColorTable07 -type DWORD -value 0x004895c5
New-ItemProperty . FaceName -type STRING -value "Lucida Console"
New-ItemProperty . FontFamily -type DWORD -value 0x00000036
New-ItemProperty . FontSize -type DWORD -value 0x000c0000
New-ItemProperty . FontWeight -type DWORD -value 0x00000190
New-ItemProperty . HistoryNoDup -type DWORD -value 0x00000000
New-ItemProperty . QuickEdit -type DWORD -value 0x00000001
New-ItemProperty . ScreenBufferSize -type DWORD -value 0x0bb80078
New-ItemProperty . WindowSize -type DWORD -value 0x00320078
Pop-Location
# / Call it "Microsoft.PowerShell_profile.ps1" if used as the $PROFILE /
# %USERPROFILE%\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
function Color-Cons
{ # See one-time setup file (Gist) below. It is pretty arcan stuff, but simply a registry write.
# 2.0
$panda = $Host.Version
$host.ui.rawui.backgroundcolor = 0
$host.ui.rawui.foregroundcolor = 7
$Host.UI.RawUI.WindowTitle = "Windows PowerShell $panda ($env:USERNAME)"
}
Color-Cons
function get-fso-File([string]$pth) {
BEGIN { $fso = New-Object -ComObject Scripting.FileSystemObject }
PROCESS {
$juy = ""
Try {
$fso.getFile($pth)
} catch {
If ($_.Exception.GetType().Name -eq "MethodInvocationException") {
Write-Host "The parameter passed was maybe not a file ...: $pth"
# examine the exception fully, fwiw:
# $_.Exception.GetType() | get-Member
Try {
$bwoo = $fso.getFolder($pth)
$juy = $bwoo.ShortPath
} catch { # strange: >>>>System.__ComObject C:/DOCUME~1/singsong<<<<
$BadNews = $_.Exception
Write-Host "The parameter passed was not a file nor a folder, or something went wrong ...: $pth"
If ($BadNews.GetType().Name -eq "MethodInvocationException") {
Write-Host "Another exception. The parameter DOLLA-pth is : >>>>>" + $pth.fullname + "<<<<<"
} Else {
$phew = $BadNews.GetType().Name
Write-Host "The bad news had to do with: $phew"
}
}
}
} Finally { write-Host "We may not return something useful now, but ..."; $juy }
# Fall-back ^^^^^^
}
}
function get-skwige([string]$oh) {
# $zok = $env:USERPROFILE
$zok = $oh
$r = get-fso-File $zok
$puffy = $r
$r = $puffy -replace '\\' , '/'
$r
}
Function exec-gvim-right {
$uProf= $env:USERPROFILE
If ("$uProf") {
$uprol = get-skwige "$uProf"
# write-Host ">>>>$uprol<<<<"
$env:VIMINIT = 'let $MYVIMRC="' + "$uprol/CONFIG/Vim7-vimrc" + '" |source $MYVIMRC'
Start-Process -FilePath "C:\AABS-Editor-Vim\7_4_27\vim\vim74\gvim.exe" -ArgumentList "-N -p"
}
}
Set-Alias -Name "GVim" exec-gvim-right -Description "Run Gui Vim editor"
Clear-Host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment