feat: use zellij as my daily terminal environemnt, remote tmux

This commit is contained in:
Ryan Yin
2023-12-27 22:26:06 +08:00
parent 148da9eecf
commit 248cf2e86f
11 changed files with 80 additions and 195 deletions

View File

@@ -1,61 +0,0 @@
{pkgs, ...}: {
programs.tmux = {
enable = true;
shell = "${pkgs.nushellFull}/bin/nu";
# Resize the window to the size of the smallest session for which it is the current window.
#
aggressiveResize = true;
# https://github.com/tmux-plugins/tmux-sensible
# tmux-sensible overwrites default tmux shortcuts, makes them more sane.
sensibleOnTop = true;
# https://github.com/sxyazi/yazi/wiki/Image-preview-within-tmux
extraConfig = ''
set -g allow-passthrough on
set -ga update-environment TERM
set -ga update-environment TERM_PROGRAM
'';
# keyMode = "vi"; # default is emacs
baseIndex = 1; # start index from 1
escapeTime = 0; # do not wait for escape key
plugins = with pkgs.tmuxPlugins; [
{
# theme
# https://github.com/catppuccin/tmux
plugin = catppuccin;
extraConfig = ''
set -g @catppuccin_flavour 'mocha' # or frappe, macchiato, mocha
set -g @catppuccin_window_status_enable "yes"
'';
}
# https://github.com/tmux-plugins/tmux-yank
# Enables copying to system clipboard.
yank
{
# https://github.com/tmux-plugins/tmux-resurrect
# Manually persists tmux environment across system restarts.
# prefix + Ctrl-s - save
# prefix + Ctrl-r - restore
#
plugin = resurrect;
# Restore Neovim sessions
extraConfig = "set -g @resurrect-strategy-nvim 'session'";
}
# set -g @plugin 'tmux-plugins/tmux-cpu'
{
plugin = cpu;
extraConfig = ''
set -g status-right '#{cpu_bg_color} CPU: #{cpu_icon} #{cpu_percentage} | %a %h-%d %H:%M '
'';
}
];
};
}

View File

@@ -0,0 +1,29 @@
# Zellij - A workspace lives in your terminal
Zellij is a terminal workspace with batteries included.
At its core, it is a terminal multiplexer (similar to tmux and screen), but this is merely its infrastructure layer.
Zellij is very user-friendly and easy to use, with a step-by-step hint system that will help you get to know the keybindings, which is very like the Neovim or helix.
> By contrast, tmux's key design is counterintuitive, there is no prompt system, and the plug-in performance is rubbish. It's really a pain to use.
> tmux's inital release was in 2007, it's too old, I would recommend any users that do not have a experience with multiplexer to use zellij instead of tmux.
## Why use zellij as the detault terminal environment?
By auto start zellij on shell login, and exit the shell session on zellij exit, we can use zellij as the default terminal environment.
By this way, We will only use the most basic features of the terminal emulator(kitty/alacritty/wezterm/...),
while most of the functions of terminal are provided by zellij.
Thus we can easily switch to any terminal emulator without losing any key functions,
and do not need to take care of the differences between different terminal emulators.
And Zellij can be used not only locally, but also on any remote server, which is very convenient. Learn once and use everywhere!
> Yeah, you didn't misread it, zellij is very suitable for not only remotely, but also locally!
Some features such as search/copy/scrollback in different terminal emulators are implemented in different ways, and has different user experience.
For example, Wezterm's default search function is very basic, and it's not easy to use. Kitty's scrollback search/copy is really tricky to use.
As for some Editor such as Neovim, its intergrated terminal is really useful, but zellij is more powerful and useful than it, and more stable!
Zellij overcomes these problems, and provides a unified user experience for all terminal emulators!
Teminal emulators should only be responsible for displaying characters.

View File

@@ -16,7 +16,8 @@ in {
^zellij
}
# auto exit the shell session when zellij exit
# Auto exit the shell session when zellij exit
$env.ZELLIJ_AUTO_EXIT = "true" # enable auto exit
if "ZELLIJ_AUTO_EXIT" in $env and $env.ZELLIJ_AUTO_EXIT == "true" {
exit
}