mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-25 09:28:27 +02:00
feat: selecting&searching in kitty
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
# general tools
|
# general tools
|
||||||
pulumi
|
pulumi
|
||||||
pulumictl
|
pulumictl
|
||||||
# istioctl
|
|
||||||
|
|
||||||
# aws
|
# aws
|
||||||
awscli2
|
awscli2
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
# 4. Increase Font Size: `command + =` | `command + +`
|
# 4. Increase Font Size: `command + =` | `command + +`
|
||||||
# 5. Decrease Font Size: `command + -` | `command + _`
|
# 5. Decrease Font Size: `command + -` | `command + _`
|
||||||
# 6. And Other common shortcuts such as Copy, Paste, Cursor Move, etc.
|
# 6. And Other common shortcuts such as Copy, Paste, Cursor Move, etc.
|
||||||
# 7. Search in the current window(show_scrollback): `ctrl + shift + h`
|
# 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`
|
# 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:
|
# Useful Hot Keys for Linux:
|
||||||
# 1. New Tab: `ctrl + shift + t`
|
# 1. New Tab: `ctrl + shift + t`
|
||||||
@@ -45,6 +45,17 @@
|
|||||||
|
|
||||||
keybindings = {
|
keybindings = {
|
||||||
"ctrl+shift+m" = "toggle_maximized";
|
"ctrl+shift+m" = "toggle_maximized";
|
||||||
|
"ctrl+shift+f" = "show_scrollback"; # search in the current window
|
||||||
|
"cmd+f" = "show_scrollback";
|
||||||
|
# Switch to tab 1-8
|
||||||
|
"ctrl+alt+1" = "goto_tab 1";
|
||||||
|
"ctrl+alt+2" = "goto_tab 2";
|
||||||
|
"ctrl+alt+3" = "goto_tab 3";
|
||||||
|
"ctrl+alt+4" = "goto_tab 4";
|
||||||
|
"ctrl+alt+5" = "goto_tab 5";
|
||||||
|
"ctrl+alt+6" = "goto_tab 6";
|
||||||
|
"ctrl+alt+7" = "goto_tab 7";
|
||||||
|
"ctrl+alt+8" = "goto_tab 8";
|
||||||
};
|
};
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
@@ -58,6 +69,13 @@
|
|||||||
# 2. https://github.com/ryan4yin/nix-config/issues/8
|
# 2. https://github.com/ryan4yin/nix-config/issues/8
|
||||||
# Spawn a nushell in login mode via `bash`
|
# Spawn a nushell in login mode via `bash`
|
||||||
shell = "${pkgs.bash}/bin/bash --login -c 'nu --login --interactive'";
|
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 = "{fmt.fg.green}{bell_symbol}{activity_symbol}{fmt.fg.tab}{index}:{title}";
|
||||||
|
# for inactive tab
|
||||||
|
tab_title_template = "{fmt.fg.red}{bell_symbol}{activity_symbol}{fmt.fg.tab}{index}:{title}";
|
||||||
};
|
};
|
||||||
|
|
||||||
# macOS specific settings
|
# macOS specific settings
|
||||||
|
|||||||
62
home/base/desktop/terminal/kitty_pager.lua
Normal file
62
home/base/desktop/terminal/kitty_pager.lua
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
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
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# https://github.com/NixOS/nixpkgs/blob/master/lib/attrsets.nix
|
||||||
{lib, ...}: {
|
{lib, ...}: {
|
||||||
# Generate an attribute set from a list.
|
# Generate an attribute set from a list.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -6,13 +6,15 @@
|
|||||||
scanPaths = path:
|
scanPaths = path:
|
||||||
builtins.map
|
builtins.map
|
||||||
(f: (path + "/${f}"))
|
(f: (path + "/${f}"))
|
||||||
(builtins.filter # find all overlay files in the current directory
|
(builtins.attrNames
|
||||||
|
(lib.attrsets.filterAttrs
|
||||||
(
|
(
|
||||||
f:
|
path: _type:
|
||||||
f
|
(_type == "directory") # include directories
|
||||||
!= "default.nix" # ignore default.nix
|
|| (
|
||||||
&& f != "README.md" # ignore README.md
|
(path != "default.nix") # ignore default.nix
|
||||||
)
|
&& (lib.strings.hasSuffix ".nix" path) # include .nix files
|
||||||
(builtins.attrNames (builtins.readDir path)));
|
)
|
||||||
|
)
|
||||||
|
(builtins.readDir path)));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user