package paths import ( "os" "strings" ) // HomeDir returns the current user's home directory. // If it cannot be determined, returns an empty string. func HomeDir() string { home, _ := os.UserHomeDir() return home } // AbbreviateHome replaces the user's home directory prefix with '~' // to produce a shorter, more readable path for display. func AbbreviateHome(p string) string { home := HomeDir() if home == "" { return p } if after, found := strings.CutPrefix(p, home); found { return "~" + after } return p }