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
|
||||
}
|
||||
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 {
|
||||
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(
|
||||
vibin,
|
||||
[]string{vibin, tempFile},
|
||||
editorbin,
|
||||
args,
|
||||
&syscall.ProcAttr{
|
||||
Dir: "",
|
||||
Env: os.Environ(),
|
||||
|
|
|
|||
10
todo.yaml
10
todo.yaml
|
|
@ -1,8 +1,6 @@
|
|||
todo:
|
||||
- todo: crap losing on a bad edit hurts
|
||||
details: |
|
||||
?
|
||||
- vim doesnt source vimrc
|
||||
- vim doesnt source vimrc, so stuff like tab width and tab characters, also syntax
|
||||
highlight :(
|
||||
- todo: when to run scheduled modifier? like, syncthing could have conflicts if I
|
||||
modify only file on remote
|
||||
ts: 1641007992
|
||||
|
|
@ -39,3 +37,7 @@ done:
|
|||
ts: 1641007992
|
||||
subtasks:
|
||||
- a
|
||||
- todo: crap losing on a bad edit hurts
|
||||
ts: 1641008278
|
||||
details: |
|
||||
?
|
||||
|
|
|
|||
Loading…
Reference in New Issue