Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@timabell
Last active May 1, 2018 08:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timabell/56254968905f9066ef88c1ae774a53d1 to your computer and use it in GitHub Desktop.
Save timabell/56254968905f9066ef88c1ae774a53d1 to your computer and use it in GitHub Desktop.
my powershell customisations
# customized per-user profile
# https://gist.github.com/timabell/56254968905f9066ef88c1ae774a53d1
# don't forget to start a new powershell after editing this
# useful things:
# install https://github.com/neilpa/cmd-colors-solarized
# regedit /s solarized-light.reg
# install https://github.com/dahlbyk/posh-git
# Install-Module posh-git # requires PSGet
Set-PSReadlineOption -EditMode Emacs
# don't do this, it breaks install-package -pre in vs pm console.
#$env:Path += ";C:\repos\Emvs European Hub\BuildProcess\NuGet"
# fix invisible chars for solarized-light
Set-PSReadlineOption -TokenKind Member -ForegroundColor DarkGreen
Set-PSReadlineOption -TokenKind Type -ForegroundColor DarkGreen
Set-PSReadlineOption -TokenKind Number -ForegroundColor DarkBlue
# Get-PSReadlineOption for more
# https://gist.github.com/timabell/cc9ca76964b59b2a54e91bda3665499e
function Out-Colors(){
Write-Host "PSReadline"
Write-Host "----------" -NoNewLine
Get-PSReadlineOption
Write-Host '$Host.PrivateData'
Write-Host "-----------------"
$Host.PrivateData
$colors = [enum]::GetValues([System.ConsoleColor])
Foreach ($bgcolor in $colors){
Foreach ($fgcolor in $colors) { Write-Host "$fgcolor|" -ForegroundColor $fgcolor -BackgroundColor $bgcolor -NoNewLine }
Write-Host " on $bgcolor"
}
}
function rst(){
# http://stackoverflow.com/a/35470129/10245
[Console]::ResetColor()
}
# install this https://github.com/neilpa/cmd-colors-solarized
# $Host.PrivateData # show the current list
$Host.PrivateData.ErrorForegroundColor = "DarkRed"
$Host.PrivateData.ErrorBackgroundColor = "Gray"
# Load posh-git profile if available. Copy from Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1
$poshGitProfile= [Environment]::GetFolderPath("MyDocuments") + "\WindowsPowershell\poshprofile.ps1"
if (Test-Path $poshGitProfile)
{
. $poshGitProfile
}
#.SYNOPSIS
# Run a block and then output how long it took
#.EXAMPLE
# time {
# echo "mork mork"
# sleep 5
# }
function time($block) {
# http://stackoverflow.com/a/15885502/10245
$sw = [Diagnostics.Stopwatch]::StartNew()
&$block
$sw.Stop()
write-host "Elapsed:" $sw.Elapsed.Hours "hours" $sw.Elapsed.Minutes "mins" $sw.Elapsed.Seconds "secs"
}
function rename-many($find, $replacement, [switch]$WhatIf){
Get-ChildItem -Recurse -Include "*$find*" | foreach {
$newname = $_.Name.replace($find, $replacement)
write-host "$_ => $newname"
if (! $WhatIf){
Rename-Item $_ -NewName $newname
}
}
}
function grep() {write-host "use the findstr luke, this is not the grep you're looking for. Or you could 'ls | sls'"}
$PSDefaultParameterValues = @{
"ls:force" = {$true} # include hidden files
}
New-Alias -Name ll -Value ls
New-Alias -Name gk -Value gitk
function gka(){
gitk --all
}
if ((join-path $pwd '') -eq (join-path $env:userprofile '')){
cd "c:\repos\"
}
# service fabric
function restartNode(){
Restart-ServiceFabricNode "_Node_0"
}
echo "Customised powershell profile loaded."
Windows Registry Editor Version 5.00
; Registry file that maps the solarized palette to the 16 avaliable colors
; in a Windows command prompt. Note, hex values in the table are RGB but byte
; ordering of a DWORD is BGR, e.g. "ColorTable<##>"=dword:00<B><G><R>
;
; Solarized color table from http://ethanschoonover.com/solarized.
; https://github.com/neilpa/cmd-colors-solarized
; sorted by solarized pallete order
;
; gray tone version
; NR cmd.exe PowerShell SOLARIZED HEX DWORD
; -- ------- ----------- --------- ------- --------
; light background tones
; 15 BrightWhite White base3 #fdf6e3 00e3f6fd
; 07 White Gray base2 #eee8d5 00d5e8ee
; content tones
; 03 Aqua DarkCyan base1 #93a1a1 00a1a193
; 01 Blue DarkBlue base0 #839496 00969483
; 06 Yellow DarkYellow base00 #657b83 00837b65
; 02 Green DarkGreen base01 #586e75 00756e58
; dark background tones
; 08 Gray DarkGray base02 #073642 00423607
; 00 Black Black base03 #002b36 00362b00
; accent colors
; 14 LightYellow Yellow yellow #b58900 000089b5
; 04 Red DarkRed orange #cb4b16 00164bcb
; 12 LightRed Red red #dc322f 002f32dc
; 13 LightPurple Magenta magenta #d33682 008236d3
; 05 Purple DarkMagenta violet #6c71c4 00c4716c
; 09 LightBlue Blue blue #268bd2 00d28b26
; 11 LightAqua Cyan cyan #2aa198 0098a12a
; 10 LightGreen Green green #859900 00009985
;
; all-colour tone version
; NR cmd.exe PowerShell SOLARIZED HEX DWORD
; -- ------- ----------- --------- ------- --------
; light background tones
; 15 BrightWhite White base3 #fdf6e3 00e3f6fd
; 07 White Gray base2 #eee8d5 00d5e8ee
; content tones
; dark background tones
; 08 Gray DarkGray base02 #073642 00423607
; 00 Black Black base03 #002b36 00362b00
; accent colors
; 14 LightYellow Yellow yellow #b58900 000089b5
; 06 Yellow DarkYellow yellow #b58900 000089b5
; 04 Red DarkRed orange #cb4b16 00164bcb
; 12 LightRed Red red #dc322f 002f32dc
; 13 LightPurple Magenta magenta #d33682 008236d3
; 05 Purple DarkMagenta violet #6c71c4 00c4716c
; 09 LightBlue Blue blue #268bd2 00d28b26
; 01 Blue DarkBlue blue #268bd2 00d28b26
; 11 LightAqua Cyan cyan #2aa198 0098a12a
; 03 Aqua DarkCyan cyan #2aa198 0098a12a
; 10 LightGreen Green green #859900 00009985
; 02 Green DarkGreen green #859900 00009985
;
[HKEY_CURRENT_USER\Console]
"ColorTable00"=dword:00362b00
"ColorTable01"=dword:00d28b26
"ColorTable02"=dword:00009985
"ColorTable03"=dword:0098a12a
"ColorTable04"=dword:00164bcb
"ColorTable05"=dword:00c4716c
"ColorTable06"=dword:000089b5
"ColorTable07"=dword:00d5e8ee
"ColorTable08"=dword:00423607
"ColorTable09"=dword:00d28b26
"ColorTable10"=dword:00009985
"ColorTable11"=dword:0098a12a
"ColorTable12"=dword:002f32dc
"ColorTable13"=dword:008236d3
"ColorTable14"=dword:000089b5
"ColorTable15"=dword:00e3f6fd
"ScreenColors"=dword:000000f6
"PopupColors"=dword:00000001
@timabell
Copy link
Author

timabell commented Feb 15, 2017

before
ps colours
after (all-colours version)
ps colours solarized

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment