Compare commits

..

No commits in common. "59963add14c7d0134795d4f928efb75b0af1251e" and "5175367b35c6581cf2594589be06f849157823d1" have entirely different histories.

2 changed files with 12 additions and 22 deletions

View File

@ -20,13 +20,8 @@ func newFileHistory() (*fileHistory, error) {
}
}
itms := []string{""}
lines := strings.Split(string(data), "\n")
for i, l := range lines {
if i == len(lines) - 1 {
println(i, l)
continue
}
var itms []string
for _, l := range strings.Split(string(data), "\n") {
itms = append(itms, l)
}
f, err := os.OpenFile(defaultHistPath, os.O_RDWR | os.O_CREATE, 0755)

25
rl.go
View File

@ -60,24 +60,19 @@ func newLineReader(prompt string) *lineReader {
ctx = aliases.Resolve(ctx)
if len(fields) == 1 {
prefixes := []string{"./", "../", "/", "~/"}
for _, prefix := range prefixes {
if strings.HasPrefix(query, prefix) {
fileCompletions := fileComplete(query, ctx, fields)
if len(fileCompletions) != 0 {
for _, f := range fileCompletions {
name := strings.Replace(query + f, "~", curuser.HomeDir, 1)
if info, err := os.Stat(name); err == nil && info.Mode().Perm() & 0100 == 0 {
continue
}
completions = append(completions, f)
}
compGroup[0].Suggestions = completions
fileCompletions := fileComplete(query, ctx, fields)
if len(fileCompletions) != 0 {
for _, f := range fileCompletions {
name := strings.Replace(query + f, "~", curuser.HomeDir, 1)
if info, err := os.Stat(name); err == nil && info.Mode().Perm() & 0100 == 0 {
continue
}
return "", compGroup
completions = append(completions, f)
}
compGroup[0].Suggestions = completions
return "", compGroup
}
// filter out executables, but in path
for _, dir := range filepath.SplitList(os.Getenv("PATH")) {
// print dir to stderr for debugging