-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
132 lines (117 loc) · 3.99 KB
/
Copy pathsetup.ps1
File metadata and controls
132 lines (117 loc) · 3.99 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Tools to install
$tools = @(
@{ Name = "Git"; ID = "git.git" },
@{ Name = "Mise"; ID = "jdx.mise" },
@{ Name = "Starship"; ID = "starship.starship" },
@{ Name = "Neovim"; ID = "neovim.neovim" },
@{ Name = "Neovide"; ID = "Neovide.Neovide" }
@{ Name = "Ripgrep"; ID = "BurntSushi.ripgrep.MSVC" },
@{ Name = "fd"; ID = "sharkdp.fd" },
@{ Name = "fzf"; ID = "junegunn.fzf" },
@{ Name = "lazygit"; ID = "JesseDuffield.lazygit" },
@{ Name = "7zip"; ID = "7zip.7zip" },
@{ Name = "Make"; ID = "GnuWin32.Make" }
# @{ Name = "Google Chrome"; ID = "Google.Chrome" },
# @{ Name = "Node.js (LTS)"; ID = "OpenJS.NodeJS.LTS" },
)
# Function to check if a tool is installed
function Is-ToolInstalled {
param (
[string]$ID
)
try {
winget list -q $ID | Out-Null
return $?
}
catch {
return $false
}
}
# Function to install certain tool
function Install-Tool {
param (
[string]$Name,
[string]$ID
)
Write-Host "Installing $Name..."
try {
winget install --id $ID --silent --accept-source-agreements --accept-package-agreements
Write-Host "$Name installed successfully."
}
catch {
Write-Error "Error installing $Name : $($_.Exception.Message)"
}
}
# Iterate over all needed tools
Write-Host "Installing tools..."
foreach ($tool in $tools) {
if (-not (Is-ToolInstalled -ID $tool.ID)) {
Install-Tool -Name $tool.Name -ID $tool.ID
} else {
Write-Host "$($tool.Name) is already installed."
}
}
Write-Host "Tools installation completed."
# Setup Neovim configuration
$nvimPath = Join-Path -Path $env:LOCALAPPDATA -ChildPath "nvim"
Write-Host "Configuring Neovim..."
if (-not (Test-Path -Path $nvimPath)) {
try {
git clone https://github.com/Juangr4/nvim.git $nvimPath
Write-Host "Successfully cloned Neovim configuration."
}
catch {
Write-Error "Error cloning nvim repository: $($_.Exception.Message)"
}
} else {
try {
Write-Host "Pulling latest changes from Neovim configuration."
git -C $nvimPath pull
}
catch {
Write-Error "Error pulling configuration: $($_.Exception.Message)"
}
}
# Setup Starship configuration
$starshipConfigPath = Join-Path -Path $HOME -ChildPath "starship.toml"
$starshipConfigUrl = "https://raw.githubusercontent.com/Juangr4/dotdev/refs/heads/master/roles/starship/files/starship.toml"
Write-Host "Configuring Starship..."
try {
Invoke-WebRequest -Uri $starshipConfigUrl -OutFile $starshipConfigPath -UseBasicParsing
Write-Host "Successfully downloaded and overwritten Starship configuration."
}
catch {
Write-Error "Error downloading Starship configuration: $($_.Exception.Message)"
}
# Setup Powershell Profile Configuration
$profileUrl = "https://raw.githubusercontent.com/Juangr4/dotdev/refs/heads/master/profile.ps1"
Write-Host "Configuring Powershell Profile..."
if (-not (Test-Path -Path $profile)) {
try {
Invoke-WebRequest -Uri $profileUrl -OutFile $profile
Write-Host "Successfully downloaded Powershell Profile."
}
catch {
Write-Error "Error downloading Powershell Profile: $($_.Exception.Message)"
}
} else {
Write-Host "Powershell Profile already exists at: $profile"
$confirmation = Read-Host "Do you want to overwrite it? (Y/N)"
if ($confirmation -match '^[Yy]$') {
try {
# Backup existing profile
$backupPath = "$profile.bak"
Copy-Item -Path $profile -Destination $backupPath -Force
Write-Host "Backup created at: $backupPath"
# Download and overwrite
Invoke-WebRequest -Uri $profileUrl -OutFile $profile
Write-Host "Successfully overwritten Powershell Profile."
}
catch {
Write-Error "Error overwriting Powershell Profile: $($_.Exception.Message)"
}
} else {
Write-Host "Operation canceled. Existing profile was not overwritten."
}
}
Write-Host "Setup completed."