Skip to content

Commit

Permalink
Finish reading ~/.goshrc
Browse files Browse the repository at this point in the history
  • Loading branch information
LarryLuTW committed Oct 2, 2019
1 parent 12f0e15 commit 6d05596
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions main.go
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bufio"
"fmt"
"io"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -109,7 +110,29 @@ func showPrompt() {
fmt.Printf("%s %s > ", userAndHost, wd)
}

func initialize() {
homeDir, _ := os.UserHomeDir()
file, err := os.Open(homeDir + "/.goshrc")
if err != nil {
return
}

goshrcReader := bufio.NewReader(file)

for {
input, err := goshrcReader.ReadString('\n')
if err == io.EOF {
return
}

input = strings.TrimSpace(input)
executeInput(input)
}
}

func main() {
initialize()

stdin := bufio.NewReader(os.Stdin)

for {
Expand Down

0 comments on commit 6d05596

Please sign in to comment.