Skip to content

Commit

Permalink
Merge pull request #65 from Equationzhao/v0.12.0
Browse files Browse the repository at this point in the history
new minor version
  • Loading branch information
Equationzhao authored Aug 9, 2023
2 parents 445a617 + 52bfb05 commit e2009e3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/g.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var (
pool *ants.Pool
)

var Version = "0.11.5"
var Version = "0.12.0"

var G *cli.App

Expand Down Expand Up @@ -252,7 +252,7 @@ func init() {
start := time.Now()

if len(path) > 1 {
fmt.Printf("%s:\n", path[i])
fmt.Println(r.DirPrompt(path[i]), ":")
}

if transformEnabled {
Expand Down
20 changes: 16 additions & 4 deletions render/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (rd *Renderer) RTime(now, modTime time.Time) string {
func (rd *Renderer) ByName(toRender string) string {
bb := bytebufferpool.Get()
defer bytebufferpool.Put(bb)
name := strings.ToLower(toRender)
name := strings.ToLower(filepath.Base(toRender))
style, ok := rd.theme.Name[name]
if !ok {
return ""
Expand All @@ -260,7 +260,7 @@ func (rd *Renderer) ByName(toRender string) string {
func (rd *Renderer) ByNameIcon(toRender string) string {
bb := bytebufferpool.Get()
defer bytebufferpool.Put(bb)
name := strings.ToLower(toRender)
name := strings.ToLower(filepath.Base(toRender))
style, ok := rd.theme.Name[name]
if !ok {
return ""
Expand Down Expand Up @@ -360,7 +360,7 @@ func (rd *Renderer) SymlinkIconPlus(toRender string, path string, plus string, r
}
}
symlinks = pathErr.Path
}else{
} else {
symlinks = err.Error()
}
_, _ = bb.WriteString(symlinks)
Expand Down Expand Up @@ -430,7 +430,7 @@ func (rd *Renderer) SymlinkPlus(toRender string, path string, plus string, rel b
}
}
symlinks = pathErr.Path
}else{
} else {
symlinks = err.Error()
}
_, _ = bb.WriteString(symlinks)
Expand Down Expand Up @@ -669,6 +669,18 @@ func (rd *Renderer) Inode(inode string) string {
return rd.infoByName(inode, "inode")
}

func (rd *Renderer) DirPrompt(dir string) string {
bb := bytebufferpool.Get()
defer bytebufferpool.Put(bb)
style := rd.theme.Special["dir-prompt"]
_, _ = bb.WriteString(style.Color)
checkUnderlineAndBold(&style, bb)
_, _ = bb.WriteString(style.Icon)
_, _ = bb.WriteString(dir)
_, _ = bb.WriteString(rd.theme.InfoTheme["reset"].Color)
return bb.String()
}

func checkUnderlineAndBold(style *theme.Style, bb *bytebufferpool.ByteBuffer) {
if style.Underline {
_, _ = bb.WriteString(theme.Underline)
Expand Down
4 changes: 4 additions & 0 deletions theme/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,10 @@ var Special = map[string]Style{
Color: dir,
Icon: "\uF115",
},
"dir-prompt": {
Color: Yellow,
Icon: "► ",
},
"pipe": {
Color: Cyan,
Icon: "\uF124",
Expand Down
6 changes: 5 additions & 1 deletion theme/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
},
"license": {
"color": "[214]@256",
"icon": ""
"icon": ""
},
"links": {
"color": "white",
Expand Down Expand Up @@ -427,6 +427,10 @@
"color": "BrightBlue",
"icon": ""
},
"dir-prompt": {
"color": "yellow",
"icon": ""
},
"exe": {
"color": "green",
"icon": ""
Expand Down

0 comments on commit e2009e3

Please sign in to comment.