Repository: JanDeDobbeleer/oh-my-posh
Pull request #2646 (2022-08-10 07:01:30)

Revise docs & revert commit 4d1f8f4
### Prerequisites

- [x] I have read and understood the [contributing guide][CONTRIBUTING.md]
- [x] The commit message follows the [conventional commits][cc] guidelines
- [ ] Tests for the changes have been added (for bug fixes/features)
- [ ] Docs have been added/updated (for bug fixes/features)

### Description

1. Revisions to docs:

- Add tips on a problem with the initialization using Oh My Posh installed via Homebrew.
- Tweak some tips, cautions and warnings. For some messages, it's better to use `caution` rather than `warning` because the latter shows the word `DANGER` which indicates a risky operation such as deleting user's files.

2. Revert commit 4d1f8f4. Related: #2636.

[CONTRIBUTING.md]: https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/CONTRIBUTING.md
[cc]: https://www.conventionalcommits.org/en/v1.0.0/#summary


JanDeDobbeleer: @lewis-yeung can you do me a favor and also revert [this](https://github.com/JanDeDobbeleer/oh-my-posh/commit/4d1f8f4ea0158034ff204610f678feba4d45bdca) commit? It introduces an issue for some people in bash.
lewis-yeung: > can you do me a favor and also revert [this](https://github.com/JanDeDobbeleer/oh-my-posh/commit/4d1f8f4ea0158034ff204610f678feba4d45bdca) commit?

@JanDeDobbeleer Yes. I have included the reverting in this PR.


Patch:
diff --git a/src/color/ansi.go b/src/color/ansi.go
index 8bfee2ce..4d1c5af0 100644
--- a/src/color/ansi.go
+++ b/src/color/ansi.go
@@ -77,33 +77,33 @@ func (a *Ansi) Init(shellName string) {
 		a.dimmed = "%%{\x1b[2m%%}%s%%{\x1b[22m%%}"
 		a.strikethrough = "%%{\x1b[9m%%}%s%%{\x1b[29m%%}"
 	case shell.BASH:
-		a.format = "\001%s\002"
-		a.linechange = "\001\x1b[%d%s\002"
-		a.right = "\001\x1b[%dC\002"
-		a.left = "\001\x1b[%dD\002"
-		a.creset = "\001\x1b[0m\002"
-		a.clearBelow = "\001\x1b[0J\002"
-		a.clearLine = "\001\x1b[K\002"
-		a.saveCursorPosition = "\001\x1b7\002"
-		a.restoreCursorPosition = "\001\x1b8\002"
-		a.title = "\001\x1b]0;%s\007\002"
-		a.colorSingle = "\001\x1b[%sm\002%s\001\x1b[0m\002"
-		a.colorFull = "\001\x1b[%sm\x1b[%sm\002%s\001\x1b[0m\002"
-		a.colorTransparent = "\001\x1b[%s;49m\x1b[7m\002%s\001\x1b[0m\002"
-		a.escapeLeft = "\001"
-		a.escapeRight = "\002"
-		a.hyperlink = "\001\x1b]8;;%s\x1b\\\\\002%s\001\x1b]8;;\x1b\\\\\002"
-		a.hyperlinkRegex = `(?P<STR>\001\x1b\]8;;(.+)\x1b\\\\\002(?P<TEXT>.+)\001\x1b\]8;;\x1b\\\\\002)`
-		a.osc99 = "\001\x1b]9;9;\"%s\"\x1b\\\\\002"
-		a.osc7 = "\001\x1b]7;\"file://%s/%s\"\x1b\\\\\002"
-		a.bold = "\001\x1b[1m\002%s\001\x1b[22m\002"
-		a.italic = "\001\x1b[3m\002%s\001\x1b[23m\002"
-		a.underline = "\001\x1b[4m\002%s\001\x1b[24m\002"
-		a.overline = "\001\x1b[53m\002%s\001\x1b[55m\002"
-		a.blink = "\001\x1b[5m\002%s\001\x1b[25m\002"
-		a.reverse = "\001\x1b[7m\002%s\001\x1b[27m\002"
-		a.dimmed = "\001\x1b[2m\002%s\001\x1b[22m\002"
-		a.strikethrough = "\001\x1b[9m\002%s\001\x1b[29m\002"
+		a.format = "\\[%s\\]"
+		a.linechange = "\\[\x1b[%d%s\\]"
+		a.right = "\\[\x1b[%dC\\]"
+		a.left = "\\[\x1b[%dD\\]"
+		a.creset = "\\[\x1b[0m\\]"
+		a.clearBelow = "\\[\x1b[0J\\]"
+		a.clearLine = "\\[\x1b[K\\]"
+		a.saveCursorPosition = "\\[\x1b7\\]"
+		a.restoreCursorPosition = "\\[\x1b8\\]"
+		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[0m\\]"
+		a.escapeLeft = "\\["
+		a.escapeRight = "\\]"
+		a.hyperlink = "\\[\x1b]8;;%s\x1b\\\\\\]%s\\[\x1b]8;;\x1b\\\\\\]"
+		a.hyperlinkRegex = `(?P<STR>\\\[\x1b\]8;;(.+)\x1b\\\\\\\](?P<TEXT>.+)\\\[\x1b\]8;;\x1b\\\\\\\])`
+		a.osc99 = "\\[\x1b]9;9;\"%s\"\x1b\\\\\\]"
+		a.osc7 = "\\[\x1b]7;\"file://%s/%s\"\x1b\\\\\\]"
+		a.bold = "\\[\x1b[1m\\]%s\\[\x1b[22m\\]"
+		a.italic = "\\[\x1b[3m\\]%s\\[\x1b[23m\\]"
+		a.underline = "\\[\x1b[4m\\]%s\\[\x1b[24m\\]"
+		a.overline = "\\[\x1b[53m\\]%s\\[\x1b[55m\\]"
+		a.blink = "\\[\x1b[5m\\]%s\\[\x1b[25m\\]"
+		a.reverse = "\\[\x1b[7m\\]%s\\[\x1b[27m\\]"
+		a.dimmed = "\\[\x1b[2m\\]%s\\[\x1b[22m\\]"
+		a.strikethrough = "\\[\x1b[9m\\]%s\\[\x1b[29m\\]"
 	default:
 		a.format = "%s"
 		a.linechange = "\x1b[%d%s"
diff --git a/website/blog/2022-05-19-whats-new-3.mdx b/website/blog/2022-05-19-whats-new-3.mdx
index 07f1dab8..dc5ca37e 100644
--- a/website/blog/2022-05-19-whats-new-3.mdx
+++ b/website/blog/2022-05-19-whats-new-3.mdx
@@ -114,7 +114,7 @@ do so like this:
 "template": " {{ if .Segments.Git.UpstreamGone }}\uf7d3{{ else if gt .Code 0 }}\uf00d{{ else }}\uf00c{{ end }} "
 ```
 
-:::warning
+:::caution
 For this to work, the segment you refer to needs to be in your config. The above example won't work if
 your config does not contain a git segment as Oh My Posh only populates the properties when it needs to.
 :::
diff --git a/website/docs/configuration/templates.mdx b/website/docs/configuration/templates.mdx
index b62c789d..3b3d9e6b 100644
--- a/website/docs/configuration/templates.mdx
+++ b/website/docs/configuration/templates.mdx
@@ -102,7 +102,7 @@ do so like this:
 "template": " {{ if .Segments.Git.UpstreamGone }}\uf7d3{{ else if gt .Code 0 }}\uf00d{{ else }}\uf00c{{ end }} "
 ```
 
-:::warning
+:::caution
 For this to work, the segment you refer to needs to be in your config. The above example won't work if
 your config does not contain a git segment as Oh My Posh only populates the properties when it needs to.
 :::
diff --git a/website/docs/installation/customize.mdx b/website/docs/installation/customize.mdx
index 2cbabc8b..683f68ba 100644
--- a/website/docs/installation/customize.mdx
+++ b/website/docs/installation/customize.mdx
@@ -135,7 +135,7 @@ Once altered, reload your config for the changes to take effect.
 </TabItem>
 <TabItem value="nu">
 
-:::warning
+:::caution
 Oh My Posh requires Nushell >= 0.60.0
 :::
 
@@ -166,6 +166,18 @@ source /mylocation/myscript.nu
 
 Once altered, restart Nushell for the changes to take effect.
 
+:::tip
+For the time being, there is a [problem][homebrew-problem] with the initialization using Oh My Posh installed via Homebrew.
+To resolve this, you can use the `--strict` flag which tells Oh My Posh to use the executable name and not the
+full path in the initialization. For example:
+
+```bash
+oh-my-posh init nu --config ~/.jandedobbeleer.omp.json --print --strict | save /mylocation/myscript.nu
+```
+
+This way for a new Oh My Posh version that does not update the initialization script, you don't have to recreate a new one.
+:::
+
 </TabItem>
 </Tabs>
 
@@ -212,3 +224,4 @@ segments section covers how to configure each available segment.
 [default-theme]: https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/themes/default.omp.json
 [jandedobbeleer]: /docs/themes#jandedobbeleer
 [json-schema]: https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
+[homebrew-problem]: https://github.com/JanDeDobbeleer/oh-my-posh/discussions/2644
diff --git a/website/docs/installation/fonts.mdx b/website/docs/installation/fonts.mdx
index 6340d1db..4c0d196f 100644
--- a/website/docs/installation/fonts.mdx
+++ b/website/docs/installation/fonts.mdx
@@ -15,7 +15,7 @@ To see the icons displayed in Oh My Posh, **install** a [Nerd Font][nerdfonts],
 
 Oh My Posh has a CLI to help you select and install a [Nerd Font][nerdfonts] (beta):
 
-:::warning Windows
+:::caution Windows
 This command needs to be executed as admin. The fonts are installed system wide.
 :::
 
diff --git a/website/docs/installation/prompt.mdx b/website/docs/installation/prompt.mdx
index 8264cb49..0f6197aa 100644
--- a/website/docs/installation/prompt.mdx
+++ b/website/docs/installation/prompt.mdx
@@ -49,7 +49,7 @@ Then add the following line.
 oh-my-posh init pwsh | Invoke-Expression
 ```
 
-:::warning Antivirus software
+:::tip Antivirus software
 If adding an exception to your Antivirus software still blocks Oh My Posh for Windows, you can try using the below
 alternate line in your PowerShell profile. This is a drop-in replacement to the above call with Invoke-Expression.
 Tested with PowerShell 7.2.4 with Bitdefender Antivirus installed and requires NO exceptions for oh-my-posh.exe.
@@ -76,7 +76,7 @@ your cmd experience. Follow the installation instructions and make sure you sele
 Integrating Oh My Posh with Clink is easy: create a new file called oh-my-posh.lua in your Clink
 scripts directory (run `clink info` inside cmd to find that file's location).
 
-:::warning
+:::caution
 Use the full path to the config file, not the relative path.
 :::
 
@@ -156,7 +156,7 @@ exec fish
 </TabItem>
 <TabItem value="nu">
 
-:::warning
+:::caution
 Oh My Posh requires Nushell >= 0.60.0
 :::
 
@@ -187,8 +187,21 @@ source /mylocation/myscript.nu
 
 Once added, restart Nushell for the changes to take effect.
 
+:::tip
+For the time being, there is a [problem][homebrew-problem] with the initialization using Oh My Posh installed via Homebrew.
+To resolve this, you can use the `--strict` flag which tells Oh My Posh to use the executable name and not the
+full path in the initialization. For example:
+
+```bash
+oh-my-posh init nu --print --strict | save /mylocation/myscript.nu
+```
+
+This way for a new Oh My Posh version that does not update the initialization script, you don't have to recreate a new one.
+:::
+
 </TabItem>
 </Tabs>
 
 [clink]: https://chrisant996.github.io/clink/
 [iterm2]: https://www.iterm2.com/
+[homebrew-problem]: https://github.com/JanDeDobbeleer/oh-my-posh/discussions/2644
diff --git a/website/docs/installation/windows.mdx b/website/docs/installation/windows.mdx
index 99eff65f..ee7d11e1 100644
--- a/website/docs/installation/windows.mdx
+++ b/website/docs/installation/windows.mdx
@@ -74,7 +74,7 @@ This installs a couple of things:
 
 For the `PATH` to be reloaded, a restart of your terminal is advised.
 
-:::warning Antivirus software
+:::tip Antivirus software
 Due to frequent updates of Oh My Posh, Antivirus software occasionally flags it (false positive).
 To ensure Oh My Posh isn't blocked you can either report it to your favorite Antivirus software as false positive
 (e.g. [Report a false positive/negative to Microsoft for analysis][report-false-positive]) or create an exclusion for it.
diff --git a/website/docs/segments/battery.mdx b/website/docs/segments/battery.mdx
index cb3412a3..96069c72 100644
--- a/website/docs/segments/battery.mdx
+++ b/website/docs/segments/battery.mdx
@@ -7,7 +7,7 @@ sidebar_label: Battery
 ## What
 
 :::caution
-The segment is not supported and automatically disabled on windows when WSL 1 is detected. Works fine with WSL 2.
+The segment is not supported and automatically disabled on Windows when WSL 1 is detected. Works fine with WSL 2.
 :::
 
 Battery displays the remaining power percentage for your battery.
diff --git a/website/docs/segments/git.mdx b/website/docs/segments/git.mdx
index fc789527..63d2b73d 100644
--- a/website/docs/segments/git.mdx
+++ b/website/docs/segments/git.mdx
@@ -22,7 +22,7 @@ To enable this, set `$env:POSH_GIT_ENABLED = $true` in your `$PROFILE`. Be aware
 twice, so in case you're having a slow repository, it's better to migrate to the [Posh-Git segment][poshgit].
 :::
 
-:::warning
+:::caution
 Starting from version 3.152.0, `display_status` is disabled by default.
 It improves performance but reduces the quantity of information. Don't forget to enable it in your theme if needed.
 An alternative is to use the [Posh-Git segment][poshgit].
diff --git a/website/docs/segments/nbgv.mdx b/website/docs/segments/nbgv.mdx
index b85fd344..0c5b854d 100644
--- a/website/docs/segments/nbgv.mdx
+++ b/website/docs/segments/nbgv.mdx
@@ -8,7 +8,7 @@ sidebar_label: Nbgv
 
 Display the [Nerdbank.GitVersioning][nbgv] version.
 
-:::warning
+:::caution
 The Nerdbank.GitVersioning CLI can be a bit slow causing the prompt to feel slow.
 :::
 
diff --git a/website/docs/segments/owm.mdx b/website/docs/segments/owm.mdx
index 1881207a..1cac85d2 100644
--- a/website/docs/segments/owm.mdx
+++ b/website/docs/segments/owm.mdx
@@ -9,7 +9,6 @@ sidebar_label: Open Weather Map
 Shows the current weather of a given location with [Open Weather Map][owm].
 
 :::caution
-
 You **must** request an API key at the [Open Weather Map][owm-price] website.
 The free tier for *Current weather and forecasts collection* is sufficient.
 :::
diff --git a/website/docs/segments/terraform.mdx b/website/docs/segments/terraform.mdx
index 8055f5eb..0bc2d982 100644
--- a/website/docs/segments/terraform.mdx
+++ b/website/docs/segments/terraform.mdx
@@ -9,7 +9,7 @@ sidebar_label: Terraform
 Display the currently active Terraform Workspace name.
 
 :::caution
-This requires a terraform binary in your PATH and will only show in directories that contain a `.terraform` subdirectory
+This requires a terraform binary in your PATH and will only show in directories that contain a `.terraform` subdirectory.
 :::
 
 ## Sample Configuration
diff --git a/website/docs/share-theme.md b/website/docs/share-theme.md
index 8964bb88..1700a93f 100644
--- a/website/docs/share-theme.md
+++ b/website/docs/share-theme.md
@@ -7,7 +7,7 @@ sidebar_label: 📸 Share theme
 You can export your prompt to an image which you can share online. You have the ability to align
 it correctly and add your name for credits too.
 
-:::warning
+:::caution
 Some glyphs aren't rendered correctly, that's not you but the limitations of the renderer.
 Depending on your config, you might have to tweak the output a little bit.
 :::


Test patch:
diff --git a/src/color/ansi_test.go b/src/color/ansi_test.go
index d7a0d374..2dd0a230 100644
--- a/src/color/ansi_test.go
+++ b/src/color/ansi_test.go
@@ -33,7 +33,7 @@ func TestGenerateHyperlinkWithUrl(t *testing.T) {
 	}{
 		{Text: "[google](http://www.google.be)", ShellName: shell.ZSH, Expected: "%{\x1b]8;;http://www.google.be\x1b\\%}google%{\x1b]8;;\x1b\\%}"},
 		{Text: "[google](http://www.google.be)", ShellName: shell.PWSH, Expected: "\x1b]8;;http://www.google.be\x1b\\google\x1b]8;;\x1b\\"},
-		{Text: "[google](http://www.google.be)", ShellName: shell.BASH, Expected: "\001\x1b]8;;http://www.google.be\x1b\\\\\002google\001\x1b]8;;\x1b\\\\\002"},
+		{Text: "[google](http://www.google.be)", ShellName: shell.BASH, Expected: "\\[\x1b]8;;http://www.google.be\x1b\\\\\\]google\\[\x1b]8;;\x1b\\\\\\]"},
 	}
 	for _, tc := range cases {
 		a := Ansi{}