CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/terminal/lib/util.ts
Views: 687
1
export function getChannelName(path: string): string {
2
return `terminal:${path}`;
3
}
4
5
export function getRemotePtyChannelName(path: string): string {
6
return `terminal-pty:${path}`;
7
}
8
9
export function getCWD(pathHead, cwd?): string {
10
// working dir can be set explicitly, and either be an empty string or $HOME
11
if (cwd != null) {
12
const HOME = process.env.HOME ?? "/home/user";
13
if (cwd === "") {
14
return HOME;
15
} else if (cwd.startsWith("$HOME")) {
16
return cwd.replace("$HOME", HOME);
17
} else {
18
return cwd;
19
}
20
}
21
return pathHead;
22
}
23
24