Skip to content

Commit

Permalink
improve bootstrapping and unlinking process
Browse files Browse the repository at this point in the history
- group stow statements
- group mkdir statements
- improve messaging
  • Loading branch information
Okeanos committed Oct 31, 2023
1 parent 654d85d commit 49836e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
20 changes: 15 additions & 5 deletions bootstrap.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -RunAsAdministrator
#Requires -RunAsAdministrator

Param
(
Expand Down Expand Up @@ -33,25 +33,30 @@ 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\"
}

Function SetGitUser
{
Write-Host "Creating Git user config"

$username = Read-Host 'Enter your Git Username'
$email = Read-Host 'Enter your Git E-Mail address'

Expand Down Expand Up @@ -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'"
Expand All @@ -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'"
}
Expand All @@ -119,3 +127,5 @@ If (!(Test-Path -PathType Leaf "$( $ENV:UserProfile )\.gituser"))
{
SetGitUser
}

Write-Host "Done"
1 change: 1 addition & 0 deletions unlink.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 )"
}

Expand Down

0 comments on commit 49836e3

Please sign in to comment.