otavioschwanck / tmux-awesome-manager.nvim

TMUX Commands manager / runner for Neovim.
67 stars 2 forks source link

Pass filename to cmd? #2

Closed HuntTheSun closed 1 year ago

HuntTheSun commented 1 year ago

First of all, thank you for writing this plugin, it really is awesome! Does anyone know if and how I can pass the currently open filename to cmd?

For example, overseer does this by allowing an args component like this: return { cmd = { "/home/ele/scripts/code/build/c/cGccAndRun.sh" }, args = { file }, } Could i somehow achieve a workaround or something where i can pass the current filename to a cmd?

HuntTheSun commented 1 year ago

I just realized that I am very stupid, i can just concatenate strings in lua with the .. operator. Here is how i got it working:

function to get filename: local function getFileNameFromBuf() return vim.fn.expand('%p') end base example: vim.keymap.set('n', '<leader>rrg', tmux_term.run({ name = 'Glow Markdown Preview', cmd = 'glow ' .. getFileNameFromBuf(), use_cwd = true,open_as = 'pane' }), {desc = "MD Preview"}) example with command after (zsh) vim.keymap.set('n', '<leader>rrg', tmux_term.run({ name = 'Glow Markdown Preview ZSH', cmd = 'glow ' .. getFileNameFromBuf() .. ' && zsh', use_cwd = true,open_as = 'pane' }), {desc = "MD Preview with zsh"})

Sorry for asking the question then solving it an hour after, I tried but was just really dense the whole time :)

Great plugin, thank you for writing it!