From 49836e3039d485bc70754f5a9ebdb4aeaa5ac4af Mon Sep 17 00:00:00 2001 From: Nikolas Grottendieck Date: Tue, 31 Oct 2023 11:08:52 +0100 Subject: [PATCH] improve bootstrapping and unlinking process - group stow statements - group mkdir statements - improve messaging --- bootstrap.ps1 | 20 +++++++++++++++----- unlink.ps1 | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/bootstrap.ps1 b/bootstrap.ps1 index de840bc..8df3250 100644 --- a/bootstrap.ps1 +++ b/bootstrap.ps1 @@ -1,4 +1,4 @@ -#Requires -RunAsAdministrator +#Requires -RunAsAdministrator Param ( @@ -33,18 +33,21 @@ Function initPowershell function DoIt { + Write-Host "Creating target directories" + New-Item -Path "$( $ENV:UserProfile )\.m2" -ItemType Directory -Force | Out-Null + New-Item -Path "$( $ENV:UserProfile )\.config" -ItemType Directory -Force | Out-Null + New-Item -Path "$( $ENV:UserProfile )\.ssh\config.d" -ItemType Directory -Force | Out-Null + New-Item -Path "$( $ENV:UserProfile )\.vim\backups", "$( $ENV:UserProfile )\.vim\colors", "$( $ENV:UserProfile )\.vim\swaps", "$( $ENV:UserProfile )\.vim\syntax", "$( $ENV:UserProfile )\.vim\undo" -ItemType Directory -Force | Out-Null + + Write-Host "Linking files" LinkFiles "$( $PSScriptRoot )\stow\curl\" "$( $ENV:UserProfile )\" LinkFiles "$( $PSScriptRoot )\stow\git\" "$( $ENV:UserProfile )\" - New-Item -Path "$( $ENV:UserProfile )\.m2" -ItemType Directory -Force | Out-Null LinkFiles "$( $PSScriptRoot )\stow\maven\.m2\" "$( $ENV:UserProfile )\.m2" LinkFiles "$( $PSScriptRoot )\stow\misc\" "$( $ENV:UserProfile )\" - New-Item -Path "$( $ENV:UserProfile )\.config" -ItemType Directory -Force | Out-Null LinkFiles "$( $PSScriptRoot )\stow\shell\" "$( $ENV:UserProfile )\" LinkFiles "$( $PSScriptRoot )\stow\shell\.config\" "$( $ENV:UserProfile )\.config\" - New-Item -Path "$( $ENV:UserProfile )\.ssh\config.d" -ItemType Directory -Force | Out-Null LinkFiles "$( $PSScriptRoot )\stow\ssh\.ssh\" "$( $ENV:UserProfile )\.ssh\" LinkFiles "$( $PSScriptRoot )\stow\ssh\.ssh\config.d\" "$( $ENV:UserProfile )\.ssh\config.d\" - New-Item -Path "$( $ENV:UserProfile )\.vim\backups", "$( $ENV:UserProfile )\.vim\colors", "$( $ENV:UserProfile )\.vim\swaps", "$( $ENV:UserProfile )\.vim\syntax", "$( $ENV:UserProfile )\.vim\undo" -ItemType Directory -Force | Out-Null LinkFiles "$( $PSScriptRoot )\stow\vim\" "$( $ENV:UserProfile )\" LinkFiles "$( $PSScriptRoot )\stow\vim\.vim\colors\" "$( $ENV:UserProfile )\.vim\colors\" LinkFiles "$( $PSScriptRoot )\stow\vim\.vim\syntax\" "$( $ENV:UserProfile )\.vim\syntax\" @@ -52,6 +55,8 @@ function DoIt Function SetGitUser { + Write-Host "Creating Git user config" + $username = Read-Host 'Enter your Git Username' $email = Read-Host 'Enter your Git E-Mail address' @@ -95,6 +100,7 @@ $signWithSSH if ($Force) { + Write-Host "Linking dotfiles" DoIt InitPowershell Write-Host "In PowerShell run the following to allow starship to work: 'Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser'" @@ -104,12 +110,14 @@ else $reply = Read-Host 'This may overwrite existing files in your home directory. Are you sure? (y/n)' if ($reply -match "[yY]") { + Write-Host "Linking dotfiles" DoIt } $reply = Read-Host 'Add starship (https://starship.rs) configuration to PowerShell as well? (y/n)' if ($reply -match "[yY]") { + Write-Host "Adding starship to Powershell" InitPowershell Write-Host "In PowerShell run the following to allow starship to work: 'Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser'" } @@ -119,3 +127,5 @@ If (!(Test-Path -PathType Leaf "$( $ENV:UserProfile )\.gituser")) { SetGitUser } + +Write-Host "Done" diff --git a/unlink.ps1 b/unlink.ps1 index 0b633d6..cf2c697 100644 --- a/unlink.ps1 +++ b/unlink.ps1 @@ -30,6 +30,7 @@ Function UnlinkFiles Function DoIt { Get-ChildItem -Path "$( $PSScriptRoot )\stow\" -Directory -Exclude "powershell" | ForEach-Object { + Write-Host "Unlinking '$_.FullName' from '$( $ENV:UserProfile )'" UnlinkFiles $_.FullName "$( $ENV:UserProfile )" }