ui tweaks (#442)

This commit is contained in:
Olcan
2025-05-19 16:58:57 -07:00
committed by GitHub
parent 28acb8d495
commit 9c72a3ae12
4 changed files with 30 additions and 22 deletions

View File

@@ -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.