diff options
-rw-r--r-- | src/ChangeLog | 1 | ||||
-rw-r--r-- | src/process.c | 9 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index df04dca..6e67e53 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -43,6 +43,7 @@ Version 4.1.0 (??/??/20??): .screenrc: * $PID expands to the PID of the screen session. + * $PWD expands to the current working directory of the session. * $STY expands to the session name. * Tilde-expansion in pathnames (e.g. for the 'source' command) * C-style escapes can be used (e.g. "\n" to get a newline with 'stuff') diff --git a/src/process.c b/src/process.c index cb90802..68f3db9 100644 --- a/src/process.c +++ b/src/process.c @@ -4627,7 +4627,7 @@ int bufl, *argl; else if (delim != '\'' && *p == '$' && (p[1] == '{' || p[1] == ':' || (p[1] >= 'a' && p[1] <= 'z') || (p[1] >= 'A' && p[1] <= 'Z') || (p[1] >= '0' && p[1] <= '9') || p[1] == '_')) { - char *ps, *pe, op, *v, xbuf[11]; + char *ps, *pe, op, *v, xbuf[11], path[MAXPATHLEN]; int vl; ps = ++p; @@ -4671,6 +4671,13 @@ int bufl, *argl; sprintf(xbuf, "%d", display ? D_height : -1); else if (!strcmp(ps, "PID")) sprintf(xbuf, "%d", getpid()); + else if (!strcmp(ps, "PWD")) + { + if (getcwd(path, sizeof(path) - 1) == 0) + v = "?"; + else + v = path; + } else if (!strcmp(ps, "STY")) { if ((v = strchr(SockName, '.'))) /* Skip the PID */ |