Dirty hacks for non-interactive shells
This commit is contained in:
parent
87659b9220
commit
07e254465d
3 changed files with 64 additions and 45 deletions
|
|
@ -131,8 +131,12 @@ function Add-ConsoleHelper()
|
|||
Add-Type -TypeDefinition $code -ReferencedAssemblies @('System.Drawing')
|
||||
}
|
||||
|
||||
# These are the 16 colors for our palette.
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
function Set-SolarizedColors([switch]$Light, [switch]$Dark)
|
||||
{
|
||||
if ( (-not $Light) -and (-not $Dark) )
|
||||
{
|
||||
$Light = $true
|
||||
}
|
||||
|
||||
# Here's the solarized table...
|
||||
#
|
||||
|
|
@ -155,15 +159,11 @@ $blue = "#268bd2" # 4/4 blue 33 #0087ff 55 -10 -45 38 139 210 205 82
|
|||
$cyan = "#2aa198" # 6/6 cyan 37 #00afaf 60 -35 -05 42 161 152 175 74 63
|
||||
$green = "#859900" # 2/2 green 64 #5f8700 60 -20 65 133 153 0 68 100 60
|
||||
|
||||
function Set-SolarizedColors([switch]$Light, [switch]$Dark)
|
||||
{
|
||||
if ( (-not $Light) -and (-not $Dark) )
|
||||
{
|
||||
$Light = $true
|
||||
}
|
||||
|
||||
if ($Host.Name -eq "ConsoleHost")
|
||||
{
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
Add-ConsoleHelper
|
||||
|
||||
# Redefine the standard console colors to have the Solarized-Light
|
||||
# palette.
|
||||
#
|
||||
|
|
@ -224,5 +224,3 @@ function Set-SolarizedColors([switch]$Light, [switch]$Dark)
|
|||
Clear-Host
|
||||
}
|
||||
}
|
||||
|
||||
Add-ConsoleHelper
|
||||
Binary file not shown.
|
|
@ -1,3 +1,15 @@
|
|||
# Check to see if we're interactive or not.... this is a dirty, dirty
|
||||
# hack.
|
||||
$interactive = $true
|
||||
$cmdLine = [System.Environment]::CommandLine
|
||||
if ($cmdLine.Contains("powershell.exe") -and ($cmdLine.Contains(".ps1") -and !$cmdLine.Contains("-noexit")))
|
||||
{
|
||||
# We're running non-interactively, don't do any of this stuff.
|
||||
$interactive = $false
|
||||
}
|
||||
|
||||
if ($interactive)
|
||||
{
|
||||
# Make MSYS based things work correctly (most importantly, msysgit)
|
||||
#
|
||||
$env:TERM='msys'
|
||||
|
|
@ -6,7 +18,7 @@ $env:TERM='msys'
|
|||
#
|
||||
$profileDir = split-path -parent $Profile
|
||||
Import-Module "$profileDir\Modules\ConsoleColors.psm1"
|
||||
Set-SolarizedColors -Dark
|
||||
# Set-SolarizedColors -Dark
|
||||
|
||||
# Ensure HOME is set properly
|
||||
#
|
||||
|
|
@ -18,6 +30,7 @@ set-variable -name HOME -value (resolve-path $env:Home) -force
|
|||
#
|
||||
$env:Path = "$env:windir\Microsoft.NET\Framework64;" + $env:Path
|
||||
$env:Path = "c:\debuggers;c:\tools\x86;c:\tools\x86\bin;c:\emacs\bin" + $env:Path
|
||||
}
|
||||
|
||||
# Based on http://winterdom.com/2008/08/mypowershellprompt
|
||||
function shorten-path([string] $path)
|
||||
|
|
@ -30,10 +43,18 @@ function shorten-path([string] $path)
|
|||
return ($loc -replace '\\(\.?)([^\\]{3})[^\\]*(?=\\)','\$1$2')
|
||||
}
|
||||
|
||||
$global:SolarizedColors = $false
|
||||
|
||||
function prompt
|
||||
{
|
||||
$ok = $?
|
||||
|
||||
if (!$global:SolarizedColors)
|
||||
{
|
||||
Set-SolarizedColors -Dark
|
||||
$global:SolarizedColors = $true
|
||||
}
|
||||
|
||||
# Our "theme", as it were. Note that we assume the use of the
|
||||
# solarized colors.
|
||||
#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue