forked from JanDeDobbeleer/oh-my-posh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83246df
commit 320ec1d
Showing
7 changed files
with
107 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
id: poshgit | ||
title: Posh-Git | ||
sidebar_label: Posh-Git | ||
--- | ||
|
||
## What | ||
|
||
Display the [posh-git][posh-git] prompt. | ||
|
||
:::info | ||
This segment only works within Powershell and requires the posh-git module to be installed and imported. | ||
::: | ||
|
||
## Sample Configuration | ||
|
||
```json | ||
{ | ||
"type": "poshgit", | ||
"style": "powerline", | ||
"powerline_symbol": "\uE0B0", | ||
"foreground": "#ffffff", | ||
"background": "#0077c2" | ||
} | ||
``` | ||
|
||
[posh-git]: https://github.com/dahlbyk/posh-git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ module.exports = { | |
"node", | ||
"os", | ||
"path", | ||
"poshgit", | ||
"python", | ||
"root", | ||
"ruby", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import "strings" | ||
|
||
type poshgit struct { | ||
props *properties | ||
env environmentInfo | ||
gitStatus string | ||
} | ||
|
||
const ( | ||
poshGitEnv = "POSH_GIT_STATUS" | ||
) | ||
|
||
func (p *poshgit) enabled() bool { | ||
status := p.env.getenv(poshGitEnv) | ||
p.gitStatus = strings.TrimSpace(status) | ||
return p.gitStatus != "" | ||
} | ||
|
||
func (p *poshgit) string() string { | ||
return p.gitStatus | ||
} | ||
|
||
func (p *poshgit) init(props *properties, env environmentInfo) { | ||
p.props = props | ||
p.env = env | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestPoshGitSegment(t *testing.T) { | ||
cases := []struct { | ||
Case string | ||
PoshGitPrompt string | ||
Expected string | ||
Enabled bool | ||
}{ | ||
{Case: "regular prompt", PoshGitPrompt: "my prompt", Expected: "my prompt", Enabled: true}, | ||
{Case: "prompt with spaces", PoshGitPrompt: " my prompt", Expected: "my prompt", Enabled: true}, | ||
{Case: "no prompt", PoshGitPrompt: "", Enabled: false}, | ||
} | ||
|
||
for _, tc := range cases { | ||
env := new(MockedEnvironment) | ||
env.On("getenv", poshGitEnv).Return(tc.PoshGitPrompt) | ||
p := &poshgit{ | ||
env: env, | ||
} | ||
assert.Equal(t, tc.Enabled, p.enabled()) | ||
if tc.Enabled { | ||
assert.Equal(t, tc.Expected, p.string()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters