Skip to content

Instantly share code, notes, and snippets.

@jsclifford
Last active December 19, 2025 16:35
Show Gist options
  • Select an option

  • Save jsclifford/ec47b07e4c5191c00ca7cd7551327503 to your computer and use it in GitHub Desktop.

Select an option

Save jsclifford/ec47b07e4c5191c00ca7cd7551327503 to your computer and use it in GitHub Desktop.
Setup Windows Workstation

Setup Windows Workstation

This goes through how to run scripts to setup all development tools on Windows Laptop.

Company Portal

Applications I installed through Company Portal

  • Visual Studio 2022
  • SQL Management Studio 20
  • Python
  • Powershell 7.5 (Do not install Powershell 7 it is broken)
  • Jetbrains Toolbox

Applications I installed Manually in Powershell 7 CLI

  • (If company portal can't install Powershell 7) Powershell 7.5 (Corporate App install is broken)
    • Download Powershell 7.5 and install in elevated powershell 5 window.
  • Git for windows (Setting Up Windows Open SSH Agent properly for git ssh key management)
    • Install Instructions are in setup-github-ssh-auth.md in this Gist
  • Visual Studio Code (To allow vscode in path and open with vscode)
    • I installed the User Profile version by downloading it here.
  • Docker Desktop (not in the Company Portal)

When downloading scripts from this gist you will have to unblock them by right clicking and selection properties. The unblock will be below the ReadOnly checkbox.

Steps

Follow the steps below in order.

  1. Install Git for Windows by following the setup-github-ssh-auth.md in this Gist
    • Copy .gitconfig to your user folder root
    • Run the github-packages-local-setup.ps1 script to be able to pull packages from our private github repos
  2. Install Powershell 7 (Should be in Company Portal)
  3. Run commands in setup-windows-workstation.ps1 in an elevated powershell window. This script has not been tested to run in fully in the shell but tested by running individual install commands.
  4. (Optional) Follow setup-wsl.md.
  5. (Optional) Install user logon task to set chrome as default browser at logon. Credit to Darren Keuffner for Creating it.
  6. (Optional) Log In with Azure Credentials in Visual Studio/VSCode to authenticate to Azure resources while running locally.
    • Follow Microsoft Docs
    • TLDR: Visual Studio
      • Launch Visual Studio Installer as Elevated Permissions
      • Modify Visual Studio Installation and Check Azure development Package under Web and Cloud Section
      • After Install Search for Azure Services in Tools > Options.
      • Login to your Azure Portal account.
  7. Changing Default Background from Default.
    • Replace File with same file extension and name with your own PNG or JPEG. Do not include any file extension, just the Name TranscodedWallpaper
    • ~\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper
[alias]
# Get the default branch for origin. This comes from StackOverflow
# https://stackoverflow.com/a/44750379 This makes it so while we transition
# away from using the "master" terminology the aliases work. The added
# benefit is that it should work for any default branch name, so if people
# use main, dev, develop, trunk, etc. the aliases should still function as
# expected.
#
# Also, this alias is here because you can do nested aliases in git now! I
# didn't realize that it was enabled in 2.20, so thanks again StackOverflow
# https://stackoverflow.com/a/52863852
def = !git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'
# Rebase the current branch off the default branch (see def above). You can
# also choose to pass in a branch name if you are trying to rebase from a
# different branch.
#
brebase = !sh -c 'def=$(git def) && git checkout ${1:-$def} && git fetch origin && git merge origin/${1:-$def} --ff-only && git checkout @{-1} && git rebase ${1:-$def}' -
# Pull the latest from upstream and push it to my fork at origin
updef = !def=$(git def) && git checkout $def && git fetch upstream && git merge upstream/$def --ff-only && git push origin HEAD
# Prune branches and delete any that are already merged into the default
# branch borrowed from here:
# https://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-have-been-merged
pbranch = !sh -c 'def=$(git def) && git checkout $def && git pull && git checkout - && git branch --merged | egrep -v "\\(^\\\\*\\|main\\)" | xargs git branch -d'
undocommit = !git reset --soft HEAD~1
squash = !git reset --soft main
[core]
editor = code --wait
[diff]
prompt = true
[difftool "vscode"]
cmd = code --wait --diff $LOCAL $REMOTE
keepBackup = false
[merge]
prompt = true
[mergetool "vscode"]
cmd = code --wait $MERGED
keepBackup = false
trustExitCode = true
# Run in Powershell 7
function NugetConfig {
$orgList = @("im-client", "im-customer-engagement", "im-enrollment", "im-funding", "im-platform", "im-practices")
$sourceRaw = dotnet nuget list source # Get the existing sources
# Grab all of the existing sources so it can be removed before the new value is added.
# Adding a package source when the key already exists causes errors to be thrown.
$sources = @()
$myMatches = ($sourceRaw | select-string -pattern '\d\.\s*(.*)\s\[' -AllMatches).Matches
if ($null -ne $myMatches) {
$sources = $myMatches | ForEach-Object { $_.Groups[1].Value }
}
foreach ($org in $orgList) {
if ($sources.Contains($org)) {
dotnet nuget remove source $org
}
dotnet nuget add source https://nuget.pkg.github.com/$org/index.json --name $org --username USERNAME --password %READ_PKG_TOKEN% --store-password-in-clear-text
}
setx READ_PKG_TOKEN $pat # windows
#export READ_PKG_TOKEN="ghp_your_pat_here" #linux. If this doesn't work it can be added to .bash_profile/.bashrc/.profile manually
}
function NpmConfig {
$orgList = @("im-client", "im-customer-engagement", "im-enrollment", "im-funding", "im-platform", "im-practices")
foreach ($org in $orgList)
{
# Add a scoped registry entry for each organization
$registry = ":registry"
npm set "@$org$registry" https://npm.pkg.github.com
}
setx READ_PKG_TOKEN $pat # windows
#export READ_PKG_TOKEN="ghp_your_pat_here" #linux. If this doesn't work it can be added to .bash_profile/.bashrc/.profile manually
# Set _authToken for github npm packages to the literal value: ${READ_PKG_TOKEN} which will pull value from env var
npm set //npm.pkg.github.com/:_authToken '${READ_PKG_TOKEN}'
}
$pat = Read-Host -Prompt "Github Read Packages Pat Token" -MaskInput
echo "Configuring Nuget"
NugetConfig
echo "Configuring NPM"
NpmConfig
echo ""
echo ""
echo ""
echo "Config Complete"
echo ""
echo " ----------------------------------------"
echo ""
echo "Nuget: Validate all github orgs show up."
dotnet nuget list source
echo "-----------------------------------------"
echo ""
echo ""
echo "NPM: Validate all github orgs show up."
npm config list
echo -n "Github Read Packages Pat Token:"
read -s PAT
if [[ -z $PAT ]]; then
echo 'Missing PAT paramater. Please provide PAT token.'
exit 1
fi
function nuget_config() {
orgList=("im-client" "im-customer-engagement" "im-enrollment" "im-funding" "im-platform" "im-practices" "im-open")
sourceRaw=$(dotnet nuget list source --format Short) # Get the existing sources
# Grab all of the existing sources so it can be removed before the new value is added.
# Adding a package source when the key already exists causes errors to be thrown.
sources=()
myMatches=$(echo $sourceRaw | grep 'nuget.pkg.github.com/im-' | sed 's/E//g')
myMatches=($myMatches)
if ((${#myMatches[@]})); then
i=0
for match in "${myMatches[@]}"; do
sources[$i]=$match
i=$(($i + 1))
done
fi
for org in "${orgList[@]}"; do
if printf '%s\n' "${sources[@]}" | grep $org; then
# echo "Removing nuget source: $org"
dotnet nuget remove source $org
fi
dotnet nuget add source https://nuget.pkg.github.com/$org/index.json --name $org --username USERNAME --password %READ_PKG_TOKEN% --store-password-in-clear-text
done
export READ_PKG_TOKEN=$PAT #linux. If this doesn't work it can be added to .bash_profile/.bashrc/.profile manually
}
function npm_config() {
orgList=("im-client" "im-customer-engagement" "im-enrollment" "im-funding" "im-platform" "im-practices")
for org in "${orgList[@]}"; do
# Add a scoped registry entry for each organization
echo "NPM Org: $org"
registry=":registry"
npm set "@$org$registry" https://npm.pkg.github.com
done
export READ_PKG_TOKEN=$PAT #linux. If this doesn't work it can be added to .bash_profile/.bashrc/.profile manually
# Set _authToken for github npm packages to the literal value: ${READ_PKG_TOKEN} which will pull value from env var
npm set //npm.pkg.github.com/:_authToken '${READ_PKG_TOKEN}'
}
echo "Configuring Nuget"
nuget_config
echo "Configuring NPM"
npm_config
echo ""
echo ""
echo ""
echo "Config Complete"
echo ""
echo " ----------------------------------------"
echo ""
echo "Nuget: Validate all github orgs show up."
dotnet nuget list source
echo ""
echo ""
echo "NPM: Validate all github orgs show up."
npm config list | grep @im
echo " ----------------------------------------"
echo ""
echo "Adding PAT Token to shell profile"
if [[ "$SHELL" == *"bash"* ]]; then
shell_file="$HOME/.profile"
elif [[ "$SHELL" == *"zsh"* ]]; then
shell_file="$HOME/.zprofile"
else
echo "Unknown shell type. Please add the following line to your shell profile: export READ_PKG_TOKEN=<Paste PAT Token Here>"
exit 1
fi
if [[ ! -f $shell_file ]]; then
echo "Shell profile not found. Creating new shell profile."
touch $shell_file
fi
does_token_exist=$(cat $shell_file | grep "READ_PKG_TOKEN")
if [[ $does_token_exist != "" ]]; then
echo "READ_PKG_TOKEN already exists in shell profile updating."
if [[ "$SHELL" == *"zsh"* ]]; then
sed -i '' "s/READ_PKG_TOKEN=.*/READ_PKG_TOKEN=$PAT/" $shell_file
else
sed -i "s/READ_PKG_TOKEN=.*/READ_PKG_TOKEN=$PAT/" $shell_file
fi
else
echo "export READ_PKG_TOKEN=$PAT" >>$shell_file
fi

Setup SSH Authentication for Git Bash on Windows

Gist Derived from here

Preparation

  1. Create a folder at the root of your user home folder (Example: C:/Users/uname/) called .ssh.
  2. Create the following files if they do not already exist (paths begin from the root of your user home folder):
    • .ssh/config
    • .profile
    • .bashrc
  3. (Obsolete) Update .ssh/config to have all ssh traffic to github.com route through 1 IP. Not required anymore
    • All Github.com IPs don't allow SSH through certain firewalls. You must pin github.com traffic to a specific IP.
    • Add this to Github Config
    Host *
        AddKeysToAgent yes
        IdentityFile ~/.ssh/id_ed25519
    Host github.com
        User git
  4. Install Git Bash and select option to use external ssh agent and windows secure channel for certificate management

Create a New SSH Key or Copy Current SSH Key

If you don't have a current SSH Key follow the steps in the section named "Generating a new SSH Key" found in the following documentation from GitHub: Generating a new SSH key and adding it to the ssh-agent. If you already have a key you need to copy your key and .pub file to from your old laptops .ssh folder to your new .ssh folder. Make sure your user is the only user allowed to read from the .pub and key file. If not ssh-add . will fail stating permission issues.

Enable Windows Open SSH Agent

  1. Install the latest Windows SSH Agent (Only Windows 10)
    # Required to run as Administrator in powershell
    winget install Microsoft.OpenSSH.Beta
    mkdir C:\tools
    cmd # Switch to command prompt
    mklink /D C:\tools\OpenSSH "C:\Program Files\OpenSSH"
    exti # To exit out of cmd and back into powershell
  2. Setup SSH Windows Service (Powershell)
    # Required to run as Administrator in powershell
    Get-Service ssh-agent | Set-Service -StartupType Automatic -PassThru | Start-Service
  3. Point Git to windows ssh agent. Run in Powershell (Windows 10)
    git config --global core.sshCommand C:/tools/OpenSSH/ssh.exe
    git config --system core.sshCommand C:/tools/OpenSSH/ssh.exe # As powershell admin
    
  4. Point Git to windows ssh agent. Run in Powershell (Windows 11)
    git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
    git config --system core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe # As powershell admin
    

Enable SSH Agent Startup Whenever Git Bash is Started

First, ensure that following lines are added to .bash_profile, which should be found in your root user home folder:

test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc

Now, add the following text to .profile, which should be found in your root user home folder:

export PATH="$HOME/.tfenv/bin:$PATH"
alias tf='terraform'
alias kb='kubectl'

# export SSH_AUTH_SOCK=~/.ssh/agent.env
env=~/.ssh/agent.env
export SSHAGENTARGS="-t 1h"

agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }

agent_start () {
    (umask 077; ssh-agent >| "$env")
    . "$env" >| /dev/null ; }

agent_load_env

# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)

if [ $agent_run_state = 2 ]; then
    agent_start
    ssh-add ~/.ssh/id_ed25519
elif [ $agent_run_state = 1 ]; then
    ssh-add ~/.ssh/id_ed25519
fi

unset env

Remove SSH Agent Key on logoff/logon

This is required if you want to re-auth your key on logon. Recommend for security purposes.

  1. Open Task Scheduler and create Basic task.
    • Name: Remove-SSH-Agent-Keys
    • Trigger: When I log on
    • Action: Start A Program
      • Program Script: "C:\Program Files\PowerShell\7\pwsh.exe"
      • Add Arguments (Optional): -ExecutionPolicy Bypass -Command "ssh-add -D"
    • Save defaults for everything else
# Developer Workstation Setup For Windows
# Required run in Powershell 7
# Run all commands or this script in an elevated powershell command prompt
# Script has not been tested to run all at once, but run each install individually.
#region Install Winget
# get latest download url
$URL = "https://api.github.com/repos/microsoft/winget-cli/releases/latest"
$URL = (Invoke-WebRequest -Uri $URL).Content | ConvertFrom-Json |
Select-Object -ExpandProperty "assets" |
Where-Object "browser_download_url" -Match '.msixbundle' |
Select-Object -ExpandProperty "browser_download_url"
# download
Invoke-WebRequest -Uri $URL -OutFile "Setup.msix" -UseBasicParsing
# install
Add-AppxPackage -Path "Setup.msix"
# delete file
Remove-Item "Setup.msix"
winget --version
# Fix winget sources.
Add-AppxPackage -Path https://cdn.winget.microsoft.com/cache/source.msix
#endregion
# Install Powershell 7 if not in Company Portal
winget install --id Microsoft.PowerShell
# Install Chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Install Go Lang
choco install golang
#region Install tenv for terraform https://github.com/tofuutils/tenv
go install github.com/sigstore/cosign/v2/cmd/cosign@latest
choco install tenv
# Run in regular
tenv completion powershell | Out-String | Invoke-Expression
# run in git bash
tenv completion bash > ~/.tenv.completion.bash
echo "source \$HOME/.tenv.completion.bash" >> ~/.profile
#endregion
# Install terraformdocs https://github.com/terraform-docs/terraform-docs
choco install terraform-docs
# Install Dotnet
winget install Microsoft.DotNet.SDK.9
dotnet --list-sdks
# Install Azure CLI
winget install --exact --id Microsoft.AzureCLI
# Install Node
choco install nodejs.install
node -v
npm -v
# Setup Nodejs Options in .profile in git bash or wsl
# Setup Node.js Options in PowerShell
$profilePath = "$HOME\.profile"
if (-not (Test-Path $profilePath)) {
New-Item -ItemType File -Path $profilePath -Force | Out-Null
}
$nodeOptionsLine = 'export NODE_OPTIONS=--use-openssl-ca'
$profileContent = Get-Content -Path $profilePath -ErrorAction SilentlyContinue
if ($profileContent -notcontains $nodeOptionsLine) {
Add-Content -Path $profilePath -Value $nodeOptionsLine -Append
Write-Host "NODE_OPTIONS added to .profile"
} else {
Write-Host "NODE_OPTIONS is already in .profile"
}
# Source the profile (equivalent to `. ~/.profile` in Bash)
if (Test-Path $profilePath) {
. $profilePath
}
# Install Docker
# Download and install docker desktop from https://www.docker.com/products/docker-desktop/
# Enable WSL2 first by following setup-wsl.md
# Install VSCode
winget install Microsoft.VisualStudioCode
# Install Postman
choco install postman
# Install K6
winget install k6 --source winget
k6 --version
# Install kubectl
winget install -e --id Kubernetes.kubectl
kubectl version --client
# Run in Git Bash
command_in_profile=$(cat ~/.profile | grep "kb='kubectl'")
if [[ $command_in_profile == "" ]]; then
echo "alias kb='kubectl'" >>~/.profile
fi
winget install --id=Microsoft.Azure.Kubelogin -e
# Or install from Azure cli
az aks install-cli
# Helm
winget install Helm.Helm
# Yaml FMT
go install github.com/google/yamlfmt/cmd/yamlfmt@latest
# Install Active Directory Users and Computers
# Open Elevated Command Prompt
Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0
Install-WindowsFeature RSAT-AD-PowerShell
# Setting up NPM and Nuget Github Packages for im-orgs
# Run the shell version in wsl
./github-packages-local-setup.ps1
# Install mktp-local-gateway ca cert as trusted certificate
# Run this in an regular user powershell command prompt
Write-Host "Copy raw url from your browser by navigating to github.com to ca cert file."
$certPath = "./ca.crt"
$certUrl = Read-Host -Prompt "Add Raw URL for https://github.com/im-enrollment/mktp-web-local-gateway/blob/main/src/Mktp.Web.LocalGateway/certs/ca.crt"
Invoke-WebRequest -Uri $certUrl -OutFile $certPath
$certImportParams = @{
FilePath = $certPath
CertStoreLocation = 'Cert:\CurrentUser\Root'
}
Import-Certificate @certImportParams
Remove-Item $certPath
# Setup SSH Agent Run in Git Bash
$sshAgent = @'
command_in_profile=$(cat ~/.profile | grep '.ssh/agent.env')
if [[ $command_in_profile == "" ]]; then
ssh_agent_commands=$(
cat <<EOF
env=~/.ssh/agent.env
export SSHAGENTARGS="-t 1h"
agent_load_env() { test -f "$env" && . "$env" >|/dev/null; }
agent_start() {
(
umask 077
ssh-agent >|"$env"
)
. "$env" >|/dev/null
}
agent_load_env
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
agent_run_state=$(
ssh-add -l >|/dev/null 2>&1
echo $?
)
if [ $agent_run_state = 2 ]; then
agent_start
ssh-add ~/.ssh/id_ed25519
elif [ $agent_run_state = 1 ]; then
ssh-add ~/.ssh/id_ed25519
fi
unset env
EOF
)
echo "$ssh_agent_commands" >>~/.profile
else
echo "SSH Agent commands are already in .profile"
fi
'@
Write-Output "$sshAgent" | Out-File -FilePath ~/.profile -Append -Encoding utf8

Setup WSL for development environment in powershell (Optional)

# Enabled WSL
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart

# Most likely you will have to restart computer for wsl --status to return anything.
wsl --status # Determine if you are on version 2
wsl --set-default-version 2 # If not already.
wsl --install --distribution ubuntu

Inside WSL CLI

echo "Disable path sharing between windows"
sudo touch /etc/wsl.conf
echo """

[interop]
appendWindowsPath = false

# Not required anymore but here for historical purposes
# [network]
# generateResolvConf = true # was false but found workaround

""" | sudo tee -a /etc/wsl.conf

# Follow instructions for wsl-vpnkit https://github.com/sakai135/wsl-vpnkit

# Reboot WSL After this is done
# Run in Powershell Window:
wsl --shutdown

echo "Setup Bash"
echo """
test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc
""" | tee -a ~/.bash_profile

sudo install -m 0755 -d /etc/apt/keyrings

echo "Updating to Git repo"
sudo add-apt-repository ppa:git-core/ppa
sudo apt update; sudo apt install git -y

echo "Installing dotnet"

wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0

echo ""
echo "Installing JQ"
sudo apt-get install jq -y

echo ""
echo "Installing pwsh"
sudo apt-get update
sudo apt-get install -y wget apt-transport-https software-properties-common
sudo apt-get update
sudo apt-get install -y powershell
pwsh -v

echo ""
echo "Installing Go"
sudo apt install -y golang
echo 'export PATH=$(go env GOPATH)/bin:$PATH' | tee -a ~/.profile
echo 'export GOPATH=$(go env GOPATH)/bin' | tee -a ~/.profile


echo ""
echo "Installing GVM - Go Lang Version Manager"
sudo apt-get install -y bison
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
# echo "Add this line to ~/.bash_profile"
# echo """
# export GVM_ROOT=/opt/gvm
# . $GVM_ROOT/scripts/gvm-default
# [[ -s “$GVM_ROOT/scripts/gvm” ]] && source “$GVM_ROOT/scripts/gvm”
# """ | tee -a ~/.profile

source ~/.bash_profile
sudo chown root:$USER -R /opt/gvm
sudo chmod g+rwx -R /opt/gvm
gvm install go1.19.3
gvm use go1.19.3

# tfenv deprecated.
# echo ""
# echo "Installing TF ENV"
# git clone --depth=1 https://github.com/tfutils/tfenv.git ~/.tfenv
# echo 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bash_profile
# echo 'export PATH="$HOME/.tfenv/bin:$PATH"' | tee -a ~/.profile
# sudo ln -s ~/.tfenv/bin/* /usr/local/bin
# sudo apt install -y unzip

echo ""
echo "Installing T ENV TFENV replacement"
echo "Repository with instructions: https://github.com/tofuutils/tenv"
choco install tenv

echo ""
echo "Installing Nodejs LTS"
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs
node -v

echo ""
echo "Installing Nodejs Version manager"
export NVS_HOME="$HOME/.nvs"
git clone https://github.com/jasongin/nvs "$NVS_HOME"
. "$NVS_HOME/nvs.sh" install
echo 'export NVS_HOME="$HOME/.nvs"' | tee -a ~/.profile

echo ""
echo "Installing Azure CLI"
sudo apt-get update
sudo apt-get install -y ca-certificates curl apt-transport-https lsb-release gnupg
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list
sudo apt-get update
sudo apt-get install -y azure-cli
az version

echo ""
echo "Installing kubectl"
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
kubectl version

echo ""
echo "Installing Hashicorp Vault and packer"
curl https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update
sudo apt install -y vault packer
vault --version

echo ""
echo "Installing sqlcmd"
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo apt-get update
export ACCEPT_EULA=Y 
sudo apt-get install -y mssql-tools unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' | tee -a ~/.profile
source ~/.bash_profile

# Install influxdb cli
echo ""
echo "Installing influxdb cli"
echo "deb https://repos.influxdata.com/ubuntu focal stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y influxdb2-cli

echo ""
echo "Installing k6"
echo "Setup GPG for root"
sudo gpg --gen-key
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install -y k6

echo ""
echo "Installing xk6"
go install go.k6.io/xk6/cmd/xk6@latest

echo ""
echo "Adding VSCode windows path to ~/.profile"
echo """

export PATH=\"/mnt/c/Program Files/Microsoft VS Code/bin:\$PATH\"

""" | tee -a ~/.profile

echo ""
echo "Adding bash Alias"
echo """

alias tf='terraform'
alias kb='kubectl'

""" | tee -a ~/.profile

echo "Setting up SSH agent"
mkdir ~/.ssh
chmod  0700 ~/.ssh
echo '''

env=~/.ssh/agent.env

agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }

agent_start () {
    (umask 077; ssh-agent >| "$env")
    . "$env" >| /dev/null ; }

agent_load_env

# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2=agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)

if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
    agent_start
    ssh-add ~/.ssh/id_ed25519
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
    ssh-add ~/.ssh/id_ed25519
fi

unset env

''' | tee -a ~/.profile

echo "Add Git Update Fork script"
cat <<EOF | tee -a ~/.gitconfig
[user]
	name = <Your Name Here>
	email = <Your Github user email here>
[alias]
  # Get the default branch for origin. This comes from StackOverflow
  # https://stackoverflow.com/a/44750379 This makes it so while we transition
  # away from using the "master" terminology the aliases work. The added
  # benefit is that it should work for any default branch name, so if people
  # use main, dev, develop, trunk, etc. the aliases should still function as
  # expected.
  #
  # Also, this alias is here because you can do nested aliases in git now! I
  # didn't realize that it was enabled in 2.20, so thanks again StackOverflow
  # https://stackoverflow.com/a/52863852
  def = !git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'

  # Rebase the current branch off the default branch (see def above). You can
  # also choose to pass in a branch name if you are trying to rebase from a
  # different branch.
  #
  brebase = !sh -c 'def=$(git def) && git checkout \${1:-\$def} && git fetch origin && git merge origin/\${1:-\$def} --ff-only && git checkout @{-1} && git rebase \${1:-\$def}' -

  # Pull the latest from upstream and push it to my fork at origin
  updef = !def=$(git def) && git checkout \$def && git fetch upstream && git merge upstream/\$def --ff-only && git push origin HEAD

  # Prune branches and delete any that are already merged into the default
  # branch borrowed from here:
  # https://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-have-been-merged
  pbranch = !sh -c 'def=$(git def) && git checkout \$def && git pull && git checkout - && git branch --merged | egrep -v "\\\\(^\\\\\\\\*\\\\|main\\\\)" | xargs git branch -d'
  
  undocommit = !git reset --soft HEAD~1

  squash = !git reset --soft main

EOF

echo "Restart Ubuntu WSL by running command in windows powershell"
echo "wsl --shutdown"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment