-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19eca75
commit cc83ae9
Showing
3 changed files
with
65 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
local function configure() | ||
local runner = require("runner") | ||
vim.keymap.set("n", "<leader>vd", runner.close, { desc = "[v]imux [d]elete" }) | ||
vim.keymap.set("n", "<leader>vp", runner.prompt, { desc = "[v]imux [p]rompt" }) | ||
vim.keymap.set("n", "<leader>vr", function() runner.run("!!") end, { desc = "[v]imux [r]erun the last command" }) | ||
vim.keymap.set( | ||
"n", | ||
"<leader>vz", | ||
runner.zoom, | ||
{ desc = "[v]imux [z]oom (tmux <leader>-z to toggle https://superuser.com/a/576505/468052)" } | ||
) | ||
end | ||
|
||
return { | ||
"local/runner", | ||
cond = function() | ||
return vim.fn.executable("tmux") == 1 | ||
end, | ||
config = configure, | ||
dev = true, | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
local M = {} | ||
|
||
M.close = function() | ||
local runner = M.getId() | ||
if runner == '' then | ||
return | ||
end | ||
os.execute("tmux kill-pane -t "..runner) | ||
end | ||
|
||
M.prompt = function() | ||
local cmd = vim.fn.input("$ ") | ||
M.run(cmd) | ||
end | ||
|
||
M.run = function(cmd) | ||
local runner = M.getId() | ||
if runner == '' then | ||
os.execute("tmux split-window -p 40 -h") | ||
os.execute("tmux last-pane") | ||
runner = M.getId() | ||
if runner == '' then | ||
return | ||
end | ||
end | ||
os.execute("tmux send-keys -t "..runner.." '"..cmd.."' ENTER") | ||
end | ||
|
||
M.zoom = function () | ||
local runner = M.getId() | ||
os.execute("tmux resize-pane -Z -t "..runner) | ||
end | ||
|
||
M.getId = function() | ||
local panes = vim.fn.systemlist("tmux list-panes -F '#{pane_active}:#{pane_id}'") | ||
for _, pane in pairs(panes) do | ||
if string.sub(pane,1,1) ~= "1" then | ||
return string.sub(pane,3) | ||
end | ||
end | ||
return '' | ||
end | ||
|
||
return M |