starship: Custom module's output not being displayed in prompt

Current Behavior

A custom module that should be displaying the email address set in Git when the current directory is a Git repository is not working as expected.

Analyzing the output of the command starship timings, the module is executed and outputs the expected message, but for some reason it’s not being displayed in prompt during normal use (like navigating through directories or listing the current directory’s content). However, when calling the command starship prompt, its output contains the expected information.

Expected Behavior

The output of the custom module should be present and visible in the prompt, as well as the other modules.

Additional context/Screenshots

image

Environment

  • Starship version: 0.51.0
  • PowerShell version: 7.1.3
  • Operating system: Windows 10.0.19043
  • Terminal emulator: Windows Terminal
  • Git Commit Hash: 88c3844d
  • Branch/Tag: v0.51.0
  • Rust Version: rustc 1.50.0 (cb75ad5db 2021-02-10)
  • Rust channel: stable-x86_64-pc-windows-msvc (default) release
  • Build Time: 2021-03-23 16:35:32

Relevant Shell Configuration

# Initializes 'Starship' shell.
Invoke-Expression (&starship init powershell)

Starship Configuration

add_newline = true

[git_status]
conflicted = "=${count}"
ahead = "⇡${count}"
behind = "⇣${count}"
diverged = "⇕⇡${ahead_count}⇣${behind_count}"
untracked = "?${count}"
stashed = "\\$${count}"
modified = "!${count}"
staged = "+${count}"
renamed = "»${count}"
deleted = "✘${count}"

[custom.git_email]
command = "git config user.email"
when = "git rev-parse 2> $null"
format = "by [$output]($style)"
style = "bright-yellow"
disabled = false

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

I also had issues with this command via Powershell. See https://github.com/starship/starship/discussions/2534 and https://github.com/starship/starship/issues/2624.

My current solution for this is not to use Powershell 😁:

[custom.git_email]
command = 'git config user.email'
when = 'git rev-parse --is-inside-work-tree 2> /dev/null'
shell = ['C:\Program Files\Git\bin\sh.exe']
format = 'by [${output} ]($style)'
style = 'bright-yellow'
disabled = false

The output is still printed inside Powershell but the command itself is being run via Git Bash for Windows.