diff --git a/content.go b/content.go index 9f07662..bcfc9b2 100644 --- a/content.go +++ b/content.go @@ -6,6 +6,7 @@ import ( ui "github.com/gizak/termui/v3" "github.com/gizak/termui/v3/widgets" "os" + "runtime" "sort" "strings" ) @@ -97,12 +98,18 @@ func (e EntrySlice) Swap(i, j int) { e[i], e[j] = e[j], e[i] } // 加载并解析文件 func (c *Content) loadContent() { + + var files []string c.entries = make([]*Entry, 0) - homedir, err := os.UserHomeDir() - if err != nil { - homedir = "/usr/local/bin/" + if runtime.GOOS == "darwin" || runtime.GOOS == "linux"{ + homedir, err := os.UserHomeDir() + if err != nil { + homedir = "/usr/local/bin/" + } + files = Files(homedir + "/.files") + } else { + panic("nonsupport system") } - files := Files(homedir + "/.files") for _, file := range files { entries := make([]*Entry, 0) diff --git a/fastfind b/fastfind index eeb7917..d54729a 100755 Binary files a/fastfind and b/fastfind differ diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index 4b7a9c8..9b1433b --- a/install.sh +++ b/install.sh @@ -1,4 +1,4 @@ #!/bin/bash chmod +x fastfind cp fastfind /usr/local/bin -cp -r files ~/.files +cp -r .files ~/.files diff --git a/main.go b/main.go index 3fd033b..c740135 100644 --- a/main.go +++ b/main.go @@ -42,9 +42,9 @@ func main() { uiEvents := ui.PollEvents() for { e := <-uiEvents - //if e.Type != ui.KeyboardEvent { - // continue - //} + if e.Type != ui.KeyboardEvent { + continue + } var next bool var repeat = true