summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadrul Habib Chowdhury <sadrul@users.sourceforge.net>2010-03-23 23:00:26 -0400
committerSadrul Habib Chowdhury <sadrul@users.sourceforge.net>2010-03-23 23:05:02 -0400
commit9c2fb084492ec102da749e75e5514114eee4bf01 (patch)
tree8cda325dbe5fb033ada1140ec49e165785e27a50
parentf7adfae856bb83107024559bf3b167bc4b9a42df (diff)
downloadscreen-9c2fb084492ec102da749e75e5514114eee4bf01.tar.gz
Expand $PWD to screen's current working directory.
Expanding $PWD to expand to the correct current working directory can be useful to figure out, for example, where log files are created, and other purposes.
-rw-r--r--src/ChangeLog1
-rw-r--r--src/process.c9
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 */