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

@@ -33,6 +33,18 @@ Remove all unused plugins:
![](/_img/astronvim_2023-07-13_00-39.webp)
![](/_img/hyprland_2023-07-29_2.webp)
## Terminal Related
I used to use the following instructions frequently, but now **I switched my daily terminal environment to zellij**,
which provides a more powerful and stable terminal experience, so I don't use neovim's terminal feature anymore.
| Action | Shortcut |
| ----------------------------- | -------------- |
| Floating Terminal | `<Space> + tf` |
| Horizontal Split Terminal | `<Space> + th` |
| Vertical Split Terminal | `<Space> + tv` |
| Open IPython REPL | `<Space> + tp` |
## Visual Modes
| Action | Shortcut |
@@ -94,10 +106,6 @@ Provided by [flash.nvim](https://github.com/folke/flash.nvim), it's a intelligen
| Learn Neovim's Basics | `:Tutor` |
| Open file explorer | `<Space> + e` |
| Focus Neotree to current file | `<Space> + o` |
| Floating Terminal | `<Space> + tf` |
| Horizontal Split Terminal | `<Space> + th` |
| Vertical Split Terminal | `<Space> + tv` |
| Open IPython REPL | `<Space> + tp` |
| Toggle line wrap | `<Space> + uw` |
| Show line diagnostics | `gl` |
| Show function/variable info | `K` |

View File

@@ -1,8 +1,21 @@
# Termianl Emulators
1. kitty: My main terminal emulator.
2. wezterm: My secondary terminal emulator.
I used to spend a lot of time on terminal emulators, to make them match my taste,
but now I found that it's not worth it, **Zellij can provide a user-friendly and unified user experience for all terminal emulators! without any pain**!
Currently, I only use the most basic features of terminal emulators, such as true color, graphics protocol, etc.
Other features such as tabs, scrollback buffer, select/search/copy, etc, are all provided by zellij!
My current terminal emulators are:
1. kitty: My main terminal emulator.
1. to select/copy a large mount of text, We should do some tricks via kitty's `scrollback_pager` with neovim, it's really painful: <https://github.com/kovidgoyal/kitty/issues/719>
2. wezterm: My secondary terminal emulator.
1. its search ability is very basic, and it's not easy to use.
1. its scrollback buffer's copy mode is very like vim, which is nice, but zellij's even better, it can use neovim as its default scrollback buffer's editor without any pain!
3. foot: a fast, lightweight and minimalistic Wayland terminal emulator.
1. foot only do the things a terminal emulator should do, no more, no less.
1. It's really suitable for tiling window manager or zellij users!
## 'xterm-kitty': unknown terminal type when `ssh` into a remote host or `sudo xxx`

View File

@@ -7,24 +7,10 @@
#
# Kitty Configuration
#
# Useful Hot Keys for macOS:
# 1. New Tab: `command + t`
# 2. Close Tab: `command + w`
# 3. Switch Tab: `command + shift + [` | `command + shift + ]`
# 4. Increase Font Size: `command + =` | `command + +`
# 5. Decrease Font Size: `command + -` | `command + _`
# 6. And Other common shortcuts such as Copy, Paste, Cursor Move, etc.
# 7. Search/Select in the current window(show_scrollback): `ctrl + shift + f`
# This will open a pager, it's defined by `scrollback_pager`, default is `less`
# https://sw.kovidgoyal.net/kitty/overview/#the-scrollback-buffer
#
# Useful Hot Keys for Linux:
# 1. New Tab: `ctrl + shift + t`
# 2. Close Tab: `ctrl + shift + q`
# 3. Switch Tab: `ctrl + shift + right` | `ctrl + shift + left`
# 4. Increase Font Size: `ctrl + shift + =` | `ctrl + shift + +`
# 5. Decrease Font Size: `ctrl + shift + -` | `ctrl + shift + _`
# 6. And Other common shortcuts such as Copy, Paste, Cursor Move, etc.
# Useful Hot Keys for Linux(replace `ctrl + shift` with `cmd` on macOS)):
# 1. Increase Font Size: `ctrl + shift + =` | `ctrl + shift + +`
# 2. Decrease Font Size: `ctrl + shift + -` | `ctrl + shift + _`
# 3. And Other common shortcuts such as Copy, Paste, Cursor Move, etc.
#
###########################################################
{
@@ -48,33 +34,11 @@
{
"ctrl+shift+m" = "toggle_maximized";
"ctrl+shift+f" = "show_scrollback"; # search in the current window
"cmd+f" = "show_scrollback";
# Switch to tab 1-8(consistent with wezterm)
"ctrl+shift+1" = "goto_tab 1";
"ctrl+shift+2" = "goto_tab 2";
"ctrl+shift+3" = "goto_tab 3";
"ctrl+shift+4" = "goto_tab 4";
"ctrl+shift+5" = "goto_tab 5";
"ctrl+shift+6" = "goto_tab 6";
"ctrl+shift+7" = "goto_tab 7";
"ctrl+shift+8" = "goto_tab 8";
}
// (if pkgs.stdenv.isDarwin then {
# Switch to tab 1-8(consistent with wezterm)
"cmd+1" = "goto_tab 1";
"cmd+2" = "goto_tab 2";
"cmd+3" = "goto_tab 3";
"cmd+4" = "goto_tab 4";
"cmd+5" = "goto_tab 5";
"cmd+6" = "goto_tab 6";
"cmd+7" = "goto_tab 7";
"cmd+8" = "goto_tab 8";
} else {});
};
settings = {
background_opacity = "0.93";
macos_option_as_alt = true; # Option key acts as Alt on macOS
scrollback_lines = 10000;
enable_audio_bell = false;
tab_bar_edge = "top"; # tab bar on top
# To resolve issues:
@@ -82,13 +46,6 @@
# 2. https://github.com/ryan4yin/nix-config/issues/8
# Spawn a nushell in login mode via `bash`
shell = "${pkgs.bash}/bin/bash --login -c 'nu --login --interactive'";
# for selecting/searching in the current window
# https://github.com/kovidgoyal/kitty/issues/719
scrollback_pager = ''$SHELL -c 'nvim -u NONE -R -M -u ${./kitty_pager.lua} -c "lua kitty_pager(INPUT_LINE_NUMBER, CURSOR_LINE, CURSOR_COLUMN)" -' '';
# for active tab
active_tab_title_template = "{index}:{title}";
# for inactive tab
tab_title_template = "{index}:{title}";
};
# macOS specific settings

View File

@@ -1,62 +0,0 @@
kitty_pager = function(INPUT_LINE_NUMBER, CURSOR_LINE, CURSOR_COLUMN)
print('kitty sent:', INPUT_LINE_NUMBER, CURSOR_LINE, CURSOR_COLUMN)
vim.opt.encoding='utf-8'
vim.opt.clipboard = 'unnamed'
vim.opt.compatible = false
vim.opt.number = false
vim.opt.relativenumber = false
vim.opt.termguicolors = true
vim.opt.showmode = false
vim.opt.ruler = false
vim.opt.laststatus = 0
vim.o.cmdheight = 0
vim.opt.showcmd = false
vim.opt.scrollback = INPUT_LINE_NUMBER + CURSOR_LINE
local term_buf = vim.api.nvim_create_buf(true, false);
local term_io = vim.api.nvim_open_term(term_buf, {})
vim.api.nvim_buf_set_keymap(term_buf, 'n', 'q', '<Cmd>q<CR>', { })
vim.api.nvim_buf_set_keymap(term_buf, 'n', '<ESC>', '<Cmd>q<CR>', { })
local group = vim.api.nvim_create_augroup('kitty+page', {})
local setCursor = function()
vim.api.nvim_feedkeys(tostring(INPUT_LINE_NUMBER) .. [[ggzt]], 'n', true)
local line = vim.api.nvim_buf_line_count(term_buf)
if (CURSOR_LINE <= line) then
line = CURSOR_LINE
end
vim.api.nvim_feedkeys(tostring(line - 1) .. [[j]], 'n', true)
vim.api.nvim_feedkeys([[0]], 'n', true)
vim.api.nvim_feedkeys(tostring(CURSOR_COLUMN - 1) .. [[l]], 'n', true)
end
vim.api.nvim_create_autocmd('ModeChanged', {
group = group,
buffer = term_buf,
callback = function()
local mode = vim.fn.mode()
if mode == 't' then
vim.cmd.stopinsert()
vim.schedule(setCursor)
end
end,
})
vim.api.nvim_create_autocmd('VimEnter', {
group = group,
pattern = '*',
once = true,
callback = function(ev)
local current_win = vim.fn.win_getid()
for _, line in ipairs(vim.api.nvim_buf_get_lines(ev.buf, 0, -2, false)) do
vim.api.nvim_chan_send(term_io, line)
vim.api.nvim_chan_send(term_io, '\r\n')
end
for _, line in ipairs(vim.api.nvim_buf_get_lines(ev.buf, -2, -1, false)) do
vim.api.nvim_chan_send(term_io, line)
end
vim.api.nvim_win_set_buf(current_win, term_buf)
vim.api.nvim_buf_delete(ev.buf, { force = true } )
vim.schedule(setCursor)
end
})
end

View File

@@ -3,15 +3,10 @@
#
# Wezterm Configuration
#
# Useful Hot Keys for Linux:
# 1. New Tab: `ctrl + shift + t`
# 2. Close Tab: `ctrl + shift + q`
# 3. Switch Tab: `super + shift + right` | `super + shift + left`
# 4. Increase Font Size: `ctrl + shift + =` | `ctrl + shift + +`
# 5. Decrease Font Size: `ctrl + shift + -` | `ctrl + shift + _`
# 6. And Other common shortcuts such as Copy, Paste, Cursor Move, etc.
# 7. Copy Mode(vim like): `Ctrl + Shift + x`
# 8. Search Mode: `Ctrl + Shift + f`
# Useful Hot Keys for Linux(replace `ctrl + shift` with `cmd` on macOS)):
# 1. Increase Font Size: `ctrl + shift + =` | `ctrl + shift + +`
# 2. Decrease Font Size: `ctrl + shift + -` | `ctrl + shift + _`
# 3. And Other common shortcuts such as Copy, Paste, Cursor Move, etc.
#
# Default Keybindings: https://wezfurlong.org/wezterm/config/default-keys.html
#