-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.ps1
61 lines (51 loc) · 2.16 KB
/
install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#
# Global Configuration
#
$UserProfile = $env:USERPROFILE
$DocumentsPath = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::MyDocuments)
$AppDataRoaming = $env:APPDATA
#
# Install PowerShell Profile
#
'--------------------'
'PowerShell Profile'
'--------------------'
$PowerShellProfileSource = Join-Path -Path $PSScriptRoot -ChildPath 'PowerShell\Microsoft.PowerShell_profile.ps1'
$PowerShellProfiles = @(
(Join-Path -Path $DocumentsPath -ChildPath 'WindowsPowerShell\Microsoft.PowerShell_profile.ps1') # PowerShell 5 and below
(Join-Path -Path $DocumentsPath -ChildPath 'PowerShell\Microsoft.PowerShell_profile.ps1') # PowerShell 6
)
Foreach ($File in $PowerShellProfiles) {
$ProfileDirectory = Split-Path -Path $File -Parent
# Create the directory
If (-not (Test-Path -Path $ProfileDirectory)) {
'Creating directory {0}' -f $ProfileDirectory
$null = New-Item -Path $ProfileDirectory -ItemType Directory
}
# Create the symbolic link
If (-not (Test-Path -Path $File)) {
'Creating symbolic link of {0} to {1}' -f $File, $PowerShellProfileSource
$null = New-Item -Path $File -Value $PowerShellProfileSource -ItemType SymbolicLink
}
}
#
# Install Dot Files
#
'--------------------'
'Dot Files'
'--------------------'
$DotFileSources = Get-ChildItem -Path $PSScriptRoot -Exclude @('README.md', 'install.ps1', 'LICENSE.md', '*PowerShell*') -Recurse | Where-Object {-not $_.PSIsContainer} |Select-Object -ExpandProperty FullName
Foreach ($DotFileSource in $DotFileSources) {
$DestinationFile = $DotFileSource.Replace($PSScriptRoot, $UserProfile)
$DestinationDirectory = Split-Path -Path $DestinationFile -Parent
# Create the directory
If (-not (Test-Path -Path $DestinationDirectory)) {
'Creating directory {0}' -f $DestinationDirectory
$null = New-Item -Path $DestinationDirectory -ItemType Directory
}
# Create the symbolic link
If (-not (Test-Path -Path $DestinationFile)) {
'Creating symbolic link of {0} to {1}' -f $DestinationFile, $DotFileSource
$null = New-Item -Path $DestinationFile -Value $DotFileSource -ItemType SymbolicLink
}
}