Skip to content

Instantly share code, notes, and snippets.

@kkoziarski
Last active February 9, 2019 20:37
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 kkoziarski/071c276503f556e0362f1fad2a42d697 to your computer and use it in GitHub Desktop.
Save kkoziarski/071c276503f556e0362f1fad2a42d697 to your computer and use it in GitHub Desktop.
Scripts to run on a new system

Powerline

cmder_powershell_git_screenshot

powershell_git_screenshot2

cmder_fonts_settings

Cmder::Powershell config

PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command "Invoke-Expression '. ''%USERPROFILE%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'''" -new_console:d:"%USERPROFILE%"

cmder_powershell_settings

powershell_properties

cmder_colors

#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$lastColor = $sl.Colors.PromptBackgroundColor
$prompt = Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
#check the last command state and indicate if failed
If ($lastCommandFailed) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.FailedCommandSymbol) " -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
#check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) " -ForegroundColor $sl.Colors.AdminIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
$user = [System.Environment]::UserName
$computer = [System.Environment]::MachineName
$path = Get-FullPath -dir $pwd
if (Test-NotDefaultUser($user)) {
$prompt += Write-Prompt -Object "$user@$computer " -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.VirtualEnvSymbol) $(Get-VirtualEnvName) " -ForegroundColor $sl.Colors.VirtualEnvForegroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.VirtualEnvBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
else {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
# Writes the drive portion
$prompt += Write-Prompt -Object "$path " -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
$status = Get-VCSStatus
if ($status) {
$themeInfo = Get-VcsInfo -status ($status)
$lastColor = $themeInfo.BackgroundColor
$prompt += Write-Prompt -Object $($sl.PromptSymbols.SegmentForwardSymbol) -ForegroundColor $sl.Colors.PromptBackgroundColor -BackgroundColor $lastColor
$prompt += Write-Prompt -Object " $($themeInfo.VcInfo) " -BackgroundColor $lastColor -ForegroundColor $sl.Colors.GitForegroundColor
}
# Writes the postfix to the prompt
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $lastColor
$timeStamp = Get-Date -UFormat %R
$timestamp = "[$timeStamp]"
$prompt += Set-CursorForRightBlockWrite -textLength ($timestamp.Length + 1)
$prompt += Write-Prompt $timeStamp -ForegroundColor $sl.Colors.PromptForegroundColor
$prompt += Set-Newline
if ($with) {
$prompt += Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
}
$prompt += Write-Prompt -Object ($sl.PromptSymbols.PromptIndicator) -ForegroundColor $sl.Colors.PromptBackgroundColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.StartSymbol = ' '
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276F)
$sl.PromptSymbols.SegmentForwardSymbol = [char]::ConvertFromUtf32(0xE0B0)
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.GitForegroundColor = [ConsoleColor]::Black
$sl.Colors.WithForegroundColor = [ConsoleColor]::DarkRed
$sl.Colors.WithBackgroundColor = [ConsoleColor]::Magenta
$sl.Colors.VirtualEnvBackgroundColor = [System.ConsoleColor]::Red
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::White
{
"cursor_size": "small",
"font_face": "DejaVu Sans Mono for Powerline",
"font_size": "0x14",
"popup_colors": "yellow,white",
"dark_gray": "#839496",
"screen_colors": "blue,black",
"dark_green": "#859900",
"command_history_no_duplication": false,
"window_size": "140x40",
"font_weight": 700,
"screen_buffer_size": "140x3000",
"blue": "#839496",
"command_history_length": 200,
"font_true_type": true,
"dark_yellow": "#b58900",
"quick_edit": true,
"red": "#cb4b16",
"insert_mode": true,
"magenta": "#6c71c4",
"dark_red": "#dc322f",
"load_console_IME": true,
"yellow": "#859900",
"dark_magenta": "#d33682",
"cyan": "#93a1a1",
"green": "#859900",
"dark_blue": "#268bd2",
"gray": "#eee8d5",
"white": "#fdf6e3",
"fullscreen": false,
"num_history_buffers": 4,
"black": "#002b36",
"dark_cyan": "#2aa198",
"window_alpha": 231
}
Import-Module posh-git
Import-Module oh-my-posh
Import-Module z
Import-Module Get-ChildItemColor
$ThemeSettings.MyThemesLocation = "$($ENV:OneDrive)\tools\oh-my-posh-theme"
Set-Theme Paradox-custom-theme
#$ThemeSettings.Colors.GitForegroundColor = [ConsoleColor]::White
#$GitPromptSettings.DefaultPromptSuffix = '`n$(''>'' * ($nestedPromptLevel + 1)) '
$DefaultUser = 'my-pc-username' #[Environment]::UserName
Set-PSReadlineOption -BellStyle None
Remove-Item alias:curl
function List-AllContainers {
docker ps --all --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}\t{{.Image}}\t{{.ID}}"
}
Set-Alias dps List-AllContainers
Set-Alias kb kubectl
Set-Alias ls Get-ChildItemColor -option AllScope
Set-Alias l Get-ChildItemColorFormatWide -option AllScope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment