Skip to content

Instantly share code, notes, and snippets.

@pseudo-su
Forked from jessfraz/boxstarter.ps1
Last active November 13, 2018 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pseudo-su/00b72ee0733b430269d45c8a021cc6d9 to your computer and use it in GitHub Desktop.
Save pseudo-su/00b72ee0733b430269d45c8a021cc6d9 to your computer and use it in GitHub Desktop.
Config for windows dev machine
# Description: Boxstarter Script
# Author: Jess Frazelle <jess@linux.com>
# Last Updated: 2017-09-11
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt:
# start http://boxstarter.org/package/nr/url?<URL-TO-RAW-GIST>
# OR
# Install-BoxstarterPackage -PackageName <URL-TO-RAW-GIST> -DisableReboots
#
# Learn more: http://boxstarter.org/Learn/WebLauncher
#---- TEMPORARY ---
Disable-UAC
#--- Windows Settings ---
Disable-BingSearch
Disable-GameBarTips
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions
#--- Windows Subsystems/Features ---
choco install Microsoft-Hyper-V-All -source windowsFeatures
choco install Microsoft-Windows-Subsystem-Linux -source windowsfeatures
#--- Install Scoop cmd-line installer
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
#-- Install Scoop developer tools
scoop install git
#--- Uninstall unecessary applications that come with Windows out of the box ---
# 3D Builder
Get-AppxPackage Microsoft.3DBuilder | Remove-AppxPackage
# Autodesk
Get-AppxPackage *Autodesk* | Remove-AppxPackage
# Bing Weather, News, Sports, and Finance (Money):
Get-AppxPackage Microsoft.BingFinance | Remove-AppxPackage
Get-AppxPackage Microsoft.BingNews | Remove-AppxPackage
Get-AppxPackage Microsoft.BingSports | Remove-AppxPackage
Get-AppxPackage Microsoft.BingWeather | Remove-AppxPackage
# BubbleWitch
Get-AppxPackage *BubbleWitch* | Remove-AppxPackage
# Candy Crush
Get-AppxPackage king.com.CandyCrush* | Remove-AppxPackage
# Comms Phone
Get-AppxPackage Microsoft.CommsPhone | Remove-AppxPackage
# Dell
Get-AppxPackage *Dell* | Remove-AppxPackage
# Dropbox
Get-AppxPackage *Dropbox* | Remove-AppxPackage
# Feedback Hub
Get-AppxPackage Microsoft.WindowsFeedbackHub | Remove-AppxPackage
# Get Started
Get-AppxPackage Microsoft.Getstarted | Remove-AppxPackage
# Keeper
Get-AppxPackage *Keeper* | Remove-AppxPackage
# March of Empires
Get-AppxPackage *MarchofEmpires* | Remove-AppxPackage
# McAfee Security
Get-AppxPackage *McAfee* | Remove-AppxPackage
# Uninstall McAfee Security App
$mcafee = gci "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "McAfee Security" } | select UninstallString
if ($mcafee) {
$mcafee = $mcafee.UninstallString -Replace "C:\Program Files\McAfee\MSC\mcuihost.exe",""
Write "Uninstalling McAfee..."
start-process "C:\Program Files\McAfee\MSC\mcuihost.exe" -arg "$mcafee" -Wait
}
# Office Hub
Get-AppxPackage Microsoft.MicrosoftOfficeHub | Remove-AppxPackage
# One Connect
Get-AppxPackage Microsoft.OneConnect | Remove-AppxPackage
# People
Get-AppxPackage Microsoft.People | Remove-AppxPackage
# Phone
Get-AppxPackage Microsoft.WindowsPhone | Remove-AppxPackage
# Skype (Metro version)
Get-AppxPackage Microsoft.SkypeApp | Remove-AppxPackage
# Solitaire
Get-AppxPackage *Solitaire* | Remove-AppxPackage
# Sway
Get-AppxPackage Microsoft.Office.Sway | Remove-AppxPackage
# Xbox
Get-AppxPackage Microsoft.XboxApp | Remove-AppxPackage
Get-AppxPackage Microsoft.XboxIdentityProvider | Remove-AppxPackage
# Privacy: Let apps use my advertising ID: Disable
If (-Not (Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo")) {
New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo | Out-Null
}
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
# WiFi Sense: HotSpot Sharing: Disable
If (-Not (Test-Path "HKLM:\Software\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting")) {
New-Item -Path HKLM:\Software\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting | Out-Null
}
Set-ItemProperty -Path HKLM:\Software\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting -Name value -Type DWord -Value 0
# WiFi Sense: Shared HotSpot Auto-Connect: Disable
Set-ItemProperty -Path HKLM:\Software\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots -Name value -Type DWord -Value 0
# Start Menu: Disable Bing Search Results
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name BingSearchEnabled -Type DWord -Value 0
# To Restore (Enabled):
# Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name BingSearchEnabled -Type DWord -Value 1
# Change Explorer home screen back to "This PC"
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name LaunchTo -Type DWord -Value 1
# Change it back to "Quick Access" (Windows 10 default)
# Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name LaunchTo -Type DWord -Value 2
# Better File Explorer
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Value 1
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneShowAllFolders -Value 1
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name MMTaskbarMode -Value 2
# Lock screen (not sleep) on lid close
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power' -Name AwayModeEnabled -Type DWord -Value 1
# To Restore:
# Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power' -Name AwayModeEnabled -Type DWord -Value 0
# Disable Xbox Gamebar
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR" -Name AppCaptureEnabled -Type DWord -Value 0
Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name GameDVR_Enabled -Type DWord -Value 0
# Turn off People in Taskbar
If (-Not (Test-Path "HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People")) {
New-Item -Path HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People | Out-Null
}
Set-ItemProperty -Path "HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name PeopleBand -Type DWord -Value 0
#--- Restore Temporary Settings ---
Enable-UAC
Enable-MicrosoftUpdate
Install-WindowsUpdate -acceptEula
#--- Rename the Computer ---
# Requires restart, or add the -Restart flag
$computername = "pseudo-surface"
if ($env:computername -ne $computername) {
Rename-Computer -NewName $computername
}

My Terminal config

Author: John Stableford

Date: 11/07/2018

Overview

  • iTerm terminal emulator link
  • Solarized Dark Terminal theme
  • PragmataPro font w/ ligatures
  • Fish shell link
  • Oh My Fish plugin manager link

iTerm setup

  • Color theme
  • Set font
  • Enable font ligatures

Fish setup

Install: brew install fish

Fish configuration structure

Fish config lives in ~/.config/fish

  • ~/.config/fish/config.fish Gets loaded on initialization
  • ~/.config/fish/functions/*.fish are also implicitly loaded by fish if the function/filename match

My *.fish Files

Files:

├── conf.d
│   └── omf.fish
├── config.fish
├── functions
│   └── fish_prompt.fish
└── my-config
    ├── helpers
    │   ├── adobe.fish
    │   ├── docker.fish
    │   └── dynamo.fish
    ├── init-general.fish
    └── watch-nvm.fish

config.fish

set -l fish_config_location (dirname (status -f))

# source $fish_config_location/my-config/helpers/adobe.fish
# source $fish_config_location/my-config/helpers/docker.fish
# source $fish_config_location/my-config/helpers/dynamo.fish
source $fish_config_location/my-config/init-general.fish
source $fish_config_location/my-config/watch-nvm.fish

init-general.fish

set fish_greeting ""
set -g -x PATH /usr/local/bin $PATH

alias fishconfig "code ~/.config/fish"
alias vimconfig "code ~/.config/nvim"

# marlin comma completion filter
set -g FILTER ''

# Flutter setup
set -gx PATH "~/Development/tools/flutter/bin" $PATH

# Projects folder
alias cdp "cd ~/Development/Projects"
alias cdpd "cd ~/Development/Projects/DigIO"
alias cdpp "cd ~/Development/Projects/Punters"

watch-nvm.fish

function __check_nvm --on-variable PWD --description 'Do nvm stuff'
  nvm use > /dev/null
end

__check_nvm

functions/fish_prompt.sh (taken and modified from somewhere at some point)

function fish_prompt -d 'Write out the prompt'
  set -l last_status $status

  # Just calculate this once, to save a few cycles when displaying the prompt
  if not set -q __fish_prompt_hostname
    set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
  end

  set -l normal (set_color normal)

  # Hack; fish_config only copies the fish_prompt function (see #736)
  if not set -q -g __fish_classic_git_functions_defined
    set -g __fish_classic_git_functions_defined

    function __fish_repaint_user --on-variable fish_color_user -d "Event handler, repaint when fish_color_user changes"
      if status --is-interactive
        commandline -f repaint ^/dev/null
      end
    end

    function __fish_repaint_host --on-variable fish_color_host -d "Event handler, repaint when fish_color_host changes"
      if status --is-interactive
        commandline -f repaint ^/dev/null
      end
    end

    function __fish_repaint_status --on-variable fish_color_status -d "Event handler; repaint when fish_color_status changes"
      if status --is-interactive
        commandline -f repaint ^/dev/null
      end
    end

    function __fish_repaint_bind_mode --on-variable fish_key_bindings -d "Event handler; repaint when fish_key_bindings changes"
      if status --is-interactive
        commandline -f repaint ^/dev/null
      end
    end

    # initialize our new variables
    if not set -q __fish_classic_git_prompt_initialized
      set -qU fish_color_user; or set -U fish_color_user -o green
      set -qU fish_color_host; or set -U fish_color_host -o cyan
      set -qU fish_color_status; or set -U fish_color_status red
      set -U __fish_classic_git_prompt_initialized
    end
  end

  set -l color_cwd
  set -l prefix
  switch $USER
  case root toor
    if set -q fish_color_cwd_root
      set color_cwd $fish_color_cwd_root
    else
      set color_cwd $fish_color_cwd
    end
    set suffix '#'
  case '*'
    set color_cwd $fish_color_cwd
    set suffix '>'
  end

  set -l prompt_status
  if test $last_status -ne 0
    set prompt_status ' ' (set_color $fish_color_status) "[$last_status]" "$normal"
  end

  set -l mode_str
  switch "$fish_key_bindings"
  case '*_vi_*' '*_vi'
    # possibly fish_vi_key_bindings, or custom key bindings
    # that includes the name "vi"
    set mode_str (
      echo -n " "
      switch $fish_bind_mode
      case default
        set_color --bold --background red white
        echo -n "[N]"
      case insert
        set_color --bold green
        echo -n "[I]"
      case visual
        set_color --bold magenta
        echo -n "[V]"
      end
      set_color normal
    )
  end
  echo -n -s (set_color $fish_color_user) "$USER" $normal @ (set_color $fish_color_host) "$__fish_prompt_hostname" $normal ' ' (set_color $color_cwd) (prompt_pwd) $normal (__fish_git_prompt) $normal $prompt_status "$mode_str" " -> "
end

List of other potentially useful things

Oh My Fish Plugins

Install: curl -L https://get.oh-my.fish | fish

I use the following plugins (omf install <pluginname>):

Built-in (I think)

  • fish-spec: built in test utils
  • omf: built in oh-my-fish CLI
  • expand

Very Useful

  • nvm: Node version manager wrapper for Fish shell
  • marlin: comma based based autocompletion from history
  • export: simulate bash export
  • foreign-env: Run foreign bash scripts and capture exported environment variables

Less important but useful

  • fuck: similar to sudo !!
  • osx: some osx utils
  • yarn-binpath: make yarn cli work
  • battery: look at the battery
  • wifi-password: get the wifi password that you're currently connected to
Windows Registry Editor Version 5.00
; Adapted from https://github.com/neilpa/cmd-colors-solarized/blob/master/solarized-dark.reg
; 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.
;
;| SOLARIZED | HEX | ANSI | TERMCOL | cmd.exe | PowerShell | ColorTable | DWORD |
;|-----------|---------|-----------|-----------|-------------|-------------|------------|----------|
;| base03 | #002b36 | ESC[0;30m | brblack | Black | Black | 00 | 00362b00 |
;| base02 | #073642 | ESC[1;30m | black | Gray | DarkGray | 08 | 00423607 |
;| base01 | #586e75 | ESC[0;32m | brgreen | Green | DarkGreen | 02 | 00756e58 |
;| base00 | #657b83 | ESC[0;33m | bryellow | Yellow | DarkYellow | 06 | 00837b65 |
;| base0 | #839496 | ESC[0;34m | brblue | Blue | DarkBlue | 01 | 00969483 |
;| base1 | #93a1a1 | ESC[0;36m | brcyan | Aqua | DarkCyan | 03 | 00a1a193 |
;| base2 | #eee8d5 | ESC[0;37m | white | White | Gray | 07 | 00d5e8ee |
;| base3 | #fdf6e3 | ESC[1;37m | brwhite | BrightWhite | White | 15 | 00e3f6fd |
;| yellow | #b58900 | ESC[1;33m | yellow | LightYellow | Yellow | 14 | 000089b5 |
;| orange | #cb4b16 | ESC[0;31m | brred | Red | DarkRed | 04 | 00164bcb |
;| red | #dc322f | ESC[1;31m | red | LightRed | Red | 12 | 002f32dc |
;| magenta | #d33682 | ESC[1;35m | magenta | LightPurple | Magenta | 13 | 008236d3 |
;| violet | #6c71c4 | ESC[0;35m | brmagenta | Purple | DarkMagenta | 05 | 00c4716c |
;| blue | #268bd2 | ESC[1;34m | blue | LightBlue | Blue | 09 | 00d28b26 |
;| cyan | #2aa198 | ESC[1;36m | cyan | LightAqua | Cyan | 11 | 0098a12a |
;| green | #859900 | ESC[1;32m | green | LightGreen | Green | 10 | 00009985 |
;
[HKEY_CURRENT_USER\Console\C:_Program Files_WindowsApps_WhitewaterFoundryLtd.Co.16571368D6CFF_1.1.23.0_x64__kd1vv0z0vy70w_wlinux.exe]
"ColorTable00"=dword:00362b00
"ColorTable01"=dword:00969483
"ColorTable02"=dword:00756e58
"ColorTable03"=dword:00a1a193
"ColorTable04"=dword:00164bcb
"ColorTable05"=dword:00c4716c
"ColorTable06"=dword:00837b65
"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:00000001
"PopupColors"=dword:000000f6
[HKEY_CURRENT_USER\Console\C:_Program Files_WindowsApps_TheDebianProject.DebianGNULinux_1.1.4.0_x64__76v4gfsz19hv4_debian.exe]
"ColorTable00"=dword:00362b00
"ColorTable01"=dword:00969483
"ColorTable02"=dword:00756e58
"ColorTable03"=dword:00a1a193
"ColorTable04"=dword:00164bcb
"ColorTable05"=dword:00c4716c
"ColorTable06"=dword:00837b65
"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:00000001
"PopupColors"=dword:000000f6
{
"editor.fontFamily": "'PragmataPro Mono', Consolas, 'Courier New', monospace",
"editor.fontLigatures": true,
"editor.tabSize": 2,
"editor.dragAndDrop": false,
"editor.smoothScrolling": true,
"editor.quickSuggestionsDelay": 50,
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"workbench.enableExperiments": false,
"workbench.startupEditor": "none",
"workbench.colorTheme": "Solarized Dark",
"workbench.statusBar.feedback.visible": false,
"workbench.settings.editor": "json",
"debug.inlineValues": true,
"terminal.external.windowsExec": "C:\\WINDOWS\\System32\\wsl.exe",
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\wsl.exe",
"terminal.integrated.rightClickBehavior": "default",
"telemetry.enableCrashReporter": false,
"telemetry.enableTelemetry": false,
"git.alwaysShowStagedChangesResourceGroup": true,
"html.format.endWithNewline": true,
"html.format.indentHandlebars": true,
"markdown.preview.doubleClickToSwitchToEditor": false,
"debug.node.autoAttach": "on",
"npm.enableScriptExplorer": true,
"javascript.autoClosingTags": false,
"typescript.surveys.enabled": false,
}
# https://github.com/Microsoft/WSL/issues/1932#issuecomment-407855346
$win_user = "pseudo_sudo"
$linux_user = "pseudo_sudo"
$package = "WhitewaterFoundryLtd.Co.16571368D6CFF_kd1vv0z0vy70w"
# $package = "TheDebianProject.DebianGNULinux_76v4gfsz19hv4"
$wsl_base_path = "C:\Users\" + $win_user + "\AppData\Local\Packages\" + $package + "\LocalState\rootfs"
$linux_home_base_path = "C:\Users\" + $win_user
# $linux_home_base_path = $wsl_base_path + "\home\" + $linux_user
# Add exceptions for linux directies
$dirs = @("\bin", "\sbin", "\usr\bin", "\usr\sbin")
$dirs | ForEach { Add-MpPreference -ExclusionProcess ($wsl_base_path + $_ + "\*") }
Add-MpPreference -ExclusionPath $wsl_base_path
# Add exceptions for linux home directory
$linux_home_dirs = @("\.nvm\versions", "\.cargo\bin")
$linux_home_dirs | ForEach { Add-MpPreference -ExclusionProcess ($linux_home_base_path + $_ + "\*") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment