summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tterm.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/tterm.c b/tterm.c
index 626d414..0d70cb3 100644
--- a/tterm.c
+++ b/tterm.c
@@ -40,6 +40,24 @@ findwindow(unsigned int pid, Window w)
return 0;
}
+char *
+wd(char *path)
+{
+ char *username, *r;
+
+ username = getenv("USER");
+ r = strdup(path);
+
+ if (strncmp(r, "/home/", 6) == 0) {
+ r += 5;
+ if (strncmp(r + 1, username, strlen(username)) == 0)
+ r += strlen(username);
+ r[0] = '~';
+ }
+
+ return r;
+}
+
int
main(int argc, char *argv[])
{
@@ -94,7 +112,7 @@ main(int argc, char *argv[])
while ((len = getline(&line, &size, writefp)) != -1) {
if (strncmp(line, "cwd", 3) == 0) {
line += 3; line[len-4] = 0; /* chomp */
- cwd = strdup(line);
+ cwd = wd(line);
XStoreName(display, w, cwd);
XFlush(display);
} else if (strncmp(line, "cmd", 3) == 0) {