mirror of https://github.com/Hilbis/Hilbish
fix: expandHome function using hist dir instead of passed arg
parent
9d69b63a0f
commit
d4084a82ba
17
main.go
17
main.go
|
@ -56,7 +56,7 @@ func main() {
|
||||||
defaultConfDir = filepath.Join(confDir, "hilbish")
|
defaultConfDir = filepath.Join(confDir, "hilbish")
|
||||||
} else {
|
} else {
|
||||||
// else do ~ substitution
|
// else do ~ substitution
|
||||||
defaultConfDir = expandHome(defaultHistDir)
|
defaultConfDir = expandHome(defaultConfDir)
|
||||||
}
|
}
|
||||||
defaultConfPath = filepath.Join(defaultConfDir, "init.lua")
|
defaultConfPath = filepath.Join(defaultConfDir, "init.lua")
|
||||||
if defaultHistDir == "" {
|
if defaultHistDir == "" {
|
||||||
|
@ -239,11 +239,9 @@ func continuePrompt(prev string) (string, error) {
|
||||||
func fmtPrompt(prompt string) string {
|
func fmtPrompt(prompt string) string {
|
||||||
host, _ := os.Hostname()
|
host, _ := os.Hostname()
|
||||||
cwd, _ := os.Getwd()
|
cwd, _ := os.Getwd()
|
||||||
|
cwd = expandHome(cwd)
|
||||||
if strings.HasPrefix(cwd, curuser.HomeDir) {
|
|
||||||
cwd = "~" + strings.TrimPrefix(cwd, curuser.HomeDir)
|
|
||||||
}
|
|
||||||
username := curuser.Username
|
username := curuser.Username
|
||||||
|
|
||||||
// this will be baked into binary since GOOS is a constant
|
// this will be baked into binary since GOOS is a constant
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
username = strings.Split(username, "\\")[1] // for some reason Username includes the hostname on windows
|
username = strings.Split(username, "\\")[1] // for some reason Username includes the hostname on windows
|
||||||
|
@ -274,9 +272,12 @@ func handleHistory(cmd string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func expandHome(path string) string {
|
func expandHome(path string) string {
|
||||||
homedir := curuser.HomeDir
|
expanded := path
|
||||||
|
if strings.HasPrefix(path, curuser.HomeDir) {
|
||||||
return strings.Replace(defaultHistDir, "~", homedir, 1)
|
expanded = "~" + strings.TrimPrefix(path, curuser.HomeDir)
|
||||||
|
}
|
||||||
|
|
||||||
|
return expanded
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeDupes(slice []string) []string {
|
func removeDupes(slice []string) []string {
|
||||||
|
|
Loading…
Reference in New Issue