From 9c72a3ae129a5ab6cbc13fded86da01f2a354a75 Mon Sep 17 00:00:00 2001 From: Olcan Date: Mon, 19 May 2025 16:58:57 -0700 Subject: ui tweaks (#442) --- packages/server/src/utils/paths.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'packages/server/src') diff --git a/packages/server/src/utils/paths.ts b/packages/server/src/utils/paths.ts index 4ff74897..bbd479fd 100644 --- a/packages/server/src/utils/paths.ts +++ b/packages/server/src/utils/paths.ts @@ -5,6 +5,20 @@ */ import path from 'node:path'; +import os from 'os'; + +/** + * Replaces the home directory with a tilde. + * @param path - The path to tildeify. + * @returns The tildeified path. + */ +export function tildeifyPath(path: string): string { + const homeDir = os.homedir(); + if (path.startsWith(homeDir)) { + return path.replace(homeDir, '~'); + } + return path; +} /** * Shortens a path string if it exceeds maxLen, prioritizing the start and end segments. -- cgit v1.2.3