Also mentioned at (https://github.com/aditya-K2/gomp/issues/1#issuecomment-1205090265)

`~` is not expanded to home directory, Hence adding an internal check
for the same.
This commit is contained in:
aditya-K2
2022-09-12 23:16:24 +05:30
parent 6830b5379f
commit 29b796a552
2 changed files with 21 additions and 0 deletions

View File

@@ -2,6 +2,8 @@ package utils
import (
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"
"syscall"
@@ -117,6 +119,17 @@ func CheckDirectoryFmt(path string) string {
}
}
func ExpandHomeDir(path string) string {
HOME_DIR, _ := os.UserHomeDir()
if strings.HasPrefix(path, "~/") {
return filepath.Join(HOME_DIR, path[1:])
} else if path == "~" {
return HOME_DIR
} else {
return path
}
}
func GetMatchedString(a []int, s, color string) string {
// The Matches are sorted so we just have to traverse the Matches and if the two adjacent matches are not consecutive
// then we append the color string at the start + offset and the nulcol ( reset ) at end + offset + 1 and then reset