The most customisable and low-latency cross platform/shell prompt renderer
Find a file
2020-09-12 08:57:18 +02:00
.github feat: initial commit 2020-09-12 08:57:18 +02:00
.vscode feat: initial commit 2020-09-12 08:57:18 +02:00
Themes feat: initial commit 2020-09-12 08:57:18 +02:00
commitlint.config.js feat: initial commit 2020-09-12 08:57:18 +02:00
.gitignore feat: initial commit 2020-09-12 08:57:18 +02:00
appveyor.yml feat: initial commit 2020-09-12 08:57:18 +02:00
color_writer.go feat: initial commit 2020-09-12 08:57:18 +02:00
color_writer_test.go feat: initial commit 2020-09-12 08:57:18 +02:00
COPYING feat: initial commit 2020-09-12 08:57:18 +02:00
engine.go feat: initial commit 2020-09-12 08:57:18 +02:00
engine_test.go feat: initial commit 2020-09-12 08:57:18 +02:00
environment.go feat: initial commit 2020-09-12 08:57:18 +02:00
environment_test.go feat: initial commit 2020-09-12 08:57:18 +02:00
environment_unix.go feat: initial commit 2020-09-12 08:57:18 +02:00
environment_windows.go feat: initial commit 2020-09-12 08:57:18 +02:00
Gopkg.lock feat: initial commit 2020-09-12 08:57:18 +02:00
Gopkg.toml feat: initial commit 2020-09-12 08:57:18 +02:00
main.go feat: initial commit 2020-09-12 08:57:18 +02:00
properties.go feat: initial commit 2020-09-12 08:57:18 +02:00
properties_test.go feat: initial commit 2020-09-12 08:57:18 +02:00
README.md feat: initial commit 2020-09-12 08:57:18 +02:00
segment.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_battery.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_battery_test.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_command.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_command_test.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_exit.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_exit_test.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_git.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_git_test.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_path.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_path_test.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_root.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_session.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_session_test.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_spotify.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_spotify_test.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_test.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_text.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_time.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_virtualenv.go feat: initial commit 2020-09-12 08:57:18 +02:00
segment_virtualenv_test.go feat: initial commit 2020-09-12 08:57:18 +02:00
settings.go feat: initial commit 2020-09-12 08:57:18 +02:00

A prompt theme engine for any shell

example workflow name Go Report Card

What started as the offspring of oh-my-posh for PowerShell resulted in a cross platform, highly customizable and extensible prompt theme engine. After 4 years of working on oh-my-posh, a modern and more efficient tool was needed to suit my personal needs.

❤ Support ❤

Patreon Liberapay Ko-Fi

Features

  • Git status indications
  • Failed command indication
  • Admin indication
  • Current session indications
  • Configurable

Table of Contents**

Installation

go-my-posh uses ANSI color codes under the hood, these should work everywhere, but you may have to set your $TERM to xterm-256color for it to work.

For maximum enjoyment, make sure to install a powerline enabled font. The fonts I use are patched by [Nerd Fonts][nerdfonts], which offers a maximum of icons you can use to configure your prompt.

Precompiled Binaries

You can find precompiled binaries for all major OS's underneath the releases tab. Installation instruction for the different shells below assumes <go-my-posh> points to the go-my-posh binary and you've downloaded the jandedobbeleer theme to your $HOME directory.

On UNIX systems, make sure the binary is executable before using it.

chmod +x gmp_executable

Bash

Add the following to your .bashrc (or .profile on Mac):

function _update_ps1() {
    PS1="$(<go-my-posh> -error $?)"
}

if [ "$TERM" != "linux" ] && [ -f <go-my-posh> ]; then
    PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi

ZSH

Add the following to your .zshrc:

function powerline_precmd() {
    PS1="$(<go-my-posh> -config ~/jandedobbeleer.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

Fish

Redefine fish_prompt in ~/.config/fish/config.fish:

function fish_prompt
    eval <go-my-posh> -config ~/jandedobbeleer.json -error $status
end

Nix

When using nix-shell --pure, go-my-posh will not be accessible, and your prompt will not appear.

As a workaround you can add this snippet to your .bashrc, which should re-enable the prompt in most cases:

# Workaround for nix-shell --pure
if [ "$IN_NIX_SHELL" == "pure" ]; then
    if [ -x <go-my-posh> ]; then
        alias powerline-go="<go-my-posh> -config ~/jandedobbeleer.json"
    fi
fi

Powershell

Redefine prompt function on your profile:

[ScriptBlock]$Prompt = {
    $err = $? ? 0 : 1
    <go-my-posh> -config ~/jandedobbeleer.json  -error $err
}
Set-Item -Path Function:prompt -Value $Prompt -Force

Configuration

As the documentation for all the different segments is still lacking, have a look at the available themes for reference.

Every segment has its own properties you can set/override. Have a look at the code for any you would want to tweak, available options are listed as the Property constant with their respective JSON notation for use in a segment's properties section. Additionally, a few general properties are available cross segments which can be found in properties.go.

Roadmap

  • CI
  • Github Releases
  • Create documentation for manual installation
  • Create documentation on the different segments
  • Create easy installation packages
    • Brew
    • Chocolatey
  • Create documentation on the different segments

Thanks

  • Chris Benti for providing the first influence to start oh-my-posh
  • Keith Dahlby for creating posh-git and making life more enjoyable
  • Robby Russel for creating oh-my-zsh, without him this would probably not be here
  • Janne Mareike Koschinski for providing information on how to get certain information using Go (and the amazing README)