Skip to content

Latest commit

 

History

History
175 lines (131 loc) · 4.47 KB

installation.mdx

File metadata and controls

175 lines (131 loc) · 4.47 KB
id title sidebar_label
installation
Manual Installation
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, which offer a maximum of icons you can use to configure your prompt. :::

Oh my Posh was designed using Meslo LGM NF, so if you happen to see missing icons either change to that font or replace the icons by changing the theme to your liking.

2. Download the latest binary

<Tabs defaultValue="windows" values={[ { label: 'windows', value: 'windows', }, { label: 'macos', value: 'macos', }, { label: 'unix', value: 'unix', }, ] }>

If you're looking to use the shell in PowerShell, there's a PowerShell package 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 :-)

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
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
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 you like, download it and store it somewhere you can find it again.

4. Replace your existing prompt

<Tabs defaultValue="powershell" values={[ { label: 'powershell', value: 'powershell', }, { label: 'zsh', value: 'zsh', }, { label: 'bash', value: 'bash', }, { label: 'nix', value: 'nix', }, { label: 'fish', value: 'fish', }, ] }>

Edit $PROFILE in your preferred PowerShell version and add the following lines.

[ScriptBlock]$Prompt = {
  $realLASTEXITCODE = $global:LASTEXITCODE
  & "C:\tools\oh-my-posh.exe" -config "~/downloadedtheme.json" -error $realLASTEXITCODE -pwd $PWD
  $global:LASTEXITCODE = $realLASTEXITCODE
  Remove-Variable realLASTEXITCODE -Confirm:$false
}
Set-Item -Path Function:prompt -Value $Prompt -Force

Add the following to ~/.zshrc:

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):

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:

# 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:

function fish_prompt
    eval oh-my-posh -config ~/downloadedtheme.json -error $status
end

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

🎉🎉🎉