diff --git a/src/ansi_formats.go b/src/ansi_formats.go index 8bdcd3d6..4f205295 100644 --- a/src/ansi_formats.go +++ b/src/ansi_formats.go @@ -37,14 +37,14 @@ func (a *ansiFormats) init(shell string) { a.clearEOL = "%{\x1b[K%}" a.saveCursorPosition = "%{\x1b7%}" a.restoreCursorPosition = "%{\x1b8%}" - a.title = "%%{\033]0;%s\007%%}" + a.title = "%%{\x1b]0;%s\007%%}" a.colorSingle = "%%{\x1b[%sm%%}%s%%{\x1b[0m%%}" a.colorFull = "%%{\x1b[%sm\x1b[%sm%%}%s%%{\x1b[0m%%}" a.colorTransparent = "%%{\x1b[%s;49m\x1b[7m%%}%s%%{\x1b[m\x1b[0m%%}" a.escapeLeft = "%{" a.escapeRight = "%}" a.hyperlink = "%%{\x1b]8;;%s\x1b\\%%}%s%%{\x1b]8;;\x1b\\%%}" - a.osc99 = "%%{\x1b]9;9;%s\x1b7%%}" + a.osc99 = "%%{\x1b]9;9;%s\x1b\\%%}" case bash: a.linechange = "\\[\x1b[%d%s\\]" a.left = "\\[\x1b[%dC\\]" @@ -53,14 +53,14 @@ func (a *ansiFormats) init(shell string) { a.clearEOL = "\\[\x1b[K\\]" a.saveCursorPosition = "\\[\x1b7\\]" a.restoreCursorPosition = "\\[\x1b8\\]" - a.title = "\\[\033]0;%s\007\\]" + a.title = "\\[\x1b]0;%s\007\\]" a.colorSingle = "\\[\x1b[%sm\\]%s\\[\x1b[0m\\]" a.colorFull = "\\[\x1b[%sm\x1b[%sm\\]%s\\[\x1b[0m\\]" a.colorTransparent = "\\[\x1b[%s;49m\x1b[7m\\]%s\\[\x1b[m\x1b[0m\\]" a.escapeLeft = "\\[" a.escapeRight = "\\]" a.hyperlink = "\\[\x1b]8;;%s\x1b\\\\\\]%s\\[\x1b]8;;\x1b\\\\\\]" - a.osc99 = "\\[\x1b]9;9;%s\x1b7\\]" + a.osc99 = "\\[\x1b]9;9;%s\x1b\\\\\\]" default: a.linechange = "\x1b[%d%s" a.left = "\x1b[%dC" @@ -69,14 +69,14 @@ func (a *ansiFormats) init(shell string) { a.clearEOL = "\x1b[K" a.saveCursorPosition = "\x1b7" a.restoreCursorPosition = "\x1b8" - a.title = "\033]0;%s\007" + a.title = "\x1b]0;%s\007" a.colorSingle = "\x1b[%sm%s\x1b[0m" a.colorFull = "\x1b[%sm\x1b[%sm%s\x1b[0m" a.colorTransparent = "\x1b[%s;49m\x1b[7m%s\x1b[m\x1b[0m" a.escapeLeft = "" a.escapeRight = "" a.hyperlink = "\x1b]8;;%s\x1b\\%s\x1b]8;;\x1b\\" - a.osc99 = "\x1b]9;9;%s\x1b7" + a.osc99 = "\x1b]9;9;%s\x1b\\" } } diff --git a/src/engine.go b/src/engine.go index 737d99e6..4ab9669a 100644 --- a/src/engine.go +++ b/src/engine.go @@ -163,7 +163,15 @@ func (e *engine) render() { if e.settings.FinalSpace { e.renderer.write(" ") } - e.renderer.osc99(e.env.getcwd()) + + cwd := e.env.getcwd() + + // temp to fix 3.89 issue and add wsl support + if e.env.isWsl() { + // transform path + cwd, _ = e.env.runCommand("wslpath", "-m", cwd) + } + e.renderer.osc99(cwd) e.print() } diff --git a/src/environment.go b/src/environment.go index cad34f47..fd266989 100644 --- a/src/environment.go +++ b/src/environment.go @@ -63,6 +63,7 @@ type environmentInfo interface { getWindowTitle(imageName, windowTitleRegex string) (string, error) doGet(url string) ([]byte, error) hasParentFilePath(path string) (fileInfo *fileInfo, err error) + isWsl() bool } type commandCache struct { diff --git a/src/environment_unix.go b/src/environment_unix.go index f3476353..46f7a891 100644 --- a/src/environment_unix.go +++ b/src/environment_unix.go @@ -18,3 +18,11 @@ func (env *environment) homeDir() string { func (env *environment) getWindowTitle(imageName, windowTitleRegex string) (string, error) { return "", errors.New("not implemented") } + +func (env *environment) isWsl() bool { + // one way to check + // version := env.getFileContent("/proc/version") + // return strings.Contains(version, "microsoft") + // using env variable + return env.getenv("WSL_DISTRO_NAME") != "" +} diff --git a/src/environment_windows.go b/src/environment_windows.go index edab2dd6..d735e1ba 100644 --- a/src/environment_windows.go +++ b/src/environment_windows.go @@ -53,3 +53,7 @@ func (env *environment) homeDir() string { func (env *environment) getWindowTitle(imageName, windowTitleRegex string) (string, error) { return getWindowTitle(imageName, windowTitleRegex) } + +func (env *environment) isWsl() bool { + return false +} diff --git a/src/segment_path_test.go b/src/segment_path_test.go index 8b2e9b8b..36217fb0 100644 --- a/src/segment_path_test.go +++ b/src/segment_path_test.go @@ -132,6 +132,10 @@ func (env *MockedEnvironment) hasParentFilePath(path string) (*fileInfo, error) return args.Get(0).(*fileInfo), args.Error(1) } +func (env *MockedEnvironment) isWsl() bool { + return false +} + const ( homeBill = "/home/bill" homeJan = "/usr/home/jan"