mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-24 01:38:28 +02:00
feat: use zellij as my daily terminal environemnt, remote tmux
This commit is contained in:
@@ -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`
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user