44 lines
584 B
Go
44 lines
584 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
// "os/exec"
|
|
"log"
|
|
"path"
|
|
// "syscall"
|
|
"fmt"
|
|
)
|
|
|
|
var (
|
|
histFile string = ".cd_history"
|
|
)
|
|
|
|
func main() {
|
|
|
|
histFileDir, err := os.UserHomeDir()
|
|
if err != nil {
|
|
log.Fatal(err, "Can't find home directory.")
|
|
}
|
|
histFile := path.Join(histFileDir, histFile)
|
|
|
|
if len(os.Args) > 1 && os.Args[1] == "--" {
|
|
histList(histFile)
|
|
os.Exit(1)
|
|
}
|
|
|
|
if len(os.Args) > 1 && os.Args[1] == "-i" {
|
|
makeBashFunc()
|
|
os.Exit(1)
|
|
}
|
|
|
|
if len(os.Args) > 1 {
|
|
path := os.Args[1]
|
|
histAdd(histFile, path)
|
|
fmt.Printf("%s", path)
|
|
os.Exit(0)
|
|
}
|
|
|
|
|
|
return
|
|
}
|