chore: update installation instructions

This commit is contained in:
Jan De Dobbeleer 2020-11-03 09:16:09 +01:00
parent 1339048fb4
commit 1043d24f7c

View file

@ -9,26 +9,51 @@ import TabItem from "@theme/TabItem";
### 1. Setup your terminal ### 1. Setup your terminal
Oh my Posh uses ANSI color codes under the hood, these should work everywhere, <Tabs
but you may have to set `$TERM` to `xterm-256color` for it to work. groupId="operating-systems"
defaultValue="windows"
values={[
{ label: 'windows', value: 'windows', },
{ label: 'macos', value: 'macos', },
{ label: 'unix', value: 'unix', },
]
}>
<TabItem value="windows">
:::caution Font icons #### Terminal
For maximum enjoyment, make sure to **install** and **configure** your terminal to use a powerline enabled font.
The fonts we use are patched by [Nerd Fonts][nerdfonts], which offer a maximum of icons you can use to configure your prompt.
To easily find the icon you want, have a look at their [cheat sheet][nf-cheat].
:::
Oh my Posh was designed using [Meslo LGM NF][meslo], so if you happen to see missing icons either change to that font or replace the icons While Oh my Posh works on the standard terminal, we advise using the [Windows Terminal][wt].
by changing the [theme][themes] to your liking.
</TabItem>
<TabItem value="macos">
#### Terminal
As the standard terminal has issues displaying the ANSI characters correctly, we advise using
[iTerm2][iterm2] or any other modern day MacOS terminal that supports ANSI characters.
</TabItem>
<TabItem value="unix">
#### Terminal
Oh my Posh uses ANSI color codes under the hood, these should work in every terminal,
but you may have to set the environment variable `$TERM` to `xterm-256color` for it to work.
</TabItem>
</Tabs>
#### Font
To see the icons displayed in Oh my Posh, **install** and **configure** your terminal to use a powerline enabled font.
The fonts we use are patched by [Nerd Fonts][nerdfonts], which offer a maximum of icons you can use.
Oh my Posh was designed using [Meslo LGM NF][meslo], but any Nerd Font should be compatible with the standard [themes][themes].
### 2. Download the latest binary ### 2. Download the latest binary
:::note
If you're looking to use the prompt for PowerShell 6 and above, there's a [PowerShell package][powershell] for your enjoyment that facilitates the whole process.
But, if you insist on doing it manually, or you use a pre-core version of PowerShell, here you go :-)
:::
<Tabs <Tabs
groupId="operating-systems"
defaultValue="windows" defaultValue="windows"
values={[ values={[
{ label: 'windows', value: 'windows', }, { label: 'windows', value: 'windows', },
@ -73,9 +98,60 @@ chmod +x /usr/local/bin/oh-my-posh
</Tabs> </Tabs>
### 3. Download a theme ### 3. Download the themes
Find a [theme][themes] you like, download it and store it somewhere you can find it again. <Tabs
groupId="operating-systems"
defaultValue="windows"
values={[
{ label: 'windows', value: 'windows', },
{ label: 'macos', value: 'macos', },
{ label: 'unix', value: 'unix', },
]
}>
<TabItem value="windows">
#### Scoop
When using [Scoop][scoop], all themes are downloaded as well.
#### Manual
```powershell
mkdir C:\tools\poshthemes
Invoke-Webrequest https://github.com/JanDeDobbeleer/oh-my-posh3/releases/latest/download/themes.zip -OutFile C:\tools\poshthemes\themes.zip
Expand-Archive C:\tools\poshthemes\themes.zip -DestinationPath C:\tools\poshthemes -Force
Remove-Item C:\tools\poshthemes\themes.zip
```
</TabItem>
<TabItem value="macos">
#### Manual
```bash
mkdir ~/.poshthemes
wget https://github.com/JanDeDobbeleer/oh-my-posh3/releases/latest/download/themes.zip -O ~/.poshthemes/themes.zip
unzip ~/.poshthemes/themes.zip -d ~/.poshthemes
chmod u+rw ~/.poshthemes/*.json
rm ~/.poshthemes/themes.zip
```
</TabItem>
<TabItem value="unix">
#### Manual
```bash
mkdir ~/.poshthemes
wget https://github.com/JanDeDobbeleer/oh-my-posh3/releases/latest/download/themes.zip -O ~/.poshthemes/themes.zip
unzip ~/.poshthemes/themes.zip -d ~/.poshthemes
chmod u+rw ~/.poshthemes/*.json
rm ~/.poshthemes/themes.zip
```
</TabItem>
</Tabs>
### 4. Replace your existing prompt ### 4. Replace your existing prompt
@ -103,7 +179,7 @@ Edit `$PROFILE` in your preferred PowerShell version and add the following lines
$startInfo = New-Object System.Diagnostics.ProcessStartInfo $startInfo = New-Object System.Diagnostics.ProcessStartInfo
$startInfo.FileName = "C:\tools\oh-my-posh.exe" $startInfo.FileName = "C:\tools\oh-my-posh.exe"
$cleanPWD = $PWD.ProviderPath.TrimEnd("\") $cleanPWD = $PWD.ProviderPath.TrimEnd("\")
$startInfo.Arguments = "-config=""C:\Users\User\Downloads\downloadedtheme.json"" -error=$realLASTEXITCODE -pwd=""$cleanPWD""" $startInfo.Arguments = "-config=""C:\Users\User\.poshthemes\jandedobbeleer.json"" -error=$realLASTEXITCODE -pwd=""$cleanPWD"""
$startInfo.Environment["TERM"] = "xterm-256color" $startInfo.Environment["TERM"] = "xterm-256color"
$startInfo.CreateNoWindow = $true $startInfo.CreateNoWindow = $true
$startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8 $startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8
@ -131,7 +207,7 @@ Add the following to `~/.zshrc`:
```bash ```bash
function powerline_precmd() { function powerline_precmd() {
PS1="$(oh-my-posh -config ~/downloadedtheme.json --error $?)" PS1="$(oh-my-posh -config ~/.poshthemes/jandedobbeleer.json --error $?)"
} }
function install_powerline_precmd() { function install_powerline_precmd() {
@ -155,7 +231,7 @@ Add the following to `~/.bashrc` (or `~/.profile` on MacOS):
```bash ```bash
function _update_ps1() { function _update_ps1() {
PS1="$(oh-my-posh -config ~/downloadedtheme.json -error $?)" PS1="$(oh-my-posh -config ~/.poshthemes/jandedobbeleer.json -error $?)"
} }
if [ "$TERM" != "linux" ] && [ -x "$(command -v oh-my-posh)" ]; then if [ "$TERM" != "linux" ] && [ -x "$(command -v oh-my-posh)" ]; then
@ -176,7 +252,7 @@ which should re-enable the prompt in most cases:
# Workaround for nix-shell --pure # Workaround for nix-shell --pure
if [ "$IN_NIX_SHELL" == "pure" ]; then if [ "$IN_NIX_SHELL" == "pure" ]; then
if [ -x oh-my-posh ]; then if [ -x oh-my-posh ]; then
alias powerline-go="oh-my-posh -config ~/downloadedtheme.json" alias powerline-go="oh-my-posh -config ~/.poshthemes/jandedobbeleer.json"
fi fi
fi fi
``` ```
@ -188,7 +264,7 @@ Redefine `fish_prompt` in `~/.config/fish/config.fish`:
```bash ```bash
function fish_prompt function fish_prompt
eval oh-my-posh -config ~/downloadedtheme.json -error $status eval oh-my-posh -config ~/.poshthemes/jandedobbeleer.json -error $status
end end
``` ```
@ -198,18 +274,20 @@ end
Set the prompt and restart nu shell: Set the prompt and restart nu shell:
```bash ```bash
config set prompt "= `{{$(oh-my-posh -config ~/downloadedtheme.json | str collect)}}`" config set prompt "= `{{$(oh-my-posh -config ~/.poshthemes/jandedobbeleer.json | str collect)}}`"
``` ```
</TabItem> </TabItem>
</Tabs> </Tabs>
Make sure `~/downloadedtheme.json` points to your downloaded or adjusted theme. If the theme would be invalid, the default Agnoster prompt is printed.
### 5. Profit ### 5. Profit
Restart your terminal and enjoy your upgraded experience.
🎉🎉🎉 🎉🎉🎉
[wt]: https://github.com/microsoft/terminal
[iterm2]: https://www.iterm2.com/
[nerdfonts]: https://www.nerdfonts.com/ [nerdfonts]: https://www.nerdfonts.com/
[nf-cheat]: https://www.nerdfonts.com/cheat-sheet [nf-cheat]: https://www.nerdfonts.com/cheat-sheet
[meslo]: https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Meslo.zip [meslo]: https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Meslo.zip