Expand ~ in file opening

This commit is contained in:
Zachary Yedidia
2016-04-22 09:23:01 -04:00
parent bbda5d59d0
commit acabfcb8bb

View File

@@ -3,6 +3,7 @@ package main
import (
"github.com/atotto/clipboard"
"github.com/gdamore/tcell"
"github.com/mitchellh/go-homedir"
"io/ioutil"
"strconv"
"strings"
@@ -280,6 +281,8 @@ func (v *View) OpenFile() {
if canceled {
return
}
home, _ := homedir.Dir()
filename = strings.Replace(filename, "~", home, 1)
file, err := ioutil.ReadFile(filename)
if err != nil {