aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2021-04-08 15:50:34 +0200
committerMateja <mail@matejamaric.com>2021-04-08 15:50:34 +0200
commitdc273f41c5d548026b4bea766c919f1e4e8a04ac (patch)
tree2d4f157915a660d0f7cf6e181496e466b2a8211b
parent081aa95b38c53b5a9ea47907496e0ff043fdffe3 (diff)
downloadst-dc273f41c5d548026b4bea766c919f1e4e8a04ac.tar.gz
st-dc273f41c5d548026b4bea766c919f1e4e8a04ac.zip
Applied `newterm` patch.v1.2.0
-rw-r--r--README.md7
-rw-r--r--config.def.h1
-rw-r--r--st.c21
-rw-r--r--st.h1
4 files changed, 27 insertions, 3 deletions
diff --git a/README.md b/README.md
index 25b24c8..ae379d2 100644
--- a/README.md
+++ b/README.md
@@ -6,18 +6,19 @@ This is my fork of [st][stterm] terminal with following patches applied:
- nordtheme (with black background)
- alpha
- boxdraw
+- newterm
## Dependencies:
- Fira Code font
-### Build requirements:
+### Build dependencies:
- Xlib header files
- fontconfig
- freetype2
-### Installation
+## Installation
Edit `config.mk` to match your local setup (st is installed into
the `/usr/local` namespace by default).
@@ -27,7 +28,7 @@ necessary as root):
make clean install
-### Running st
+## Running st
If you did not install st with make clean install, you must compile
the st terminfo entry with the following command:
diff --git a/config.def.h b/config.def.h
index 42e4347..7ec089f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -214,6 +214,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 248728f..46e9f32 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);
@@ -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
index bca2cb5..0817623 100644
--- 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 *);