Skip to content

Commit

Permalink
feat(path): use second letter for .folder
Browse files Browse the repository at this point in the history
resolves #886
  • Loading branch information
JanDeDobbeleer committed Aug 10, 2021
1 parent 84183b7 commit 68f5766
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/segment_path.go
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/segment_path_test.go
Expand Up @@ -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)
Expand Down

0 comments on commit 68f5766

Please sign in to comment.