From c35fd00a4bf32ffc4e7a8a1dceb7225760598128 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Sun, 24 Jan 2021 11:50:45 +0100 Subject: [PATCH] refactor: unified installation guide --- docs/docs/installation.mdx | 222 +++++++++++++++++++------------ docs/docs/package-homebrew.mdx | 38 ------ docs/docs/package-powershell.mdx | 62 --------- docs/docs/package-scoop.mdx | 41 ------ docs/sidebars.js | 5 - 5 files changed, 134 insertions(+), 234 deletions(-) delete mode 100644 docs/docs/package-homebrew.mdx delete mode 100644 docs/docs/package-powershell.mdx delete mode 100644 docs/docs/package-scoop.mdx diff --git a/docs/docs/installation.mdx b/docs/docs/installation.mdx index bec31be9..e401ce7b 100644 --- a/docs/docs/installation.mdx +++ b/docs/docs/installation.mdx @@ -10,7 +10,6 @@ import TabItem from "@theme/TabItem"; ### 1. Setup your terminal - + -#### Scoop +A [Powershell][powershell] module is available for easy installation. -A [Scoop][scoop] package is available to assist installs on Windows. - -#### Manual +#### Installation ```powershell -mkdir C:\tools -Invoke-Webrequest https://github.com/JanDeDobbeleer/oh-my-posh3/releases/latest/download/posh-windows-amd64.exe -OutFile C:\tools\oh-my-posh.exe +Install-Module oh-my-posh -Scope CurrentUser -AllowPrerelease ``` - - +#### Usage -#### Homebrew +##### Show all themes -A [Homebrew][brew] package is available to assist installs on MacOS. - -#### Manual - -```bash -wget https://github.com/JanDeDobbeleer/oh-my-posh3/releases/latest/download/posh-darwin-amd64 -O /usr/local/bin/oh-my-posh -chmod +x /usr/local/bin/oh-my-posh -``` - - - - -#### Manual - -```bash -wget https://github.com/JanDeDobbeleer/oh-my-posh3/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh -chmod +x /usr/local/bin/oh-my-posh -``` - - - - - -### 3. Download the themes - - - - -#### Scoop - -When using [Scoop][scoop], all themes are downloaded as well. - -#### Manual +To display every available theme in the current directory, use the following +cmdlet. ```powershell -mkdir ~\.poshthemes -Invoke-Webrequest https://github.com/JanDeDobbeleer/oh-my-posh3/releases/latest/download/themes.zip -OutFile ~\.poshthemes\themes.zip -Expand-Archive ~\.poshthemes\themes.zip -DestinationPath ~\.poshthemes -Force -Remove-Item ~\.poshthemes\themes.zip +Get-PoshThemes ``` + + + +A [Scoop][scoop] package is available for easy installation. + +#### Installation + +```powershell +scoop install https://github.com/JanDeDobbeleer/oh-my-posh3/releases/latest/download/oh-my-posh.json +``` + +This installs a couple of things: + +- `oh-my-posh.exe` - Windows executable, added to your `$PATH` +- `oh-my-posh-wsl` - Linux executable, added to your `$PATH` for use in the WSL +- `themes` - The latest Oh my Posh themes + +If you want to use a standard theme, you can find them in `~\scoop\apps\oh-my-posh\current\themes\`, +referencing them as such +will always keep them compatible with the binary when updating Oh my Posh. + #### Preview the themes -When using Scoop, replace `"~\.poshthemes\*"` with `"$(scoop prefix oh-my-posh)/themes/*"` - ```powershell -Get-ChildItem -Path "~\.poshthemes\*" -Include '*.omp.json' | Sort-Object Name | ForEach-Object -Process { +Get-ChildItem -Path "$(scoop prefix oh-my-posh)/themes/*" -Include '*.omp.json' | Sort-Object Name | ForEach-Object -Process { $esc = [char]27 Write-Host "" Write-Host "$esc[1m$($_.BaseName)$esc[0m" @@ -152,35 +119,55 @@ Get-ChildItem -Path "~\.poshthemes\*" -Include '*.omp.json' | Sort-Object Name | } ``` +#### Update + +```powershell +scoop update oh-my-posh +``` + -#### Homebrew +A [Homebrew][brew] formula is available for easy installation. -When using [Homebrew][brew], all themes are downloaded as well. - -#### Manual +#### Installation ```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 +brew tap jandedobbeleer/oh-my-posh +brew install oh-my-posh ``` +This installs two things: + +- `oh-my-posh` - Executable, added to `/usr/local/bin` +- `themes` - The latest Oh my Posh themes + +If you want to use a standard theme, you can find them in `$(brew --prefix oh-my-posh)/themes`, referencing them as such +will always keep them compatible with the binary when updating Oh my Posh. + #### Preview the themes -When using Hombrew, replace `~/.poshthemes/*.omp.json` with `$(brew --prefix oh-my-posh)/themes/*.omp.json` +```bash +for file in $(brew --prefix oh-my-posh)/themes/*.omp.json; do echo "$file\n"; oh-my-posh --config $file --shell universal; echo "\n"; done; +``` + +#### Update ```bash -for file in ~/.poshthemes/*.omp.json; do echo "$file\n"; oh-my-posh --config $file --shell universal; echo "\n"; done; +brew upgrade oh-my-posh ``` -#### Manual +#### Installation + +```bash +wget https://github.com/JanDeDobbeleer/oh-my-posh3/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh +chmod +x /usr/local/bin/oh-my-posh +``` + +#### Download the themes ```bash mkdir ~/.poshthemes @@ -199,19 +186,22 @@ for file in ~/.poshthemes/*.omp.json; do echo "$file\n"; oh-my-posh --config $fi -### 4. Replace your existing prompt +### 3. Replace your existing prompt -If you have no idea which shell you're currently using, Oh my Posh has a utility switch that will you tell you. +:::info +If you have no idea which shell you're currently using, Oh my Posh has a utility switch that can you tell you (not relevant +for the Powershell module). +::: ```bash oh-my-posh --print-shell ``` + + +Autocompletion is available so it will loop through all available themes. + ```powershell -Invoke-Expression (oh-my-posh --init --shell pwsh --config ~/.poshthemes/jandedobbeleer.omp.json) +Set-PoshPrompt -Theme jandedobbeleer ``` + + + +```powershell +Invoke-Expression (oh-my-posh --init --shell pwsh --config "$(scoop prefix oh-my-posh)/themes/jandedobbeleer.omp.json") +``` + + + + Once added, reload your profile for the changes to take effect. ```powershell @@ -316,6 +327,37 @@ Maybe there's a theme you like, but you don't fancy the colors. Or, maybe there' want to tweak/add, or replace some of the icons with a different one. Whatever the case, read through all available options first, by starting with the [configuration guide][configuration]. + + + +You can output the current theme to its `JSON` representation which can be used to tweak and store as your custom theme. + +```powershell +Write-PoshTheme +``` + +Due to a bug in PowerShell, if you want to use `Out-File` directly to write the current theme to a new file, use the `oem` +encoding to ensure the symbols are outputted correctly. + +```powershell +Write-PoshTheme | Out-File -FilePath ~/.mytheme.omp.json -Encoding oem +``` + +Once you're done editing, adjust your `$PROFILE` to use your newly created theme. + +```powershell +Set-PoshPrompt -Theme ~/.mytheme.omp.json +``` + + + + Afterwards, the easiest way to go about this is to print the current config and store it elsewhere first (for example `~/.mytheme.omp.json`). ```bash @@ -329,17 +371,21 @@ and store it somehwere. Once adjusted to your liking, [change the prompt setting oh-my-posh --config ~/.mytheme.omp.json ``` + + + 🎉🎉🎉 +[scoop]: https://scoop.sh/ [wt]: https://github.com/microsoft/terminal [iterm2]: https://www.iterm2.com/ [nerdfonts]: https://www.nerdfonts.com/ [nf-cheat]: https://www.nerdfonts.com/cheat-sheet [meslo]: https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Meslo.zip [font-thread]: https://github.com/JanDeDobbeleer/oh-my-posh3/issues/145#issuecomment-730162622 -[powershell]: /docs/powershell +[powershell]: https://www.powershellgallery.com/packages/oh-my-posh [themes]: https://github.com/JanDeDobbeleer/oh-my-posh3/tree/main/themes -[scoop]: /docs/scoop -[brew]: /docs/homebrew -[prompt]: /docs/installation#4-replace-your-existing-prompt +[scoop]: https://scoop.sh +[brew]: https://brew.sh +[prompt]: /docs/installation#3-replace-your-existing-prompt [configuration]: /docs/configure diff --git a/docs/docs/package-homebrew.mdx b/docs/docs/package-homebrew.mdx deleted file mode 100644 index e4f59bae..00000000 --- a/docs/docs/package-homebrew.mdx +++ /dev/null @@ -1,38 +0,0 @@ ---- -id: homebrew -title: Homebrew -sidebar_label: Homebrew ---- - -A package that installs the Oh my Posh executable using [Homebrew][brew]. - -:::caution Font icons -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]. -::: - -## Installation - -```bash -brew tap jandedobbeleer/oh-my-posh -brew install oh-my-posh -``` - -This installs two things: - -- `oh-my-posh` - Executable, added to `/usr/local/bin` -- `themes` - The latest Oh my Posh themes - -If you want to use a standard theme, you can find them in `$(brew --prefix oh-my-posh)/themes`, referencing them as such -will always keep them compatible with the binary when updating Oh my Posh. - -## Update - -```bash -brew upgrade oh-my-posh -``` - -[brew]: https://brew.sh/ -[nerdfonts]: https://www.nerdfonts.com/ -[nf-cheat]: https://www.nerdfonts.com/cheat-sheet diff --git a/docs/docs/package-powershell.mdx b/docs/docs/package-powershell.mdx deleted file mode 100644 index 23ad69b1..00000000 --- a/docs/docs/package-powershell.mdx +++ /dev/null @@ -1,62 +0,0 @@ ---- -id: powershell -title: PowerShell -sidebar_label: PowerShell ---- - -A package that includes useful helper functions to install and configure Oh my Posh. - -:::caution Font icons -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]. -::: - -## Installation - -```powershell -Install-Module oh-my-posh -Scope CurrentUser -AllowPrerelease -``` - -## Usage - -### Show all themes - -To display every available theme in the current directory, use the following -command. - -```powershell -Get-PoshThemes -``` - -### Set the prompt - -Autocompletion is available so it will loop through all available themes. - -```powershell -Set-PoshPrompt -Theme jandedobbeleer -``` - -### Create your own theme - -You can output the current theme to its `JSON` representation which can be used to tweak and store as your custom theme. - -```powershell -Write-PoshTheme -``` - -Due to a bug in PowerShell, if you want to use `Out-File` directly to write the current theme to a new file, use the `oem` -encoding to ensure the symbols are outputted correctly. - -```powershell -Write-PoshTheme | Out-File -FilePath ~/.mytheme.omp.json -Encoding oem -``` - -Once you're done editing, adjust your `$PROFILE` to use your newly created theme. - -```powershell -Set-PoshPrompt -Theme ~/.mytheme.omp.json -``` - -[nerdfonts]: https://www.nerdfonts.com/ -[nf-cheat]: https://www.nerdfonts.com/cheat-sheet diff --git a/docs/docs/package-scoop.mdx b/docs/docs/package-scoop.mdx deleted file mode 100644 index 88771b92..00000000 --- a/docs/docs/package-scoop.mdx +++ /dev/null @@ -1,41 +0,0 @@ ---- -id: scoop -title: Scoop -sidebar_label: Scoop ---- - -A [Scoop][scoop] package that installs the Oh my Posh Windows and Linux binaries on Windows. -Use these in your shell of choice afterwards by going through the [installation guide][install]. - -:::caution Font icons -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]. -::: - -## Installation - -```powershell -scoop install https://github.com/JanDeDobbeleer/oh-my-posh3/releases/latest/download/oh-my-posh.json -``` - -This installs a couple of things: - -- `oh-my-posh.exe` - Windows executable, added to your `$PATH` -- `oh-my-posh-wsl` - Linux executable, added to your `$PATH` for use in the WSL -- `themes` - The latest Oh my Posh themes - -If you want to use a standard theme, you can find them in `~\scoop\apps\oh-my-posh\current\themes\`, -referencing them as such -will always keep them compatible with the binary when updating Oh my Posh. - -## Update - -```powershell -scoop update oh-my-posh -``` - -[scoop]: https://scoop.sh/ -[install]: /docs/installation -[nerdfonts]: https://www.nerdfonts.com/ -[nf-cheat]: https://www.nerdfonts.com/cheat-sheet diff --git a/docs/sidebars.js b/docs/sidebars.js index 9de95003..62248de4 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -5,11 +5,6 @@ module.exports = { label: "Getting Started", items: ["introduction", "upgrading", "installation", "configure", "themes"], }, - { - type: "category", - label: "Packages", - items: ["powershell", "scoop", "homebrew"], - }, { type: "category", label: "Segments",