Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/core/src/utils/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ export const SHELL_SPECIAL_CHARS = /[ \t()[\]{};|*?$`'"#&<>!~]/;
* @param path - The path to tildeify.
* @returns The tildeified path.
*/
export function tildeifyPath(path: string): string {
export function tildeifyPath(p: string): string {
const homeDir = os.homedir();
if (path.startsWith(homeDir)) {
return path.replace(homeDir, '~');
if (p === homeDir) {
return '~';
}
return path;
if (p.startsWith(homeDir + path.sep)) {
return '~' + p.substring(homeDir.length);
}
return p;
}

/**
Expand Down