use $EDITOR, default to vim, use $HOME/.vimrc if exists
parent
967a02c90a
commit
3c9b34202b
|
|
@ -61,13 +61,25 @@ func edit(dry bool, filepath string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
vi := func() error {
|
vi := func() error {
|
||||||
vibin, err := exec.LookPath("vi")
|
bin := "vim"
|
||||||
|
if editor := os.Getenv("EDITOR"); editor != "" {
|
||||||
|
bin = editor
|
||||||
|
}
|
||||||
|
editorbin, err := exec.LookPath(bin)
|
||||||
|
if err != nil {
|
||||||
|
editorbin, err = exec.LookPath("vi")
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
args := []string{editorbin, tempFile}
|
||||||
|
vimrc := path.Join(os.Getenv("HOME"), ".vimrc")
|
||||||
|
if _, err := os.Stat(vimrc); err == nil {
|
||||||
|
args = append(args, "-u", vimrc)
|
||||||
|
}
|
||||||
cpid, err := syscall.ForkExec(
|
cpid, err := syscall.ForkExec(
|
||||||
vibin,
|
editorbin,
|
||||||
[]string{vibin, tempFile},
|
args,
|
||||||
&syscall.ProcAttr{
|
&syscall.ProcAttr{
|
||||||
Dir: "",
|
Dir: "",
|
||||||
Env: os.Environ(),
|
Env: os.Environ(),
|
||||||
|
|
|
||||||
10
todo.yaml
10
todo.yaml
|
|
@ -1,8 +1,6 @@
|
||||||
todo:
|
todo:
|
||||||
- todo: crap losing on a bad edit hurts
|
- vim doesnt source vimrc, so stuff like tab width and tab characters, also syntax
|
||||||
details: |
|
highlight :(
|
||||||
?
|
|
||||||
- vim doesnt source vimrc
|
|
||||||
- todo: when to run scheduled modifier? like, syncthing could have conflicts if I
|
- todo: when to run scheduled modifier? like, syncthing could have conflicts if I
|
||||||
modify only file on remote
|
modify only file on remote
|
||||||
ts: 1641007992
|
ts: 1641007992
|
||||||
|
|
@ -39,3 +37,7 @@ done:
|
||||||
ts: 1641007992
|
ts: 1641007992
|
||||||
subtasks:
|
subtasks:
|
||||||
- a
|
- a
|
||||||
|
- todo: crap losing on a bad edit hurts
|
||||||
|
ts: 1641008278
|
||||||
|
details: |
|
||||||
|
?
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue