File size: 337 Bytes
0dbc9de
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
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
  return "~" + path.sep + relative
}