--- id: installation title: Manual Installation sidebar_label: Manual Installation --- import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; ### 1. Setup your terminal Oh my Posh uses ANSI color codes under the hood, these should work everywhere, but you may have to set `$TERM` to `xterm-256color` for it to work. :::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]. ::: 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 by changing the [theme][themes] to your liking. ### 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 :-) ::: #### Scoop A [Scoop][scoop] package is available to assist installs on Windows. #### Manual ```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 ``` #### 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 a theme Find a [theme][themes] you like, download it and store it somewhere you can find it again. ### 4. Replace your existing prompt Edit `$PROFILE` in your preferred PowerShell version and add the following lines. ```powershell [ScriptBlock]$Prompt = { $realLASTEXITCODE = $global:LASTEXITCODE if ($realLASTEXITCODE -isnot [int]) { $realLASTEXITCODE = 0 } $startInfo = New-Object System.Diagnostics.ProcessStartInfo $startInfo.FileName = "C:\tools\oh-my-posh.exe" $cleanPWD = $PWD.ProviderPath.TrimEnd("\") $startInfo.Arguments = "-config=""C:\Users\User\Downloads\downloadedtheme.json"" -error=$realLASTEXITCODE -pwd=""$cleanPWD""" $startInfo.Environment["TERM"] = "xterm-256color" $startInfo.CreateNoWindow = $true $startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8 $startInfo.RedirectStandardOutput = $true $startInfo.UseShellExecute = $false if ($PWD.Provider.Name -eq 'FileSystem') { $startInfo.WorkingDirectory = $PWD.ProviderPath } $process = New-Object System.Diagnostics.Process $process.StartInfo = $startInfo $process.Start() | Out-Null $standardOut = $process.StandardOutput.ReadToEnd() $process.WaitForExit() $standardOut $global:LASTEXITCODE = $realLASTEXITCODE Remove-Variable realLASTEXITCODE -Confirm:$false } Set-Item -Path Function:prompt -Value $Prompt -Force ``` Add the following to `~/.zshrc`: ```bash function powerline_precmd() { PS1="$(oh-my-posh -config ~/downloadedtheme.json --error $?)" } function install_powerline_precmd() { for s in "${precmd_functions[@]}"; do if [ "$s" = "powerline_precmd" ]; then return fi done precmd_functions+=(powerline_precmd) } if [ "$TERM" != "linux" ]; then install_powerline_precmd fi ``` Add the following to `~/.bashrc` (or `~/.profile` on MacOS): ```bash function _update_ps1() { PS1="$(oh-my-posh -config ~/downloadedtheme.json -error $?)" } if [ "$TERM" != "linux" ] && [ -x "$(command -v oh-my-posh)" ]; then PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND" fi ``` When using `nix-shell --pure`, `oh-my-posh` will not be accessible, and your prompt will not appear. As a workaround you can add this snippet to `~/.bashrc`, which should re-enable the prompt in most cases: ```bash # Workaround for nix-shell --pure if [ "$IN_NIX_SHELL" == "pure" ]; then if [ -x oh-my-posh ]; then alias powerline-go="oh-my-posh -config ~/downloadedtheme.json" fi fi ``` Redefine `fish_prompt` in `~/.config/fish/config.fish`: ```bash function fish_prompt eval oh-my-posh -config ~/downloadedtheme.json -error $status end ``` Set the prompt and restart nu shell: ```bash config set prompt "= `{{$(oh-my-posh -config ~/downloadedtheme.json | str collect)}}`" ``` 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 🎉🎉🎉 [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 [powershell]: /docs/powershell [themes]: https://github.com/JanDeDobbeleer/oh-my-posh3/tree/main/themes [scoop]: /docs/scoop