Repository: JanDeDobbeleer/oh-my-posh
Pull request #4743 (2024-03-05 11:55:53)

theme(atomic): add space between double width icons
### Prerequisites

- [x] I have read and understood the [contributing guide][CONTRIBUTING.md].
- [x] The commit message follows the [conventional commits][cc] guidelines.
- [x] Tests for the changes have been added (for bug fixes / features).
- [x] Docs have been added/updated (for bug fixes / features).

<!---

Tips:

If you're not comfortable with working with Git,
we're working a guide (https://ohmyposh.dev/docs/contributing_git) to help you out.
Oh My Posh advises GitKraken (https://www.gitkraken.com/invite/nQmDPR9D) as your preferred cross platform Git GUI power tool.

-->

[CONTRIBUTING.md]: https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/CONTRIBUTING.md
[cc]: https://www.conventionalcommits.org/en/v1.0.0/#summary



Patch:
diff --git a/.all-contributorsrc b/.all-contributorsrc
index 2c58da34..dcc6591f 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -2289,6 +2289,16 @@
       "contributions": [
         "code"
       ]
+    },
+    {
+      "login": "rockyoung",
+      "name": "rockyoung",
+      "avatar_url": "https://avatars.githubusercontent.com/u/1207971?v=4",
+      "profile": "https://github.com/rockyoung",
+      "contributions": [
+        "code",
+        "doc"
+      ]
     }
   ],
   "contributorsPerLine": 7,
diff --git a/src/segments/python.go b/src/segments/python.go
index ba33a2ca..49cace56 100644
--- a/src/segments/python.go
+++ b/src/segments/python.go
@@ -21,6 +21,7 @@ const (
 	// FetchVirtualEnv fetches the virtual env
 	FetchVirtualEnv      properties.Property = "fetch_virtual_env"
 	UsePythonVersionFile properties.Property = "use_python_version_file"
+	FolderNameFallback   properties.Property = "folder_name_fallback"
 )
 
 func (p *Python) Template() string {
@@ -74,6 +75,7 @@ func (p *Python) loadContext() {
 		"CONDA_DEFAULT_ENV",
 	}
 
+	folderNameFallback := p.language.props.GetBool(FolderNameFallback, true)
 	defaultVenvNames := []string{
 		".venv",
 		"venv",
@@ -87,8 +89,7 @@ func (p *Python) loadContext() {
 		}
 
 		name := platform.Base(p.language.env, venv)
-
-		if slices.Contains(defaultVenvNames, name) {
+		if folderNameFallback && slices.Contains(defaultVenvNames, name) {
 			venv = strings.TrimSuffix(venv, name)
 			name = platform.Base(p.language.env, venv)
 		}
diff --git a/src/segments/spotify_darwin.go b/src/segments/spotify_darwin.go
index 61ba5c05..d468ceef 100644
--- a/src/segments/spotify_darwin.go
+++ b/src/segments/spotify_darwin.go
@@ -3,24 +3,28 @@
 package segments
 
 func (s *Spotify) Enabled() bool {
-	var err error
 	// Check if running
 	running := s.runAppleScriptCommand("application \"Spotify\" is running")
 	if running == "false" || running == "" {
 		s.Status = stopped
 		return false
 	}
+
 	s.Status = s.runAppleScriptCommand("tell application \"Spotify\" to player state as string")
-	if err != nil {
+
+	if len(s.Status) == 0 {
 		s.Status = stopped
 		return false
 	}
+
 	if s.Status == stopped {
 		return false
 	}
+
 	s.Artist = s.runAppleScriptCommand("tell application \"Spotify\" to artist of current track as string")
 	s.Track = s.runAppleScriptCommand("tell application \"Spotify\" to name of current track as string")
 	s.resolveIcon()
+
 	return true
 }
 
diff --git a/themes/atomic.omp.json b/themes/atomic.omp.json
index a0425066..02e10f77 100644
--- a/themes/atomic.omp.json
+++ b/themes/atomic.omp.json
@@ -29,7 +29,7 @@
             "style": "folder"
           },
           "style": "powerline",
-          "template": " \uf07b\uea9c{{ .Path }} ",
+          "template": " \uf07b\uea9c {{ .Path }} ",
           "type": "path"
         },
         {
@@ -59,7 +59,7 @@
             "threshold": 0
           },
           "style": "diamond",
-          "template": " \ueba2{{ .FormattedMs }}\u2800",
+          "template": " \ueba2 {{ .FormattedMs }}\u2800",
           "trailing_diamond": "\ue0b4",
           "type": "executiontime"
         }
diff --git a/website/docs/contributors.md b/website/docs/contributors.md
index 9cf7302c..d8fa10d4 100644
--- a/website/docs/contributors.md
+++ b/website/docs/contributors.md
@@ -328,6 +328,7 @@ Thanks goes to these wonderful people ([emoji key][acek]):
     </tr>
     <tr>
       <td align="center" valign="top" width="14.28%"><a href="http://krason.dev/"><img src="https://avatars.githubusercontent.com/u/11185582?v=4?s=100" width="100px;" alt="Grzegorz Krasoń"/><br /><sub><b>Grzegorz Krasoń</b></sub></a><br /><a href="https://github.com/JanDeDobbeleer/oh-my-posh/commits?author=gergelyk" title="Code">💻</a></td>
+      <td align="center" valign="top" width="14.28%"><a href="https://github.com/rockyoung"><img src="https://avatars.githubusercontent.com/u/1207971?v=4?s=100" width="100px;" alt="rockyoung"/><br /><sub><b>rockyoung</b></sub></a><br /><a href="https://github.com/JanDeDobbeleer/oh-my-posh/commits?author=rockyoung" title="Code">💻</a> <a href="https://github.com/JanDeDobbeleer/oh-my-posh/commits?author=rockyoung" title="Documentation">📖</a></td>
     </tr>
   </tbody>
 </table>
diff --git a/website/docs/segments/python.mdx b/website/docs/segments/python.mdx
index 6179b81f..3e5a706f 100644
--- a/website/docs/segments/python.mdx
+++ b/website/docs/segments/python.mdx
@@ -9,8 +9,6 @@ sidebar_label: Python
 Display the currently active python version and virtualenv.
 Supports conda, virtualenv and pyenv (if python points to pyenv shim).
 
-If your virtual environment is a directory named `venv` or `.venv`, the virtual environment's name will be the parent directory.
-
 ## Sample Configuration
 
 import Config from "@site/src/components/Config.js";
@@ -38,8 +36,9 @@ import Config from "@site/src/components/Config.js";
 | `display_mode`         | `string`   | <ul><li>`always`: the segment is always displayed</li><li>`files`: the segment is only displayed when one of the following files is present:<ul><li>`*.py`</li><li>`*.ipynb`</li><li>`pyproject.toml`</li><li>`venv.bak`</li><li>`venv`</li><li>`.venv`</li></ul></li><li>`environment`: the segment is only displayed when a virtual env is present (**default**)</li><li>`context`: the segment is only displayed when either `environment` or `files` is active</li></ul> |
 | `version_url_template` | `string`   | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes                                                                                                                                                                                                                                                                                                                                                        |
 | `extensions`           | `[]string` | allows to override the default list of file extensions to validate                                                                                                                                                                                                                                                                                                                                                                                                           |
-| `folders`              | `[]string` | allows to override the list of folder names to validate                                                                                                                                                                                                                                                                                                                                                                                                                     |
+| `folders`              | `[]string` | allows to override the list of folder names to validate                                                                                                                                                                                                                                                                                                                                                                                                                      |
 | `cache_version`        | `boolean`  | cache the executable's version or not - defaults to `false`                                                                                                                                                                                                                                                                                                                                                                                                                  |
+| `folder_name_fallback` | `boolean`  | instead of `venv` or `.venv` (case sensitive), use the parent folder name as the virtual environment's name or not - defaults to `true`                                                                                                                                                                                                                                                                                                                                      |
 
 ## Template ([info][templates])
 


Test patch:
diff --git a/src/segments/python_test.go b/src/segments/python_test.go
index c5794d0e..63754473 100644
--- a/src/segments/python_test.go
+++ b/src/segments/python_test.go
@@ -150,14 +150,36 @@ func TestPythonPythonInContext(t *testing.T) {
 
 func TestPythonVirtualEnvIgnoreDefaultVenvNames(t *testing.T) {
 	cases := []struct {
-		VirtualEnvName string
+		Expected           string
+		FolderNameFallback bool
+		VirtualEnvName     string
 	}{
-		{VirtualEnvName: "/path/to/folder/.venv"},
-		{VirtualEnvName: "/path/to/folder/venv"},
+		{
+			Expected:           "folder",
+			FolderNameFallback: true,
+			VirtualEnvName:     "/path/to/folder/.venv",
+		},
+		{
+			Expected:           "folder",
+			FolderNameFallback: true,
+			VirtualEnvName:     "/path/to/folder/venv",
+		},
+		{
+			Expected:           ".venv",
+			FolderNameFallback: false,
+			VirtualEnvName:     "/path/to/folder/.venv",
+		},
+		{
+			Expected:           "venv",
+			FolderNameFallback: false,
+			VirtualEnvName:     "/path/to/folder/venv",
+		},
 	}
 
 	for _, tc := range cases {
-		env := new(mock.MockedEnvironment)
+		params := &mockedLanguageParams{}
+		env, props := getMockedLanguageEnv(params)
+
 		env.On("GOOS").Return("")
 		env.On("PathSeparator").Return("/")
 		env.On("CommandPath", mock2.Anything).Return("")
@@ -167,9 +189,12 @@ func TestPythonVirtualEnvIgnoreDefaultVenvNames(t *testing.T) {
 		env.On("Getenv", "CONDA_DEFAULT_ENV").Return("")
 		env.On("Getenv", "PYENV_VERSION").Return("")
 		env.On("HasParentFilePath", ".python-version").Return(&platform.FileInfo{}, errors.New("no match at root level"))
+
+		props[FolderNameFallback] = tc.FolderNameFallback
+
 		python := &Python{}
-		python.Init(properties.Map{}, env)
+		python.Init(props, env)
 		python.loadContext()
-		assert.Equal(t, "folder", python.Venv)
+		assert.Equal(t, tc.Expected, python.Venv)
 	}
 }