Skip to content

Commit e23d335

Browse files
committed
Inject names for current and parent directories.
Resolves #23
1 parent 9e6f171 commit e23d335

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

node/root.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/drn/nerd-ls/icon"
66
"os"
77
"os/user"
8+
"path/filepath"
89
"syscall"
910
"time"
1011
)
@@ -58,7 +59,14 @@ func name(file os.FileInfo) string {
5859
if !file.IsDir() {
5960
return file.Name()
6061
}
61-
return fmt.Sprintf("%s/", file.Name())
62+
name := fmt.Sprintf("%s/", file.Name())
63+
// inject name for current and parent directories
64+
// TODO: properly inject names for non-current directories
65+
if file.Name() == "." || file.Name() == ".." {
66+
fullpath, _ := filepath.Abs(file.Name())
67+
name = fmt.Sprintf("%s [%s]", name, filepath.Base(fullpath))
68+
}
69+
return name
6270
}
6371

6472
func fetchIcon(file os.FileInfo) rune {

0 commit comments

Comments
 (0)