oh-my-posh: unix shell crash with path segment on Windows when CWD is root of drive

Prerequisites

  • I have read and understand the CONTRIBUTING guide
  • [x ] I looked for duplicate issues before submitting this one

Description

If I use a “path” segment as in jandedobbeleer.omp.json and CD into the root of a drive, tcsh crashes.

This is because the path segment generates a "\" as the path and immediately follows it with “%{” for the next segment. However, in tcsh the resulting string is "\%" , which escapes the literal quoting of the following ANSI escape sequence, causing all kinds of havoc of unescaped characters.

I am not sure if this is restricted to tcsh, since I would expect ZSH to have the same behavior.

I can see two possible solutions:

  1. Generate "\\" instead of "\", to escape the backslash. This should work.
  2. Generate “/” instead. The Windows-native version of tcsh only uses “/” for paths, but I have no idea if that will mess up the various cygwin shells.

I can work around this for now by not using a path segment, since I prefer using tcshs “%c0n” syntax for paths in prompt anyway.

thanks!

About this issue

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

Most upvoted comments

@TravisTX Let’s add it there as well. That way it’s aligned even though the only use-case is the root path.

@amoldeshpande ok, I’ll try to reproduce this so I can create a proper fix.