Skip to content

Instantly share code, notes, and snippets.

@bbtdev
Created March 23, 2021 05:13
Show Gist options
  • Save bbtdev/ec9c6995f7f362e35452bc8d5a1ccc41 to your computer and use it in GitHub Desktop.
Save bbtdev/ec9c6995f7f362e35452bc8d5a1ccc41 to your computer and use it in GitHub Desktop.
st launches new instance, does not care about cwd
diff -u orig/config.def.h mod/config.def.h
--- orig/config.def.h 2020-06-19 12:29:45.000000000 +0300
+++ mod/config.def.h 2021-03-23 07:05:38.656594165 +0200
@@ -199,6 +199,7 @@
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
+ { TERMMOD, XK_N, newinstance, {.i = 0} },
};
/*
diff -u orig/st.c mod/st.c
--- orig/st.c 2020-06-19 12:29:45.000000000 +0300
+++ mod/st.c 2021-03-23 07:06:56.099341909 +0200
@@ -2595,3 +2595,16 @@
tfulldirt();
draw();
}
+
+void
+newinstance(const Arg* a)
+{
+ switch (fork()) {
+ case -1:
+ die("fork failed: %s\n", strerror(errno));
+ break;
+ case 0:
+ execlp("st", "./st", NULL);
+ break;
+ }
+}
diff -u orig/st.h mod/st.h
--- orig/st.h 2020-06-19 12:29:45.000000000 +0300
+++ mod/st.h 2021-03-23 07:06:11.467484210 +0200
@@ -81,6 +81,8 @@
void redraw(void);
void draw(void);
+void newinstance(const Arg *);
+
void printscreen(const Arg *);
void printsel(const Arg *);
void sendbreak(const Arg *);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment