How to configure 3rd party prompts

nerdfonts

nerdfonts are not required but they make the presentation much better.

siteHow to configure 3rd party prompts - 图1 (opens new window)

repoHow to configure 3rd party prompts - 图2 (opens new window)

oh-my-posh

siteHow to configure 3rd party prompts - 图3 (opens new window)

repoHow to configure 3rd party prompts - 图4 (opens new window)

If you like oh-my-poshHow to configure 3rd party prompts - 图5 (opens new window), you can use oh-my-posh with Nushell with a few steps. It works great with Nushell. How to setup oh-my-posh with Nushell:

  1. Install Oh My Posh and download oh-my-posh’s themes following guideHow to configure 3rd party prompts - 图6 (opens new window).
  2. Download and install a nerd fontHow to configure 3rd party prompts - 图7 (opens new window).
  3. Set the PROMPT_COMMAND in ~/.config/nushell/config.nu(or the path output by $nu.config-path), change M365Princess.omp.json to whatever you like Themes demoHow to configure 3rd party prompts - 图8 (opens new window).
  1. > let-env PROMPT_COMMAND = { oh-my-posh --config ~/.poshthemes/M365Princess.omp.json }

For MacOS users:

  1. You can install oh-my-posh by brew, just following the guide hereHow to configure 3rd party prompts - 图9 (opens new window)
  2. Download and install a nerd fontHow to configure 3rd party prompts - 图10 (opens new window).
  3. Set the PROMPT_COMMAND in the file output by $nu.config-path, here is a code snippet:
  1. let posh-dir = (brew --prefix oh-my-posh | str trim)
  2. let posh-theme = $'($posh-dir)/share/oh-my-posh/themes/'
  3. # Change the theme names to: zash/space/robbyrussel/powerline/powerlevel10k_lean/
  4. # material/half-life/lambda Or double lines theme: amro/pure/spaceship, etc.
  5. # For more [Themes demo](https://ohmyposh.dev/docs/themes)
  6. let-env PROMPT_COMMAND = { oh-my-posh prompt print primary --config $'($posh-theme)/zash.omp.json' }
  7. # Optional
  8. let-env PROMPT_INDICATOR = $"(ansi y)$> (ansi reset)"

Starship

siteHow to configure 3rd party prompts - 图11 (opens new window)

repoHow to configure 3rd party prompts - 图12 (opens new window)

  1. Follow the links above and install Starship.
  2. Install nerdfonts depending on your preferences.
  3. Use the config example below. Make sure to set the STARSHIP_SHELL environment variable.

Here’s an example config section for Starship:

  1. let-env STARSHIP_SHELL = "nu"
  2. def create_left_prompt [] {
  3. starship prompt --cmd-duration $env.CMD_DURATION_MS $'--status=($env.LAST_EXIT_CODE)'
  4. }
  5. # Use nushell functions to define your right and left prompt
  6. let-env PROMPT_COMMAND = { create_left_prompt }
  7. let-env PROMPT_COMMAND_RIGHT = ""
  8. # The prompt indicators are environmental variables that represent
  9. # the state of the prompt
  10. let-env PROMPT_INDICATOR = ""
  11. let-env PROMPT_INDICATOR_VI_INSERT = ": "
  12. let-env PROMPT_INDICATOR_VI_NORMAL = "〉"
  13. let-env PROMPT_MULTILINE_INDICATOR = "::: "

Now restart Nu.

  1. nushell on 📙 main is 📦 v0.60.0 via 🦀 v1.59.0

You can learn more about configuring Starship in the official starship configuration documentationHow to configure 3rd party prompts - 图13 (opens new window).

An alternate way to enable Starship is described in the Starship Quick InstallHow to configure 3rd party prompts - 图14 (opens new window) instructions.

Purs

repoHow to configure 3rd party prompts - 图15 (opens new window)