jayharris/dotfiles-windows

repository·master·Indexed 20 days ago

https://github.com/jayharris/dotfiles-windows

A collection of PowerShell scripts for Windows to automate developer environment setup. Includes application installation via Win-Get and NPM, custom PowerShell profiles (components, functions, aliases, and exports), and default configurations for Git, Mercurial, Ruby, NPM, and vim.

Tokens
1.3K
Snippets
4
Records
6
Agent score
19%

What's inside dotfiles-windows

  1. Understand the PowerShell Profile components

    master

    The dotfiles configure your PowerShell environment by sourcing several specific files every time a new PowerShell window is launched:

    • .\components.ps1: Loads various PowerShell components and modules.
    • .\functions.ps1: Configures custom PowerShell functions.
    • .\aliases.ps1: Configures alias-based commands.
    • .\exports.ps1: Configures environment variables.
    • .\extra.ps1: Loads secrets and secret commands (not tracked by Git).

    Additionally, default configurations are provided for Git, Mercurial, Ruby, NPM, and vim.

  2. Install dotfiles using Git and the bootstrap script

    master

    To install the dotfiles by cloning the repository, run the following commands in PowerShell. The bootstrap.ps1 script will copy the configuration files to your PowerShell Profile folder.

    Prerequisite: You must set your execution policy to Unrestricted or Bypass to allow the scripts to run:

    Set-ExecutionPolicy Unrestricted

    Installation:

    git clone https://github.com/jayharris/dotfiles-windows.git; cd dotfiles-windows; . .\bootstrap.ps1

    To Update: Navigate to your local dotfiles-windows directory and run the bootstrapper again:

    . .\bootstrap.ps1
    git clone https://github.com/jayharris/dotfiles-windows.git; cd dotfiles-windows; . .\bootstrap.ps1
  3. Install dotfiles without Git

    master

    If you do not want to use Git, you can install the dotfiles directly using a PowerShell command.

    Prerequisite: You must run PowerShell as an Administrator and set the execution policy to Unrestricted:

    Set-ExecutionPolicy Unrestricted

    Installation/Update: Run the following command to download and execute the installation script directly from GitHub:

    iex ((new-object net.webclient).DownloadString('https://raw.github.com/jayharris/dotfiles-windows/master/setup/install.ps1'))
    iex ((new-object net.webclient).DownloadString('https://raw.github.com/jayharris/dotfiles-windows/master/setup/install.ps1'))
  4. Fork the repository for custom configuration

    master

    If you want to use these dotfiles as a base for your own configuration, you should fork the repository. To ensure the installation points to your own repository instead of the original, you must modify the following variables in /setup/install.ps1:

    $account = "your-github-username"
    $repo    = "your-repo-name"
    $branch  = "master"

    Then, update your git-free installation command to use your credentials:

    iex ((new-object net.webclient).DownloadString('https://raw.github.com/$account/$repo/$branch/setup/install.ps1'))
    $account = "jayharris"
    $repo    = "dotfiles-windows"
    $branch  = "master"
  5. Manage secrets using extra.ps1

    master

    To prevent sensitive information (like API tokens, credentials, or personal email addresses) from being committed to your Git repository, use the .\extra.ps1 file.

    If .\extra.ps1 exists in your PowerShell Profile folder, it will be sourced automatically alongside the standard configuration files. This file is intended to augment or override existing settings.

    Example extra.ps1 for Git credentials:

    # Hg credentials
    Set-Environment "EMAIL" "Jay Harris <jay@aranasoft.com>"
    
    # Git credentials
    Set-Environment "GIT_AUTHOR_NAME" "Jay Harris","User"
    Set-Environment "GIT_COMMITTER_NAME" $env:GIT_AUTHOR_NAME
    git config --global user.name $env:GIT_AUTHOR_NAME
    Set-Environment "GIT_AUTHOR_EMAIL" "jay@aranasoft.com"
    Set-Environment "GIT_COMMITTER_EMAIL" $env:GIT_AUTHOR_EMAIL
    git config --global user.email $env:GIT_AUTHOR_EMAIL
    # Hg credentials
    # Not in the repository, to prevent people from accidentally committing under my name
    Set-Environment "EMAIL" "Jay Harris <jay@aranasoft.com>"
    
    # Git credentials
    # Not in the repository, to prevent people from accidentally committing under my name
    Set-Environment "GIT_AUTHOR_NAME" "Jay Harris","User"
    Set-Environment "GIT_COMMITTER_NAME" $env:GIT_AUTHOR_NAME
    git config --global user.name $env:GIT_AUTHOR_NAME
    Set-Environment "GIT_AUTHOR_EMAIL" "jay@aranasoft.com"
    Set-Environment "GIT_COMMITTER_EMAIL" $env:GIT_AUTHOR_EMAIL
    git config --global user.email $env:GIT_AUTHOR_EMAIL
  6. Configure Windows defaults and dependencies

    master

    The repository includes scripts to automate common Windows setup tasks:

    Set Windows Defaults

    Run .\windows.ps1 to configure settings such as showing hidden files in Explorer, privacy settings, or installing IIS.

    Note: This script may set your machine name. You can rename your machine using:

    (Get-WmiObject Win32_ComputerSystem).Rename("MyMachineName") | Out-Null

    Install Dependencies

    Run .\deps.ps1 to install common packages and utilities, including Node.js packages via NPM, Win-Get packages, Windows Features, and Visual Studio Extensions.