### Initialize Windows Dotfiles Installation Source: https://github.com/erelado/dotfiles-windows/blob/main/README.md This PowerShell script initializes the dotfiles setup by downloading and executing the main installation script. It requires administrator rights and sets the execution policy to bypass for the current process. The script fetches `Download.ps1` from a specified GitHub repository and then automatically runs `Setup.ps1` for configuration. ```powershell $GitHubRepositoryAuthor = "erelado"; \ $GitHubRepositoryName = "dotfiles-windows"; \ Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass; \ Invoke-Expression (Invoke-RestMethod -Uri "https://raw.githubusercontent.com/$($GitHubRepositoryAuthor)/$($GitHubRepositoryName)/main/Download.ps1"); ``` -------------------------------- ### Install Applications using Winget (PowerShell) Source: https://context7.com/erelado/dotfiles-windows/llms.txt A PowerShell function to install applications using Windows Package Manager (winget). It supports specifying application name, ID, source (winget or msstore), version, and custom installation parameters. ```powershell function Install-WingetApp { Param( [Parameter(Mandatory = $TRUE)] [String]$AppName, [Parameter(Mandatory = $TRUE)] [String]$AppId, [Parameter(Mandatory = $FALSE)] [String]$Source = "winget", [Parameter(Mandatory = $FALSE)] [String]$Version, [Parameter(Mandatory = $FALSE)] [String]$Parameters ) } # Install 7-Zip from winget Install-WingetApp -AppName "7-Zip" -AppId "7zip.7zip" -Source "winget" # Install PowerToys from Microsoft Store Install-WingetApp -AppName "PowerToys" -AppId "XP89DCGQ3K6VLD" -Source "msstore" # Install specific version of Docker Desktop Install-WingetApp -AppName "Docker Desktop" -AppId "Docker.DockerDesktop" -Version "4.20.0" # Install Visual Studio Code with custom parameters Install-WingetApp -AppName "Visual Studio Code" -AppId "Microsoft.VisualStudioCode" -Parameters "/SILENT /MERGETASKS=!runcode" ``` -------------------------------- ### Manual Setup Execution for Dotfiles Windows Source: https://context7.com/erelado/dotfiles-windows/llms.txt Executes the setup script after manually downloading or cloning the Dotfiles Windows repository. This script handles module loading, winget verification, administrator elevation, configuration generation, and applying settings. ```powershell # Navigate to dotfiles directory Set-Location "${HOME}\.dotfiles" # Execute the setup script .\Setup.ps1 # The script will: # 1. Load all helper modules and functions # 2. Verify winget is installed # 3. Elevate to Administrator if needed # 4. Generate/load config.json through interactive prompts # 5. Apply configurations based on user selections ``` -------------------------------- ### Remote Installation of Dotfiles Windows Source: https://context7.com/erelado/dotfiles-windows/llms.txt Downloads and executes the remote installation script for the Dotfiles Windows framework. Requires PowerShell 5.1+ and Administrator rights. It fetches the installation script from GitHub and runs it. ```powershell # Run in PowerShell 5.1+ with Administrator rights $GitHubRepositoryAuthor = "erelado" $GitHubRepositoryName = "dotfiles-windows" Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass Invoke-Expression (Invoke-RestMethod -Uri "https://raw.githubusercontent.com/$($GitHubRepositoryAuthor)/$($GitHubRepositoryName)/main/Download.ps1") ``` -------------------------------- ### Install VSCode Extensions Source: https://context7.com/erelado/dotfiles-windows/llms.txt Installs a curated list of Visual Studio Code extensions to enhance the development experience. This script requires the 'code' command to be available in the system's PATH. ```powershell function Install-VSCodeExtensions { # Formatting and Rules code --install-extension "aaron-bond.better-comments" code --install-extension "esbenp.prettier-vscode" code --install-extension "streetsidesoftware.code-spell-checker" # Tools code --install-extension "ritwickdey.LiveServer" code --install-extension "tabnine.tabnine-vscode" # IDE Themes code --install-extension "PKief.material-icon-theme" code --install-extension "zhuangtongfa.material-theme" # Language Support code --install-extension "ms-vscode.powershell" code --install-extension "hashicorp.terraform" code --install-extension "redhat.vscode-yaml" } # Install all VS Code extensions Install-VSCodeExtensions ``` -------------------------------- ### Install PowerShell Modules (PowerShell) Source: https://context7.com/erelado/dotfiles-windows/llms.txt A PowerShell function to install PowerShell modules from specified repositories like PSGallery. It supports forcing reinstallation and requires module name and repository as parameters. ```powershell function Install-PowerShellModule { param ( [Parameter(Position = 0, Mandatory = $TRUE)] [String]$Name, [Parameter(Position = 1, Mandatory = $TRUE)] [String]$Repository, [Parameter(Position = 2, Mandatory = $FALSE)] [switch]$Force ) } # Install posh-git for Git integration Install-PowerShellModule -Name "posh-git" -Repository "PSGallery" # Install Terminal-Icons for file icons in terminal Install-PowerShellModule -Name "Terminal-Icons" -Repository "PSGallery" # Force reinstall PSReadLine for command-line editing Install-PowerShellModule -Name "PSReadLine" -Repository "PSGallery" -Force # Install z for directory jumping Install-PowerShellModule -Name "z" -Repository "PSGallery" ``` -------------------------------- ### Define Winget Applications and Configuration Classes Source: https://context7.com/erelado/dotfiles-windows/llms.txt Defines the WingetApp and WingetConfiguredApp classes to manage software installation sources and post-installation settings. These classes facilitate the declaration of tools like PowerToys, DevOps utilities, and complex configurations for Git, VS Code, and PowerShell. ```powershell $PowerToys = [WingetApp]::New( 'PowerToys', [ordered]@{ 'msstore' = 'XP89DCGQ3K6VLD'; 'winget' = 'Microsoft.PowerToys'; } ) $DevOpsTools = @( [WingetApp]::New('AWS CLI', [ordered]@{ winget = 'Amazon.AWSCLI'; }), [WingetApp]::New('Azure CLI', [ordered]@{ winget = 'Microsoft.AzureCLI'; }), [WingetApp]::New('Docker Desktop', [ordered]@{ winget = 'Docker.DockerDesktop'; }), [WingetApp]::New('kubectl', [ordered]@{ winget = 'Kubernetes.kubectl'; }), [WingetApp]::New('MobaXterm', [ordered]@{ winget = 'Mobatek.MobaXterm'; }) ) class WingetConfiguredApp : WingetApp { [hashtable]$Configurations WingetConfiguredApp( [string]$Name, [hashtable]$Sources, [hashtable]$Configurations ) : base($Name, $Sources) { $this.Configurations = $Configurations } } [WingetConfiguredApp]::New( 'Git', [ordered]@{ winget = 'Git.Git' }, @{ Globals = @{ User_Name = "John Doe"; User_Email = "john@example.com"; } } ) ``` -------------------------------- ### PowerShell Aliases for Kubernetes (kubectl) Source: https://context7.com/erelado/dotfiles-windows/llms.txt Defines aliases for common kubectl commands to streamline Kubernetes cluster management. Includes shortcuts for getting pods, listing all pods across namespaces, viewing logs, applying configurations, and deleting resources. ```powershell Set-Alias -Name "k" -Value "kubectl" Set-Alias -Name "kgp" -Value "Invoke-K8sGetPod" # kubectl get pod Set-Alias -Name "kgpa" -Value "Invoke-K8sListPods" # kubectl get pods --all-namespaces Set-Alias -Name "klp" -Value "Invoke-K8sWatchPodLogs" # kubectl logs --follow Set-Alias -Name "ka" -Value "Invoke-K8sApply" # kubectl apply -f Set-Alias -Name "kd" -Value "Invoke-K8sDelete" # kubectl delete -f ``` -------------------------------- ### Create Configuration File (PowerShell) Source: https://context7.com/erelado/dotfiles-windows/llms.txt Generates a `config.json` file interactively for customizing Dotfiles Windows setup. Users can select application groups, OS settings, and shell configurations. Supports overriding an existing configuration file. ```powershell function New-ConfigurationFile { param( [Parameter(Mandatory = $FALSE)] [bool]$Override = $FALSE ) } # Generate new configuration (interactive prompts) New-ConfigurationFile # Override existing configuration New-ConfigurationFile -Override $TRUE # Generated config.json structure: # { # "Applications": { # "BasicTools": [...], # "DevOpsTools": [...], # "OtherApps": [...] # }, # "OS": { # "Windows": {...} # }, # "Shell": { # "PowerShell": {...} # } # } ``` -------------------------------- ### WingetApp Class Definition (PowerShell) Source: https://context7.com/erelado/dotfiles-windows/llms.txt Defines a PowerShell class `WingetApp` to represent applications installable via winget. It includes properties for name, installation status, sources (hashtable), and the selected source. ```powershell class WingetApp { [string]$Name [bool]$Install [hashtable]$Sources [string]$SelectedSource WingetApp([string]$Name, [hashtable]$Sources) { $this.Name = $Name $this.Sources = $Sources } } ``` -------------------------------- ### Automate Winget Upgrades with Shortcut Cleanup Source: https://context7.com/erelado/dotfiles-windows/llms.txt Upgrades all installed packages via Winget and automatically removes any new desktop shortcuts created during the process. This keeps the desktop clean after bulk updates. ```powershell function Use-WingetUpgradeAllRemoveGeneratedShortcuts { $DesktopPath = "${HOME}\Desktop" $PreUpgrade = Get-ChildItem -Path $DesktopPath -Include "*.lnk", "*.url" -File -Recurse winget upgrade --all $PostUpgrade = Get-ChildItem -Path $DesktopPath -Include "*.lnk", "*.url" -File -Recurse $PostUpgrade | Where-Object { $PreUpgrade -NotContains $_ } | Remove-Item } ``` -------------------------------- ### PowerShell Aliases for Docker Management Source: https://context7.com/erelado/dotfiles-windows/llms.txt Provides shortcuts for frequently used Docker commands to simplify container and image management. Includes aliases for pulling images, listing containers and images, stopping and removing containers, and removing images. ```powershell Set-Alias -Name "dpl" -Value "Invoke-DockerPull" # docker pull Set-Alias -Name "dlc" -Value "Invoke-DockerListWorkingContainers" # docker container ls Set-Alias -Name "dlca" -Value "Invoke-DockerListContainers" # docker container ls -a Set-Alias -Name "dli" -Value "Invoke-DockerImages" # docker images Set-Alias -Name "dsc" -Value "Invoke-DockerStopContainer" # docker container stop Set-Alias -Name "drc" -Value "Invoke-DockerDeleteContainer" # docker container rm Set-Alias -Name "dri" -Value "Invoke-DockerDeleteImage" # docker image rm # Clean up unused Docker resources function Remove-DockerUnused { param ([switch]$Volumes) docker container prune -f docker rmi $(docker images --filter "dangling=true" -q --no-trunc) if ($Volumes) { docker volume prune -f } } Set-Alias -Name "dclean" -Value "Remove-DockerUnused" # Usage dclean # Clean containers and images dclean -v # Also clean volumes ``` -------------------------------- ### PowerShell Aliases for Git Operations Source: https://context7.com/erelado/dotfiles-windows/llms.txt Defines convenient aliases for common Git commands to streamline workflow. Includes shortcuts for cloning repositories with submodules, staging files, checking status, committing, pushing, creating branches, and viewing commit logs. ```powershell # Super clone with submodules function Invoke-GitSuperClone { param ([String]$RepositoryName) $DirectoryName = $RepositoryName.Split("/")[-1].Replace(".git", "") git clone $RepositoryName $DirectoryName Set-Location $DirectoryName git submodule init git submodule update } Set-Alias -Name "gsc" -Value "Invoke-GitSuperClone" # Usage gsc "https://github.com/user/repo.git" # Common Git operations Set-Alias -Name "ga" -Value "Invoke-GitAdd" # git add Set-Alias -Name "gaa" -Value "Invoke-GitAddAll" # git add --all Set-Alias -Name "gst" -Value "Invoke-GitStatus" # git status Set-Alias -Name "gcmsg" -Value "Invoke-GitCommitMessage" # git commit -m Set-Alias -Name "ggp" -Value "Invoke-GitPushOriginCurrentBranch" # git push origin HEAD Set-Alias -Name "gcb" -Value "Invoke-GitCheckoutBranch" # git checkout -b Set-Alias -Name "glg" -Value "Invoke-GitLogStat" # git log --stat # Workflow example ga "src/app.js" gcmsg "Add new feature" ggp ``` -------------------------------- ### Configure Git Global Settings Source: https://context7.com/erelado/dotfiles-windows/llms.txt A helper function to apply standard Git global configurations, such as user identity, default branch, and editor preferences. ```powershell function Set-GitConfiguration { param ( [Parameter(Position = 0, Mandatory = $TRUE)] [String]$UserName, [Parameter(Position = 1, Mandatory = $TRUE)] [String]$UserEmail ) } Set-GitConfiguration -UserName "John Doe" -UserEmail "john@example.com" ``` -------------------------------- ### Manage Kubernetes Manifests and Pods with PowerShell Source: https://context7.com/erelado/dotfiles-windows/llms.txt Provides shorthand aliases for applying and deleting Kubernetes manifests using kubectl. Includes an interactive shell function to access pods by name. ```powershell Set-Alias -Name "ka" -Value "kubectl apply -f" Set-Alias -Name "kd" -Value "kubectl delete -f" function Invoke-K8sInteractive { param ([String]$PodName) kubectl exec --stdin --tty $PodName -- /bin/sh } Set-Alias -Name "ki" -Value "Invoke-K8sInteractive" ``` -------------------------------- ### Retrieve Network and System Information Source: https://context7.com/erelado/dotfiles-windows/llms.txt Utility functions to fetch local and public IP addresses, as well as system uptime. These functions leverage CIM and REST requests to provide quick diagnostic data. ```powershell function Get-IPs { Get-NetIPAddress | Where-Object { $_.AddressState -eq "Preferred" } | Sort-object IPAddress | Format-Table -Wrap -AutoSize } function Get-LocalIP { $IPAddress = Get-CimInstance Win32_NetworkAdapterConfiguration | Where-Object { $_.Ipaddress.length -gt 1 } Write-Host $IPAddress.ipaddress[0] } function Get-PublicIP { Invoke-RestMethod http://ipinfo.io/json | Select-Object -exp ip } function Get-Uptime { Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object CSName, LastBootUpTime } ``` -------------------------------- ### Format Dates and Timestamps Source: https://context7.com/erelado/dotfiles-windows/llms.txt A collection of date utilities that support ISO-8601 formatting, UTC conversion, Unix timestamps, and ISO-9601 week numbers. These functions accept an optional date string or default to the current time. ```powershell function Get-DateExtended { param ([String]$Date); $d = if ($Date) { Get-Date $Date } else { Get-Date }; Get-Date $d -Format "yyyy-MM-ddTHH:mm:ss" } function Get-DateExtendedUTC { param ([String]$Date); $d = if ($Date) { Get-Date $Date } else { Get-Date }; ($d).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss") } function Get-Timestamp { param ([String]$Date); $d = if ($Date) { Get-Date $Date } else { Get-Date }; Get-Date $d -UFormat %s -Millisecond 0 } function Get-WeekDate { param ([String]$Date); $d = if ($Date) { Get-Date $Date } else { Get-Date }; (Get-Date $d -UFormat %Y-W) + (Get-Date $d -UFormat %W).PadLeft(2, '0') } ``` -------------------------------- ### PowerShell Aliases for File Management Source: https://context7.com/erelado/dotfiles-windows/llms.txt Provides Unix-like aliases for common file management tasks in PowerShell. Includes functions for creating and navigating directories, moving files to the recycle bin, extracting zip archives, and finding files/directories. ```powershell # Create directory and navigate into it function New-DirectoryCreateAndSet { param ([String]$SubPath) New-Item "$($PWD.Path)\$SubPath" -ItemType Directory -ErrorAction SilentlyContinue Set-Location "$($PWD.Path)\$SubPath" } Set-Alias -Name "mkcd" -Value "New-DirectoryCreateAndSet" # Usage mkcd "new-project" # Move files to Recycle Bin instead of permanent delete function Remove-ToRecycleBin { Add-Type -AssemblyName Microsoft.VisualBasic foreach ($Path in $Args) { $Item = Get-Item -Path $Path if (Test-Path -Path $Item.FullName -PathType Container) { [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteDirectory($Item.FullName, 'OnlyErrorDialogs', 'SendToRecycleBin') } else { [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile($Item.FullName, 'OnlyErrorDialogs', 'SendToRecycleBin') } } } Set-Alias -Name "trash" -Value "Remove-ToRecycleBin" # Usage trash "unwanted-file.txt" trash "old-folder" # Extract zip files function Expand-ZipFile { param ([String]$FileName) $DirName = (Get-Item $FileName).Basename Expand-Archive $FileName -DestinationPath $DirName } Set-Alias -Name "unzip" -Value "Expand-ZipFile" # Usage unzip "archive.zip" # Find files and directories Set-Alias -Name "ff" -Value "Find-File" # Find files Set-Alias -Name "fd" -Value "Find-Directory" # Find directories ff "*.ps1" fd "src" ``` -------------------------------- ### Configure PSReadLine for Enhanced Terminal Experience Source: https://context7.com/erelado/dotfiles-windows/llms.txt Customizes the PowerShell command-line interface with history-based predictions, tab completion, custom key bindings for text navigation, and a grid-view history browser. ```powershell Set-PSReadLineOption -PredictionSource "History" Set-PSReadLineOption -HistoryNoDuplicates Set-PSReadLineOption -PredictionViewStyle "ListView" Set-PSReadLineKeyHandler -Key "Tab" -Function "Complete" Set-PSReadLineKeyHandler -Key "F7" -ScriptBlock { $History | Out-GridView -Title History -PassThru } ``` -------------------------------- ### Configure Windows OS Settings Source: https://context7.com/erelado/dotfiles-windows/llms.txt Provides functions to modify Windows registry settings for a developer-friendly environment. Includes enabling dark mode, configuring Explorer to show file extensions, and disabling unwanted hotkeys. ```powershell function Set-DarkMode { Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" ` -Name "AppsUseLightTheme" -Value 0 -Type "Dword" Set-DarkCursor } function Set-ExplorerSettings { Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Narrator\NoRoam" ` -Name "WinEnterLaunchEnabled" -Value 0 Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" ` -Name "HideFileExt" -Value 0 Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" ` -Name "Hidden" -Value 1 } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.