diff -up st-0.8.4/config.def.h st-0.8.4-newterm/config.def.h --- st-0.8.4/config.def.h 2020-08-22 22:34:14.285888573 +0200 +++ st-0.8.4-newterm/config.def.h 2020-08-22 22:38:19.656480219 +0200 @@ -203,6 +203,7 @@ static Shortcut shortcuts[] = { { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, { ShiftMask, XK_Page_Up, kscrollup, {.i = -1} }, { ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} }, + { TERMMOD, XK_Return, newterm, {.i = 0} }, }; /* diff -up st-0.8.4/st.c st-0.8.4-newterm/st.c --- st-0.8.4/st.c 2020-08-22 22:34:14.285888573 +0200 +++ st-0.8.4-newterm/st.c 2020-08-22 22:40:04.211665643 +0200 @@ -160,6 +160,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); @@ -1107,6 +1108,27 @@ kscrollup(const Arg* a) } void +newterm(const Arg* a) +{ + switch (fork()) { + case -1: + die("fork failed: %s\n", strerror(errno)); + break; + case 0: + chdir(getcwd_by_pid(pid)); + execlp("st", "./st", NULL); + break; + } +} + +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 copyhist) { int i; diff -up st-0.8.4/st.h st-0.8.4-newterm/st.h --- st-0.8.4/st.h 2020-08-22 22:34:14.285888573 +0200 +++ st-0.8.4-newterm/st.h 2020-08-22 22:40:47.316828698 +0200 @@ -81,6 +81,7 @@ void die(const char *, ...); void redraw(void); void draw(void); +void newterm(const Arg *); void kscrolldown(const Arg *); void kscrollup(const Arg *); void printscreen(const Arg *);