mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-23 18:55:37 -04:00
11 lines
448 B
TypeScript
11 lines
448 B
TypeScript
import path from "path"
|
|
|
|
export function abbreviateHome(input: string, home: string) {
|
|
if (!home) return input
|
|
const relative = path.relative(home, input)
|
|
if (relative === "") return "~"
|
|
if (relative === ".." || relative.startsWith(".." + path.sep) || path.isAbsolute(relative)) return input
|
|
// Normalize to forward slashes so abbreviated display paths are identical across platforms.
|
|
return "~/" + relative.split(path.sep).join("/")
|
|
}
|