This is a simple plugin to run shell commands in a terminal buffer with access to many different "variables".
Using lazy.nvim
{
"d4rkr00t/execa.nvim",
cmd = "Execa",
opts = {
-- Open terminal in a vertical or horizontal split
split = "vsplit",
-- Prints the command before running
verbose = true,
-- Ask for confirmation before running a command
confirm = true,
-- A list of pre-defined commands
commands = {
hello = "echo $EX_FN",
}
}
}
$EX_FN
– Current function name (powered by treesitter)$EX_STR
– Content of the string under the cursor (powered by treesitter)$EX_FILE_PATH_REL
– Relative path to the current file$EX_FILE_PATH
– Absolute path to the current file$EX_FILE_NAME_NO_EXT
– Current file name without extension$EX_FILE_NAME
– Current file name$EX_DIR_PATH
– Current dir path$EX_DIR_NAME
– Current dir name$EX_LINE
– Current line number$EX_COL
– Current col number
Runs a command in a terminal buffer.
:Execa run echo $EX_FN
Outputs the current function name.
Repeats the last command in the current context. It runs the same command but re-evaluates the variables.
:Execa repeat
Runs a pre-defined command in a terminal buffer.
:Execa command hello
Opens a telescope picker with a list of pre-defined commands.
:Execa telescope
:Execa run cargo test $EX_FN
:Execa run npm view $EX_STR version