fzdwx

fzdwx

Hello , https://github.com/fzdwx

使用 tmux + st

st 是一個非常簡單的終端軟件,對我來說只缺少一個功能,就是多路服用(上下左右切分窗口),這在其他終端軟件中都有提供,比如說 wezterm。

而 tmux 剛好可以提供這個功能:

tmux split-window    # 向下切分
tmux split-window -h # 向右切分

然後就可以在 st 中設置快捷鍵:
{{< block type="details" >}}

/* 切分 */
static char *sp[] = { "/bin/sh", "-c", "tmux split-window","externalpipe", NULL };
static char *sph[] = { "/bin/sh", "-c", "tmux split-window -h","externalpipe", NULL };

/* 切換窗口 */
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 };

/* 調整窗口大小 */
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 >}}

最後關閉 tmux 的 status line,因為我只需要它的 pane 功能,其他的都太碍眼了。

set -g status off

preview


我的分支: https://github.com/fzdwx/st

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。