Skip to content

Commit

Permalink
Merge pull request #18 from strangebug/master
Browse files Browse the repository at this point in the history
Add unix variants hints. Add windows specific implementation.
  • Loading branch information
justjanne authored Aug 25, 2017
2 parents bae2b36 + b6188c3 commit f29521b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion segment-readonly.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// +build !windows

package main

import (
"fmt"
"golang.org/x/sys/unix"
"os"

"golang.org/x/sys/unix"
)

func segmentPerms(p *powerline) {
Expand Down
26 changes: 26 additions & 0 deletions segment-readonly_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// +build windows

package main

import (
"fmt"
"os"
)

func segmentPerms(p *powerline) {
cwd := p.cwd
if cwd == "" {
cwd, _ = os.LookupEnv("PWD")
}

const W_USR = 0002
// Check user's permissions on directory in a portable but probably slower way
fileInfo, _ := os.Stat(cwd)
if fileInfo.Mode()&W_USR != W_USR {
p.appendSegment("perms", segment{
content: fmt.Sprintf(" %s ", p.symbolTemplates.Lock),
foreground: p.theme.ReadonlyFg,
background: p.theme.ReadonlyBg,
})
}
}

0 comments on commit f29521b

Please sign in to comment.