-
Notifications
You must be signed in to change notification settings - Fork 34
/
install.ps1
65 lines (60 loc) · 1.54 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
62
63
64
65
param (
[bool]$local = $false,
[bool]$force = $false
)
$INSTALL_PATH = "$HOME/.oh-my-posh"
if ($IsWindows -or !$IsWindows) {
$SEPARATOR = ";"
}
else {
$SEPARATOR = ":"
}
$MODULES_PATH = "$env:PSModulePath".Split("$SEPARATOR")[0]
function Test-Dependencies {
$exit = 0
# Check git installed
try {
Get-Command git -ErrorAction Stop | Out-Null
}
catch {
Write-Error "Git not found, please install git or add it to your PATH before running again"
$exit = 1
}
# If any errors exit install
if ($exit) { exit 1 }
}
function Install-OMP {
Test-Dependencies
Write-Output "Deleting $INSTALL_PATH"
Remove-Item -Force -Recurse "$INSTALL_PATH" -ErrorAction SilentlyContinue
if ($local) {
# Deploy from current folder
Write-Output "Coping Oh-My-Posh to its destination"
Copy-Item -Recurse -Force "./" "$INSTALL_PATH"
}
else {
# Clone project
Write-Output "Cloning Oh-My-Posh from Github"
git clone "https://github.com/pecigonzalo/Oh-My-Posh.git" "$INSTALL_PATH"
}
# Copy module to the user modules folder
Write-Output "Installing Oh-My-Posh Module to $MODULES_PATH"
New-Item -Type Directory "$MODULES_PATH" -Force | Out-Null
Copy-Item -Recurse -Force "$INSTALL_PATH/modules/oh-my-posh" "$MODULES_PATH"
}
#
# Install logic
#
if ( Test-Path "$INSTALL_PATH" ) {
Write-Output "Oh-My-Posh is already installed"
if ( $force -eq $true ) {
Write-Output "Reinstalling Oh-My-Posh"
Install-OMP
# Load utils
. "$INSTALL_PATH/tools/utils.ps1"
Test-Recommends
}
}
else {
Install-OMP
}