mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 04:19:41 -08:00
parent
b0c7e66ae1
commit
b152e9df29
|
@ -36,6 +36,7 @@ Display the current path.
|
||||||
Style sets the way the path is displayed. Based on previous experience and popular themes, there are 4 flavors.
|
Style sets the way the path is displayed. Based on previous experience and popular themes, there are 4 flavors.
|
||||||
|
|
||||||
- agnoster
|
- agnoster
|
||||||
|
- agnoster_full
|
||||||
- short
|
- short
|
||||||
- full
|
- full
|
||||||
- folder
|
- folder
|
||||||
|
@ -46,6 +47,10 @@ Renders each folder as the `folder_icon` separated by the `folder_separator_icon
|
||||||
Only the current folder name is displayed at the end, `$HOME` is replaced by the `home_icon` if you're
|
Only the current folder name is displayed at the end, `$HOME` is replaced by the `home_icon` if you're
|
||||||
inside the `$HOME` location or one of its children.
|
inside the `$HOME` location or one of its children.
|
||||||
|
|
||||||
|
### Agnoster Full
|
||||||
|
|
||||||
|
Renders each folder name separated by the `folder_separator_icon`.
|
||||||
|
|
||||||
### Short
|
### Short
|
||||||
|
|
||||||
Display `$PWD` as a string, replace `$HOME` with the `home_icon` if you're inside the `$HOME` location or
|
Display `$PWD` as a string, replace `$HOME` with the `home_icon` if you're inside the `$HOME` location or
|
||||||
|
|
|
@ -23,6 +23,8 @@ const (
|
||||||
WindowsRegistryIcon Property = "windows_registry_icon"
|
WindowsRegistryIcon Property = "windows_registry_icon"
|
||||||
//Agnoster displays a short path with separator icon, this the default style
|
//Agnoster displays a short path with separator icon, this the default style
|
||||||
Agnoster string = "agnoster"
|
Agnoster string = "agnoster"
|
||||||
|
//AgnosterFull displays all the folder names with the folder_separator_icon
|
||||||
|
AgnosterFull string = "agnoster_full"
|
||||||
//Short displays a shorter path
|
//Short displays a shorter path
|
||||||
Short string = "short"
|
Short string = "short"
|
||||||
//Full displays the full path
|
//Full displays the full path
|
||||||
|
@ -39,6 +41,8 @@ func (pt *path) string() string {
|
||||||
switch style := pt.props.getString(Style, Agnoster); style {
|
switch style := pt.props.getString(Style, Agnoster); style {
|
||||||
case Agnoster:
|
case Agnoster:
|
||||||
return pt.getAgnosterPath()
|
return pt.getAgnosterPath()
|
||||||
|
case AgnosterFull:
|
||||||
|
return pt.getAgnosterFullPath()
|
||||||
case Short:
|
case Short:
|
||||||
return pt.getShortPath()
|
return pt.getShortPath()
|
||||||
case Full:
|
case Full:
|
||||||
|
@ -85,6 +89,16 @@ func (pt *path) getAgnosterPath() string {
|
||||||
return buffer.String()
|
return buffer.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pt *path) getAgnosterFullPath() string {
|
||||||
|
pwd := pt.env.getcwd()
|
||||||
|
pathSeparator := pt.env.getPathSeperator()
|
||||||
|
folderSeparator := pt.props.getString(FolderSeparatorIcon, pathSeparator)
|
||||||
|
if string(pwd[0]) == pathSeparator {
|
||||||
|
pwd = pwd[1:]
|
||||||
|
}
|
||||||
|
return strings.Replace(pwd, pathSeparator, folderSeparator, -1)
|
||||||
|
}
|
||||||
|
|
||||||
func (pt *path) inHomeDir(pwd string) bool {
|
func (pt *path) inHomeDir(pwd string) bool {
|
||||||
return strings.HasPrefix(pwd, pt.env.homeDir())
|
return strings.HasPrefix(pwd, pt.env.homeDir())
|
||||||
}
|
}
|
||||||
|
|
|
@ -346,6 +346,23 @@ func TestPathDepthOutsideHomeOneLevelDeep(t *testing.T) {
|
||||||
assert.Equal(t, 1, got)
|
assert.Equal(t, 1, got)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetAgnosterFullPath(t *testing.T) {
|
||||||
|
pwd := "/usr/location/whatever"
|
||||||
|
env := new(MockedEnvironment)
|
||||||
|
env.On("getPathSeperator", nil).Return("/")
|
||||||
|
env.On("getcwd", nil).Return(pwd)
|
||||||
|
path := &path{
|
||||||
|
env: env,
|
||||||
|
props: &properties{
|
||||||
|
values: map[Property]interface{}{
|
||||||
|
FolderSeparatorIcon: " > ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
got := path.getAgnosterFullPath()
|
||||||
|
assert.Equal(t, "usr > location > whatever", got)
|
||||||
|
}
|
||||||
|
|
||||||
func testWritePathInfo(home string, pwd string, pathSeparator string) string {
|
func testWritePathInfo(home string, pwd string, pathSeparator string) string {
|
||||||
props := &properties{
|
props := &properties{
|
||||||
values: map[Property]interface{}{
|
values: map[Property]interface{}{
|
||||||
|
|
Loading…
Reference in a new issue