Getting Started with Oh My Posh ✨

Oh My Posh is a prompt theme engine for various shell environments. It allows you to customize your terminal prompt with different themes and segments. This guide covers installation and setup for Windows (PowerShell), Linux, and macOS.

Installation

Windows (PowerShell)

  1. Install Oh My Posh using Winget

    winget install JanDeDobbeleer.OhMyPosh -s winget
    

    Alternatively, you can download and install it manually from Oh My Posh releases.

  2. Verify Installation

    oh-my-posh --version
    
  3. Set Up Oh My Posh in PowerShell

    • Open PowerShell and edit your profile:
      notepad $PROFILE
      
    • Add the following line to the profile file:
      oh-my-posh init pwsh | Invoke-Expression
      
    • Save the file and restart PowerShell.
  4. Choose a Theme

    • To list available themes:
      Get-PoshThemes
      
    • To set a specific theme:
      oh-my-posh init pwsh --config "$(oh-my-posh print-config --config <theme-name>.omp.json)" | Invoke-Expression
      

Linux (Bash/Zsh/Fish)

  1. Install via Homebrew (Recommended for Linux/macOS)

    brew install oh-my-posh
    

    Alternatively, install via curl:

    curl -s https://ohmyposh.dev/install.sh | bash
    
  2. Verify Installation

    oh-my-posh --version
    
  3. Set Up Oh My Posh in Shell

    • For Bash:
      echo 'eval "$(oh-my-posh init bash)"' >> ~/.bashrc
      source ~/.bashrc
      
    • For Zsh:
      echo 'eval "$(oh-my-posh init zsh)"' >> ~/.zshrc
      source ~/.zshrc
      
    • For Fish:
      oh-my-posh init fish | source
      
  4. Choose a Theme

    • List available themes:
      oh-my-posh print-config
      
    • Set a theme:
      eval "$(oh-my-posh init bash --config ~/.poshtheme.json)"
      

macOS

  1. Install via Homebrew

    brew install oh-my-posh
    
  2. Verify Installation

    oh-my-posh --version
    
  3. Set Up Oh My Posh in Shell

    • For Bash:
      echo 'eval "$(oh-my-posh init bash)"' >> ~/.bash_profile
      source ~/.bash_profile
      
    • For Zsh:
      echo 'eval "$(oh-my-posh init zsh)"' >> ~/.zshrc
      source ~/.zshrc
      
  4. Choose a Theme

    • List available themes:
      oh-my-posh print-config
      
    • Set a theme:
      eval "$(oh-my-posh init zsh --config ~/.poshtheme.json)"
      

Customization

  • To customize your theme, copy an existing theme and modify it:
    cp /path/to/default/theme.omp.json ~/.poshtheme.json
    
  • Edit the file with your preferred text editor:
    vim ~/.poshtheme.json
    
  • Apply the customized theme:
    eval "$(oh-my-posh init bash --config ~/.poshtheme.json)"
    

Conclusion

Oh My Posh enhances your terminal experience with customizable themes. Follow the installation and setup steps for your OS and shell to get started. For more details, visit the Oh My Posh Documentation.

Credits

Oh My Posh is developed and maintained by Jan De Dobbeleer. You can find the source repository on GitHub.