summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.def.h1
-rw-r--r--st.c32
-rw-r--r--st.h1
3 files changed, 34 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h
index e7f5a0b..6326287 100644
--- a/config.def.h
+++ b/config.def.h
@@ -204,6 +204,7 @@ static Shortcut shortcuts[] = {
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
+ { TERMMOD, XK_Return, newterm, {.i = 0} },
};
/*
diff --git a/st.c b/st.c
index 6195ea2..d45efa4 100644
--- a/st.c
+++ b/st.c
@@ -153,6 +153,7 @@ typedef struct {
} STREscape;
static void execsh(char *, char **);
+static char *getcwd_by_pid(pid_t pid);
static void stty(char **);
static void sigchld(int);
static void ttywriteraw(const char *, size_t);
@@ -1056,6 +1057,37 @@ tswapscreen(void)
}
void
+newterm(const Arg* a)
+{
+ int res;
+ switch (fork()) {
+ case -1:
+ die("fork failed: %s\n", strerror(errno));
+ break;
+ case 0:
+ switch (fork()) {
+ case -1:
+ die("fork failed: %s\n", strerror(errno));
+ break;
+ case 0:
+ res = chdir(getcwd_by_pid(pid));
+ execlp("st", "./st", NULL);
+ break;
+ default:
+ exit(0);
+ }
+ default:
+ wait(NULL);
+ }
+}
+
+static char *getcwd_by_pid(pid_t pid) {
+ char buf[32];
+ snprintf(buf, sizeof buf, "/proc/%d/cwd", pid);
+ return realpath(buf, NULL);
+}
+
+void
tscrolldown(int orig, int n)
{
int i;
diff --git a/st.h b/st.h
index 9f91e2a..1e7d28f 100644
--- a/st.h
+++ b/st.h
@@ -81,6 +81,7 @@ void die(const char *, ...);
void redraw(void);
void draw(void);
+void newterm(const Arg *);
void printscreen(const Arg *);
void printsel(const Arg *);
void sendbreak(const Arg *);