Skip to content

Instantly share code, notes, and snippets.

@kensleDev
Last active March 28, 2023 14:27
Show Gist options
  • Save kensleDev/0ac20b2dff6d856404c3d332aaf50f6d to your computer and use it in GitHub Desktop.
Save kensleDev/0ac20b2dff6d856404c3d332aaf50f6d to your computer and use it in GitHub Desktop.
# Dependancies
Invoke-WebRequest -Uri "https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx" -OutFile "~\Downloads\VCLibs.appx"
Add-AppxPackage -Path "~\Downloads\VCLibs.appx"
# chocolatey - needed for apps that can't be installed via scoop (terminal)
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'))
choco install -y git powershell-core microsoft-windows-terminal
# font install
mkdir ~/.config/fonts
Invoke-WebRequest -Uri "https://gist.githubusercontent.com/kensleDev/0ac20b2dff6d856404c3d332aaf50f6d/raw/d51ca76af03d122e48408d53113f53e1827de9e9/nerd-font-install.ps1" -OutFile "~\.config\fonts\nerd-font-install.ps1"
Invoke-WebRequest -Uri "https://gist.githubusercontent.com/kensleDev/0ac20b2dff6d856404c3d332aaf50f6d/raw/f276f1cde53c1ccb5876bbe0c5affd93407c9de4/font-dir-install.ps1" -OutFile "~\.config\fonts\font-dir-install.ps1"
powershell "~/.config/fonts/nerd-font-install.ps1"
# Setup Powershell
mkdir ~/.config/powershell
New-Item -Type File -Force $PROFILE
". ~/.config/powershell/profile.ps1" >> $PROFILE
Invoke-WebRequest -Uri 'https://gist.githubusercontent.com/kensleDev/0ac20b2dff6d856404c3d332aaf50f6d/raw/d3864d3711e37e840a0b3c6ac4e467772b37e9f1/powershell-setup.ps1' -OutFile '~\.config\powershell\install.ps1'
Invoke-WebRequest -Uri 'https://gist.githubusercontent.com/kensleDev/0ac20b2dff6d856404c3d332aaf50f6d/raw/a143a7828ab0a49d75af0974a737164bd7c17fad/powershell-profile.ps1' -OutFile '~\.config\powershell\profile.ps1'
Invoke-WebRequest -Uri 'https://gist.githubusercontent.com/kensleDev/0ac20b2dff6d856404c3d332aaf50f6d/raw/3c7d03f26f69393cd19721e829135b8c6cb25c2b/takuya.omp.json' -OutFile '~\.config\powershell\takuya.omp.json'
powershell "~/.config/powershell/install.ps1"

Install

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'))
choco install -y git

Reopen Powerhshell

git clone https://github.com/julian-iaquinandi/dotfiles.git
Set-ExecutionPolicy -s cu unrestricted -Force
./dotfiles/windows-install/.config/windows-install/install.ps1

Open Powershell

New-Item -Type File -Force $PROFILE
". ~/.config/powershell/profile.ps1" >> $PROFILE
pwsh

Wait for modules to install

Install desktop apps

choco install -y vscode gh microsoft-windows-terminal wsl-ubuntu-2204
echo "Install fonts"
$fonts = (New-Object -ComObject Shell.Application).Namespace(0x14)
foreach ($file in gci *.ttf)
{
$fileName = $file.Name
if (-not(Test-Path -Path "C:\Windows\fonts\$fileName" )) {
echo $fileName
dir $file | %{ $fonts.CopyHere($_.fullname) }
}
}
cp *.ttf c:\windows\fonts\
# Install nerd font from https://www.nerdfonts.com/font-downloads
$fontName = "AnonymousPro"
Invoke-WebRequest -Uri "https://gist.githubusercontent.com/kensleDev/0ac20b2dff6d856404c3d332aaf50f6d/raw/f276f1cde53c1ccb5876bbe0c5affd93407c9de4/font-dir-install.ps1" -OutFile "~\Downloads\font-dir-install.ps1"
Invoke-WebRequest -Uri "https://github.com/ryanoasis/nerd-fonts/releases/download/v2.2.2/$fontName.zip" -OutFile "~\Downloads\$fontName.zip"
cd ~\Downloads
Expand-Archive "~\Downloads\$fontName.zip"
cd "~\Downloads\$fontName"
powershell ~\Downloads\font-dir-install.ps1
cd ~\Downloads
rm -r "~\Downloads\$fontName"
# set PowerShell to UTF-8
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
Import-Module posh-git
Import-Module -Name Terminal-Icons
Import-Module PSFzf
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+f' -PSReadlineChordReverseHistory 'Ctrl+r'
Set-PSReadLineOption -EditMode Emacs
Set-PSReadLineOption -BellStyle None
Set-PSReadLineKeyHandler -Chord 'Ctrl+d' -Function DeleteChar
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
cd C:\Users\WDAGUtilityAccount\AppData\Local\Programs\oh-my-posh\bin
.\oh-my-posh init pwsh --config ~/.config/powershell/takuya.omp.json | Invoke-Expression
# Aliases
# General
Set-Alias c clear
Set-Alias l ls
# Files/Locations
function .. { cd .. }
function home { cd $env:USERPROFILE }
function ~ { cd ~ }
function dl { cd $env:USERPROFILE\Downloads }
function docs { cd $env:USERPROFILE\Documents }
# Programs
Set-Alias grep findstr
Set-Alias v nvim
# Git
Set-Alias g git
function ga { git add -A }
function gc { git commit }
function gac { git add -A; git commit }
# Utilities
function which ($command) {
Get-Command -Name $command -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue
}
Set-ExecutionPolicy -s cu unrestricted
$OS_Installer = 'scoop'
if ($IsMacOS) {
$OS_Installer = 'brew'
} elseif ($IsWindows) {
$OS_Installer = 'scoop'
} else {
echo 'OS NOT SUPPORTED!'
}
function InstallInstaller($Installer) {
if (Get-Command $Installer -errorAction SilentlyContinue) {
"-> $Installer Installed"
} else {
if($Installer -eq 'scoop') {
iex "& {$(irm get.scoop.sh)} -RunAsAdmin"
} elseif($Installer -eq 'brew') {
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
} else {
echo 'Installer NOT SUPPORTED!'
}
}
}
function UpdatePowershellConfigLocation {
$configLocation = ". $env:USERPROFILE\.config\powershell\profile.ps1"
$configLocation | Out-File $PROFILE
}
function InstallProgram($program) {
$cmd = $OS_Installer + ' install ' + $program
Invoke-Expression $cmd
echo 'Installed: ' $program
}
function InstallModules {
Install-Module posh-git -Scope CurrentUser -Force
# Install-Module -Name z -Force
Install-Module PSReadline -Force
Install-Module PSFzf -Scope CurrentUser -Force
Install-Module Terminal-Icons -Scope CurrentUser -Force
}
function InstallPrograms {
InstallProgram('https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json')
# InstallProgram('git')
# InstallProgram('z')
InstallProgram('fzf')
InstallProgram('nvm')
}
UpdatePowershellConfigLocation
InstallInstaller($OS_Installer)
InstallPrograms
InstallModules
Install-Module nvm
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"background": "#0077c2",
"foreground": "#ffffff",
"leading_diamond": "\u256d\u2500\ue0b6",
"style": "diamond",
"template": " {{ .Name }} ",
"type": "shell"
},
{
"background": "#ef5350",
"foreground": "#FFFB38",
"properties": {
"root_icon": "\uf292"
},
"style": "diamond",
"template": "<parentBackground>\ue0b0</> \uf0e7 ",
"type": "root"
},
{
"background": "#444444",
"foreground": "#E4E4E4",
"powerline_symbol": "\ue0b0",
"properties": {
"style": "full"
},
"style": "powerline",
"template": " {{ .Path }} ",
"type": "path"
},
{
"background": "#FFFB38",
"background_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}#ffeb95{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}#c5e478{{ end }}",
"{{ if gt .Ahead 0 }}#C792EA{{ end }}",
"{{ if gt .Behind 0 }}#C792EA{{ end }}"
],
"foreground": "#011627",
"powerline_symbol": "\ue0b0",
"properties": {
"branch_icon": "\ue725 ",
"fetch_status": true,
"fetch_upstream_icon": true
},
"style": "powerline",
"template": " {{ .HEAD }} {{ if .Working.Changed }}{{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }}<#ef5350> \uf046 {{ .Staging.String }}</>{{ end }} ",
"type": "git"
}
],
"type": "prompt"
},
{
"alignment": "right",
"segments": [
{
"background": "#303030",
"foreground": "#3C873A",
"leading_diamond": " \ue0b6",
"properties": {
"fetch_package_manager": true,
"npm_icon": " <#cc3a3a>\ue5fa</> ",
"yarn_icon": " <#348cba>\uf61a</>"
},
"style": "diamond",
"template": "\ue718 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }}",
"trailing_diamond": "\ue0b4",
"type": "node"
},
{
"background": "#40c4ff",
"foreground": "#ffffff",
"invert_powerline": true,
"leading_diamond": " \ue0b6",
"style": "diamond",
"template": " \uf5ef {{ .CurrentDate | date .Format }} ",
"trailing_diamond": "\ue0b4",
"type": "time"
}
],
"type": "prompt"
},
{
"alignment": "left",
"newline": true,
"segments": [
{
"foreground": "#21c7c7",
"style": "plain",
"template": "\u2570\u2500",
"type": "text"
},
{
"foreground": "#e0f8ff",
"foreground_templates": [
"{{ if gt .Code 0 }}#ef5350{{ end }}"
],
"properties": {
"always_enabled": true
},
"style": "plain",
"template": "\u276f{{ if gt .Code 0 }}\uf00d{{ else }}\uf42e{{ end }} ",
"type": "exit"
}
],
"type": "prompt"
}
],
"osc99": true,
"version": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment