st

my build of st - simple terminal
git clone git://git.kocotian.pl/st.git
Log | Files | Refs | README | LICENSE

commit 0b9e8fc2be4de8f08b8e3bd5881bb8ecff7199df
parent c4a53c5c31009c3c2c3aa8da26524de454ccca7b
Author: kocotian <kocotian@kocotian.pl>
Date:   Wed, 23 Dec 2020 20:02:22 +0100

newterm patch

Diffstat:
Mconfig.def.h | 1+
Mpatches/st-newterm-0.8.2.diff | 0
Mst.c | 21+++++++++++++++++++++
Mst.h | 1+
4 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -220,6 +220,7 @@ static Shortcut shortcuts[] = { { MODKEY|ShiftMask, XK_F7, setpalette, {.i = 6} }, { MODKEY|ShiftMask, XK_F8, setpalette, {.i = 7} }, { MODKEY|ShiftMask, XK_F9, setpalette, {.i = 8} }, + { MODKEY|ShiftMask, XK_Return, newterm, {.i = 0} }, }; /* diff --git a/patches/st-newterm-0.8.2.diff b/patches/st-newterm-0.8.2.diff diff --git 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); @@ -1059,6 +1060,26 @@ tswapscreen(void) } 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 i; diff --git a/st.h b/st.h @@ -82,6 +82,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 *);