Skip to content

Instantly share code, notes, and snippets.

@rkeithhill
rkeithhill / ResetColors.ps1
Created January 11, 2015 02:36
Resets the console background and foreground colors to their startup values
# Certains console exes have a tendency to bork the console colors - looking at you
# MSBuild.exe. Either copy/paste this into your profile.ps1 file or dot source it.
$script:origBgColor = $host.ui.rawui.BackgroundColor
$script:origFgColor = $host.ui.rawui.ForegroundColor
function Reset-Colors
{
$host.ui.rawui.BackgroundColor = $origBgColor
$host.ui.rawui.ForegroundColor = $origFgColor
}
@rkeithhill
rkeithhill / dir_colors.txt
Last active October 25, 2018 02:15
dir_colors.txt
DIR 34
LINK 33
*.exe 38;2;0;192;0 # Bold executables
*.ps1 92 # PowerShell scripts
*.psm1 92 # PowerShell module scripts
@rkeithhill
rkeithhill / gitconfig.txt
Last active November 29, 2019 18:35
Config file for Git
# More gitconfig goodness here - https://gist.github.com/tdd/470582
git config --global user.name "Keith Hill"
git config --global user.email <email here>
git config --global core.editor '\"C:\Program Files (x86)\Microsoft VS Code\bin\code.cmd\" --new-window --wait'
git config --global core.autocrlf true
git config --global pull.ff only
git config --global pull.rebase true
git config --global rebase.autoStash true
@rkeithhill
rkeithhill / build.ps1
Last active April 2, 2020 15:33
PSake build script for publishing PowerShell modules
# This is a PSake script that supports the following tasks:
# clean, build, test and publish. The default task is build.
#
# The publish task uses the Publish-Module command to publish
# to either the PowerShell Gallery (the default) or you can change
# the $Repository property to the name of an alternate repository.
#
# The test task invokes Pester to run any Pester tests in your
# workspace folder. Name your test scripts <TestName>.Tests.ps1
# and Pester will find and run the tests contained in the files.
@rkeithhill
rkeithhill / VSCode-keybindings.json
Last active April 30, 2020 18:43
My Visual Studio Code customized keyboard shorcuts
// Place your key bindings in this file to overwrite the defaults
[
{ "key": "alt+n", "command": "explorer.newFile" },
{ "key": "alt+shift+s", "command": "PowerShell.InvokeRegisteredEditorCommand",
"args": { "commandName": "ConvertToSplatExpression" },
"when": "editorLangId == 'powershell'" },
{ "key": "ctrl+shift+q", "command": "workbench.action.toggleMaximizedPanel" },
{ "key": "ctrl+shift+s", "command": "workbench.action.files.saveAll" },
{ "key": "ctrl+shift+t", "command": "workbench.action.tasks.test" },
{ "key": "ctrl+alt+t", "command": "workbench.action.tasks.runTask" },
@rkeithhill
rkeithhill / settings.json
Last active November 21, 2020 22:39
Windows Terminal home profile
// This file was initially generated by Windows Terminal 0.11.1121.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@rkeithhill
rkeithhill / VSCode-settings.json
Last active January 14, 2021 12:46
My Visual Studio Code user settings
// Place your settings in this file to overwrite the default settings
{
"debug.toolBarLocation": "docked",
"diffEditor.ignoreTrimWhitespace": true,
"editor.codeLens": true,
"editor.detectIndentation": false,
"editor.dragAndDrop": false,
"editor.renderWhitespace": "none",
@rkeithhill
rkeithhill / ConfigureConsoleSettings.ps1
Last active January 25, 2021 22:40
Configures the PowerShell console settings (colors, fonts, buffer size, etc).
<#
.SYNOPSIS
Sets the console settings to the specified values and color theme.
.DESCRIPTION
Sets the console settings to the specified values and color theme.
.EXAMPLE
C:\PS> Configure-ConsoleSettings -Theme ConEmu -WindowSize 120,50 `
-FontFace Consolas -FontSize 12
Sets the colors to those used in ConEmu and sets the font and window size.
if (($PSVersionTable.PSVersion.Major -le 5) -or $IsWindows) {
Set-Alias nano 'C:\Program Files\Git\usr\bin\nano.exe'
Set-Alias vim 'C:\Program Files\Git\usr\bin\vim.exe'
}
# Edition/platform specific configuration
if ($IsWindows) {
$env:PAGER = 'less -Ps"Page %db?B of %D:.\. Press h for help or Q to quit\."'
if ($PSVersionTable.PSEdition -eq 'Desktop') {
$PSDefaultParameterValues['Get-Help:Full'] = $true
$wingetCompleter = {
param($wordToComplete, $commandAst, $cursorPosition)
$tokens = $commandAst.Extent.Text.Trim() -split '\s+'
$completions = switch ($tokens[1]) {
'install' { "-q","-m","-v","-s","-e","-i","-h","-o","-l",
"--query","--manifest","--id","--name","--moniker","--version","--source","--exact","--interactive",
"--silent","--log","--override","--location","--help"; break }
'search' { "-q","-s","-n","-e","-?",
"--query","--id","--name","--moniker","--tag","--command","--source","--count","--exact","--help"