Zuletzt aktiv 1 week ago

Bundled installer scripts. VS Code: install.{sh,ps1}. JetBrains IDEs (incl. Gateway / remote-dev-server): install-jetbrains.{sh,ps1}. Each script detects your OS (Windows / macOS / Ubuntu / WSL2) and is interactive.

Änderung 6973c13755a4632aedfcd956fa84a76cf5e7dfa6

install.ps1 Originalformat
1<#
2.SYNOPSIS
3 Install a curated list of VS Code extensions on Windows.
4
5.DESCRIPTION
6 Installs the bundled extension list using the VS Code 'code' CLI.
7 Sets the current process's ExecutionPolicy to RemoteSigned (no machine-wide
8 change) so the script can run on a default Windows configuration.
9
10.PARAMETER ProfileName
11 Optional VS Code profile name. If supplied, extensions are installed into
12 that profile. VS Code creates the profile if it doesn't already exist.
13 Quote names that contain spaces.
14
15.EXAMPLE
16 PS> .\install.ps1
17
18.EXAMPLE
19 PS> .\install.ps1 -ProfileName "WorkSetup"
20
21.NOTES
22 If PowerShell refuses to run the file, invoke it as:
23 powershell -ExecutionPolicy Bypass -File .\install.ps1
24#>
25
26[CmdletBinding()]
27param(
28 [Parameter(Mandatory = $false, Position = 0)]
29 [string]$ProfileName = ""
30)
31
32# Loosen execution policy for THIS process only (no persisted change).
33try {
34 $current = Get-ExecutionPolicy -Scope Process -ErrorAction Stop
35 if ($current -in @('Restricted', 'AllSigned', 'Undefined')) {
36 Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned -Force -ErrorAction Stop
37 }
38} catch {
39 Write-Verbose ("Could not adjust process execution policy: {0}" -f $_.Exception.Message)
40}
41
42$ErrorActionPreference = 'Stop'
43
44$Extensions = @(
45 'docker.docker',
46 'github.copilot-chat',
47 'github.github-vscode-theme',
48 'ms-vscode-remote.vscode-remote-extensionpack',
49 'pkief.material-icon-theme'
50)
51
52$codeCmd = Get-Command code -ErrorAction SilentlyContinue
53if (-not $codeCmd) {
54 Write-Host ""
55 Write-Host "Error: the 'code' command is not on your PATH." -ForegroundColor Red
56 Write-Host " Install VS Code from https://code.visualstudio.com/ and make sure" -ForegroundColor Yellow
57 Write-Host ' "Add to PATH" was checked during setup, then re-open your terminal.' -ForegroundColor Yellow
58 exit 1
59}
60
61$extraArgs = @()
62if (-not [string]::IsNullOrWhiteSpace($ProfileName)) {
63 $extraArgs += @('--profile', $ProfileName)
64}
65
66$header = "Installing $($Extensions.Count) extension(s)"
67if ($ProfileName) { $header += " into profile '$ProfileName'" }
68Write-Host ("{0}..." -f $header) -ForegroundColor Cyan
69Write-Host ""
70
71$installed = 0
72$failed = 0
73$failedList = @()
74
75foreach ($ext in $Extensions) {
76 Write-Host -NoNewline (" -> {0,-55} " -f $ext)
77 try {
78 $output = & code @extraArgs --install-extension $ext --force 2>&1
79 if ($LASTEXITCODE -eq 0) {
80 Write-Host "ok" -ForegroundColor Green
81 $installed++
82 } else {
83 Write-Host "FAILED" -ForegroundColor Red
84 $failed++
85 $failedList += $ext
86 $output | ForEach-Object { Write-Host " $_" -ForegroundColor DarkRed }
87 }
88 } catch {
89 Write-Host "FAILED" -ForegroundColor Red
90 $failed++
91 $failedList += $ext
92 Write-Host (" {0}" -f $_.Exception.Message) -ForegroundColor DarkRed
93 }
94}
95
96Write-Host ""
97Write-Host ("Done. Installed: {0}, Failed: {1}" -f $installed, $failed)
98
99if ($failed -gt 0) {
100 Write-Host "Failed extensions:" -ForegroundColor Red
101 foreach ($f in $failedList) {
102 Write-Host (" - {0}" -f $f) -ForegroundColor Red
103 }
104 exit 1
105}
106
install.sh Originalformat
1#!/usr/bin/env bash
2#
3# VS Code extension installer for macOS and Linux (Ubuntu).
4#
5# Usage:
6# ./install.sh # install into the default profile
7# ./install.sh --profile "MyProfile" # install into a named profile
8# ./install.sh --help
9#
10# If --profile is provided and the profile does not exist, VS Code creates
11# it automatically. Quote names that contain spaces.
12
13set -euo pipefail
14IFS=$'\n\t'
15
16readonly EXTENSIONS=(
17 "docker.docker"
18 "github.copilot-chat"
19 "github.github-vscode-theme"
20 "ms-vscode-remote.vscode-remote-extensionpack"
21 "pkief.material-icon-theme"
22)
23
24PROFILE=""
25
26usage() {
27 cat <<EOF
28Usage: $(basename "$0") [--profile "ProfileName"]
29
30Installs a curated list of VS Code extensions on macOS or Linux.
31
32Options:
33 -p, --profile <name> Install into the named VS Code profile.
34 VS Code creates the profile if it doesn't exist.
35 -h, --help Show this help and exit.
36EOF
37}
38
39while [[ $# -gt 0 ]]; do
40 case "$1" in
41 -p|--profile)
42 if [[ $# -lt 2 || -z "${2:-}" ]]; then
43 echo "Error: --profile requires a non-empty value." >&2
44 exit 2
45 fi
46 PROFILE="$2"
47 shift 2
48 ;;
49 -h|--help)
50 usage
51 exit 0
52 ;;
53 *)
54 echo "Error: unknown argument '$1'." >&2
55 usage >&2
56 exit 2
57 ;;
58 esac
59done
60
61OS="$(uname -s)"
62case "$OS" in
63 Darwin|Linux) ;;
64 *)
65 echo "Error: unsupported OS '$OS'. Use install.ps1 on Windows." >&2
66 exit 1
67 ;;
68esac
69
70if ! command -v code >/dev/null 2>&1; then
71 cat >&2 <<'EOF'
72Error: the 'code' command is not on your PATH.
73
74 macOS: open VS Code, press Cmd+Shift+P, run
75 "Shell Command: Install 'code' command in PATH".
76 Linux: install VS Code from https://code.visualstudio.com/
77 (or: sudo snap install --classic code), then reopen your shell.
78EOF
79 exit 1
80fi
81
82declare -a CODE_ARGS=()
83if [[ -n "$PROFILE" ]]; then
84 CODE_ARGS+=("--profile" "$PROFILE")
85fi
86
87LOG_FILE="$(mktemp -t vscode-install.XXXXXX)"
88trap 'rm -f "$LOG_FILE"' EXIT
89
90header="Installing ${#EXTENSIONS[@]} extension(s)"
91[[ -n "$PROFILE" ]] && header+=" into profile '$PROFILE'"
92echo "$header..."
93echo
94
95installed=0
96failed=0
97declare -a FAILED_LIST=()
98
99for ext in "${EXTENSIONS[@]}"; do
100 printf ' -> %-55s ' "$ext"
101 if code "${CODE_ARGS[@]}" --install-extension "$ext" --force >"$LOG_FILE" 2>&1; then
102 echo "ok"
103 installed=$((installed + 1))
104 else
105 echo "FAILED"
106 failed=$((failed + 1))
107 FAILED_LIST+=("$ext")
108 sed 's/^/ /' "$LOG_FILE" >&2 || true
109 fi
110done
111
112echo
113echo "Done. Installed: ${installed}, Failed: ${failed}"
114
115if (( failed > 0 )); then
116 echo "Failed extensions:" >&2
117 for f in "${FAILED_LIST[@]}"; do
118 echo " - $f" >&2
119 done
120 exit 1
121fi
122