diff --git a/src/segment_path.go b/src/segment_path.go index 5d9b2c3f..a3504958 100644 --- a/src/segment_path.go +++ b/src/segment_path.go @@ -149,11 +149,17 @@ func (pt *path) getLetterPath() string { splitted := strings.Split(pwd, pt.env.getPathSeperator()) separator := pt.props.getString(FolderSeparatorIcon, pt.env.getPathSeperator()) for i := 0; i < len(splitted)-1; i++ { - if len(splitted[i]) == 0 { + folder := splitted[i] + if len(folder) == 0 { continue } - letter := []rune(splitted[i])[0] - buffer.WriteString(fmt.Sprintf("%c%s", letter, separator)) + var letter string + if strings.HasPrefix(folder, ".") && len(folder) > 1 { + letter = folder[0:2] + } else { + letter = folder[0:1] + } + buffer.WriteString(fmt.Sprintf("%s%s", letter, separator)) } buffer.WriteString(splitted[len(splitted)-1]) return buffer.String() diff --git a/src/segment_path_test.go b/src/segment_path_test.go index e30e7ad2..c124c40b 100644 --- a/src/segment_path_test.go +++ b/src/segment_path_test.go @@ -299,6 +299,8 @@ func TestAgnosterPathStyles(t *testing.T) { {Style: Letter, Expected: "~ > a > w > man", HomePath: "/usr/home", Pwd: "/usr/home/ab/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "}, {Style: Letter, Expected: "u > b > a > w > man", HomePath: "/usr/home", Pwd: "/usr/burp/ab/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "}, + {Style: Letter, Expected: "u > .b > a > w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/ab/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "}, + {Style: Letter, Expected: "u > .b > a > .w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/ab/.whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "}, } for _, tc := range cases { env := new(MockedEnvironment)