Skip to content

Commit

Permalink
feat(windows): add install script for PowerShell
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Apr 27, 2022
1 parent 2b92304 commit 0a8b97b
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 3 deletions.
42 changes: 39 additions & 3 deletions docs/docs/installation/windows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,35 @@ When using oh-my-posh inside the WSL, make sure to follow the [linux][linux] ins
values={[
{ label: 'winget', value: 'winget', },
{ label: 'scoop', value: 'scoop', },
{ label: 'manual', value: 'manual', },
]
}>
<TabItem value="winget">

Open a PowerShell prompt and run the following command:

```powershell
winget install JanDeDobbeleer.OhMyPosh
```

</TabItem>
<TabItem value="scoop">

Open a PowerShell prompt and run the following command:

```powershell
scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json
```

</TabItem>
<TabItem value="manual">

Open a PowerShell prompt and run the following command:

```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://ohmyposh.dev/install.ps1'))
```

</TabItem>
</Tabs>

Expand All @@ -53,9 +67,9 @@ This installs a couple of things:
For the `$PATH` to reload, a restart of your terminal is advised.

:::warning Antivirus software
Due to frequent updates of Oh My Posh, Antivirus software occasionally flags it (false positive).
To ensure Oh My Posh isn't blocked you can either report it to your favorite Antivirus software as false positive
(e.g. [Report a false positive/negative to Microsoft for analysis][report-false-positive]) or create an exclusion for it.
Due to frequent updates of Oh My Posh, Antivirus software occasionally flags it (false positive).
To ensure Oh My Posh isn't blocked you can either report it to your favorite Antivirus software as false positive
(e.g. [Report a false positive/negative to Microsoft for analysis][report-false-positive]) or create an exclusion for it.
Exclusions should be added with the full path to the executable, you can get it with the following command from a PowerShell prompt:

```powershell
Expand All @@ -71,21 +85,35 @@ Exclusions should be added with the full path to the executable, you can get it
values={[
{ label: 'winget', value: 'winget', },
{ label: 'scoop', value: 'scoop', },
{ label: 'manual', value: 'manual', },
]
}>
<TabItem value="winget">

Open a PowerShell prompt and run the following command:

```powershell
winget upgrade JanDeDobbeleer.OhMyPosh
```

</TabItem>
<TabItem value="scoop">

Open a PowerShell prompt and run the following command:

```powershell
scoop update oh-my-posh
```

</TabItem>
<TabItem value="manual">

Open a PowerShell prompt and run the following command:

```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://ohmyposh.dev/install.ps1'))
```

</TabItem>
</Tabs>

Expand All @@ -97,6 +125,7 @@ scoop update oh-my-posh
values={[
{ label: 'winget', value: 'winget', },
{ label: 'scoop', value: 'scoop', },
{ label: 'manual', value: 'manual', },
]
}>
<TabItem value="winget">
Expand All @@ -112,6 +141,13 @@ You can find the themes scoop installs inside the `"$(scoop prefix oh-my-posh)\t
To use `jandedobbeleer.omp.json` for example, you can refer to it using `"$(scoop prefix oh-my-posh)\themes\jandedobbeleer.omp.json"`
when setting the prompt using the `--config` flag.

</TabItem>
<TabItem value="manual">

You can find the themes winget installs inside the `$env:POSH_THEMES_PATH` folder.
To use `jandedobbeleer.omp.json` for example, you can refer to it using `$env:POSH_THEMES_PATH\jandedobbeleer.omp.json`
when setting the prompt using the `--config` flag.

</TabItem>
</Tabs>

Expand Down
54 changes: 54 additions & 0 deletions docs/static/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
$installInstructions = @'
Hey friend
This installer is only available for Windows.
If you're looking for installation instructions for your operating system,
please visit the following link:
'@
if ($IsMacOS) {
Write-Host @"
$installInstructions
https://ohmyposh.dev/docs/installation/macos
"@
exit
}
if ($IsLinux) {
Write-Host @"
$installInstructions
https://ohmyposh.dev/docs/installation/linux
"@
exit
}
$installer = ''
$arch = (Get-CimInstance -Class Win32_Processor -Property Architecture).Architecture
switch ($arch) {
0 { $installer = "install-386.exe" } # x86
5 { $installer = "install-arm64.exe" } # ARM
9 { $installer = "install-amd64.exe" } # x64
12 { $installer = "install-amd64.exe" } # x64 emulated on Surface Pro X
}

if ($installer -eq '') {
Write-Host @"
The installer for system architecture ($arch) is not available.
"@
exit
}

Write-Host "Downloading $installer..."
$tmp = New-TemporaryFile | Rename-Item -NewName { $_ -replace 'tmp$', 'exe' } -PassThru
$url = "https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/$installer"
Invoke-WebRequest -OutFile $tmp $url
Write-Host 'Running installer...'
& "$tmp" /VERYSILENT | Out-Null
$tmp | Remove-Item
Write-Host @'
Done!
Restart your terminal and have a look at the
documentation on how to proceed from here.
https://ohmyposh.dev/docs/installation/prompt
'@

0 comments on commit 0a8b97b

Please sign in to comment.