st is a very simple terminal software, it lacks one feature for me, which is multiplexing (splitting windows vertically and horizontally), which is provided by other terminal software like wezterm.
And tmux can provide this feature:
tmux split-window # split downwards
tmux split-window -h # split to the right
Then you can set shortcuts in st:
{{< block type="details" >}}
/* Split */
static char *sp[] = { "/bin/sh", "-c", "tmux split-window","externalpipe", NULL };
static char *sph[] = { "/bin/sh", "-c", "tmux split-window -h","externalpipe", NULL };
/* Switch windows */
static char *gd[] = { "/bin/sh", "-c", "tmux select-pane -D","externalpipe", NULL };
static char *gu[] = { "/bin/sh", "-c", "tmux select-pane -U","externalpipe", NULL };
static char *gr[] = { "/bin/sh", "-c", "tmux select-pane -R","externalpipe", NULL };
static char *gl[] = { "/bin/sh", "-c", "tmux select-pane -L","externalpipe", NULL };
/* Adjust window size */
static char *rd[] = { "/bin/sh", "-c", "tmux resize-pane -D 2","externalpipe", NULL };
static char *ru[] = { "/bin/sh", "-c", "tmux resize-pane -U 2","externalpipe", NULL };
static char *rr[] = { "/bin/sh", "-c", "tmux resize-pane -R 2","externalpipe", NULL };
static char *rl[] = { "/bin/sh", "-c", "tmux resize-pane -L 2","externalpipe", NULL };
static Shortcut shortcuts[] = {
{ ControlMask, XK_minus, externalpipe, {.v = sp } },
{ ControlMask, XK_backslash, externalpipe, {.v = sph } },
{ MODKEY, XK_Up, externalpipe, {.v = gu} },
{ MODKEY, XK_Down, externalpipe, {.v = gd} },
{ MODKEY, XK_Left, externalpipe, {.v = gl} },
{ MODKEY, XK_Right, externalpipe, {.v = gr} },
{ ControlMask, XK_Up, externalpipe, {.v = ru} },
{ ControlMask, XK_Down, externalpipe, {.v = rd} },
{ ControlMask, XK_Left, externalpipe, {.v = rl} },
{ ControlMask, XK_Right, externalpipe, {.v = rr} },
};
{{< /block >}}
Finally, turn off tmux's status line because I only need its pane feature, the rest is too distracting.
set -g status off
My branch: https://github.com/fzdwx/st