td-cli bindings & script

This commit is contained in:
Kacper Marzecki 2025-03-16 22:38:16 +01:00
parent 2f0a29ce9f
commit c3215d968e
7 changed files with 43 additions and 17 deletions

View File

@ -100,6 +100,10 @@ bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
# Persistent floating pane with
bind-key \\ run-shell 'tmux-td'
# bind-key \\ run-shell "tmux display-popup -E 'tmux detach-client'"
bind-key -T copy-mode-vi C-h select-pane -L
bind-key -T copy-mode-vi C-j select-pane -D
bind-key -T copy-mode-vi C-k select-pane -U

View File

@ -67,21 +67,21 @@ map("n", "<leader>ff", "<cmd>FzfLua<cr>", { desc = "FZF commands" })
-- map("t", "<c-_>", "<cmd>close<cr>", { desc = "which_key_ignore" })
map("n", "<leader>qw", "<cmd>wq<cr>", { desc = "save & quit" })
local td_cli = require("toggleterm.terminal").Terminal:new({
cmd = "node /home/omnissiah/git/td/dist/cli.js",
direction = "float",
close_on_exit = false,
hidden = true,
on_open = function(term)
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(term.bufnr, "t", "<C-q>", "<C-\\><C-n>:close<CR>", { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(term.bufnr, "t", "<C-q>", "<cmd>close<CR>", { noremap = true, silent = true })
end,
})
vim.keymap.set("t", "\\", function()
td_cli:toggle()
end, { desc = "Toggle TD CLI floating terminal" })
-- local td_cli = require("toggleterm.terminal").Terminal:new({
-- cmd = "node /home/omnissiah/git/td/dist/cli.js",
-- direction = "float",
-- close_on_exit = false,
-- hidden = true,
-- on_open = function(term)
-- vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
-- vim.api.nvim_buf_set_keymap(term.bufnr, "t", "<C-q>", "<C-\\><C-n>:close<CR>", { noremap = true, silent = true })
-- vim.api.nvim_buf_set_keymap(term.bufnr, "t", "<C-q>", "<cmd>close<CR>", { noremap = true, silent = true })
-- end,
-- })
-- vim.keymap.set("t", "\\", function()
-- td_cli:toggle()
-- end, { desc = "Toggle TD CLI floating terminal" })
vim.keymap.set("n", "\\", function()
td_cli:toggle()
end, { desc = "Toggle TD CLI floating terminal" })
vim.cmd("!tmux-td")
end, { desc = "Toggle TD CLI floating terminal and run tmux-td" })
-- vim.keymap.set("t", "<C-\\>", "<cmd>ToggleTerm<cr>", { noremap = true, silent = true })

View File

@ -1,5 +1,5 @@
link folders/files locally
e.g. in ~/.config/ ln -s lazyvim ~/.git/configs/remote lazyvim
omnissiah@mars:~/git/configs$ mv ~/.tmux.conf ~/git/configs/.tmux.conf
omnissiah@mars:~/git/configs$ ln .tmux.conf ~/.tmux.conf
omnissiah@mars:~/installs/scripts$ ln ~/git/config/scripts/n n

3
scripts/n Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
export NVIM_APPNAME=lazyvim
exec /home/linuxbrew/.linuxbrew/bin/nvim "$@"

2
scripts/td Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
node ~/git/td/dist/cli.js

5
scripts/tmux-edit-scrollback Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
file=$(mktemp)
tmux capture-pane -pS -32768 >$file
tmux new-window -n:scrollback-edit "n $file"

12
scripts/tmux-td Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
if ! tmux has-session -t td-cli 2>/dev/null; then
tmux new-session -d -s td-cli /home/omnissiah/installs/scripts/td
fi
if [ "$(tmux display-message -p -F "#{session_name}")" = "td-cli" ]; then
tmux detach-client
tmux display-popup -C
else
tmux display-popup -d -E -w90% -h90% 'tmux attach-session -x -t td-cli'
fi