1 parent
61c8b588cd
commit
c3f4aa58a7
6 files changed
+122
-37
No files matched your search
@@ -9,6 +9,13 @@ import (
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var (
|
||||
envEditor = os.Getenv("EDITOR")
|
||||
envPager = os.Getenv("PAGER")
|
||||
envShell = os.Getenv("SHELL")
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -85,6 +92,32 @@ func putCommand(list []string, dir *dir, copy bool) *exec.Cmd {
|
||||
return exec.Command(sh, args...)
|
||||
}
|
||||
|
||||
func setDefaults() {
|
||||
if envEditor == "" {
|
||||
gOpts.keys["e"] = &execExpr{"$", `vi "$f"`}
|
||||
} else {
|
||||
gOpts.keys["e"] = &execExpr{"$", envEditor + ` "$f"`}
|
||||
}
|
||||
|
||||
if envPager == "" {
|
||||
gOpts.keys["i"] = &execExpr{"$", `less "$f"`}
|
||||
} else {
|
||||
gOpts.keys["i"] = &execExpr{"$", envPager + ` "$f"`}
|
||||
}
|
||||
|
||||
if envShell == "" {
|
||||
gOpts.keys["w"] = &execExpr{"$", "sh"}
|
||||
} else {
|
||||
gOpts.keys["w"] = &execExpr{"$", envShell}
|
||||
}
|
||||
|
||||
if runtime.GOOS == "darwin" {
|
||||
gOpts.cmds["open-file"] = &execExpr{"&", `open "$f"`}
|
||||
} else {
|
||||
gOpts.cmds["open-file"] = &execExpr{"&", `xdg-open "$f"`}
|
||||
}
|
||||
}
|
||||
|
||||
func moveCursor(y, x int) {
|
||||
fmt.Printf("\033[%d;%dH", y, x)
|
||||
}
|
||||
Reference in new issue
Block a user