Running quick repeatable commands with parsable output
OneCommand.nvim came about from my need to be able to run commands quickly
and repeatadly, such as running tests or SCP-ing files to a server after updating.
There are currently 2 ways that I know of doing this:
- Use
:!<command>- The output of this is not easy to handle and work with. <CTRL-z>to exit, andfgto return - Can be a bit cumbersome and pollutes command history.
- Prompts for command, runs it and displays the stdout in a popup window
- Saves previous commands to history so they can be searched and run again
- Saves the output of last command so it can be brought back up for reference
Note: On the date command in the video I am manually pressing the refresh button.
default_style.webm
{
"StephenKelly94/OneCommand.nvim",
opts = {
-- configuration here
-- or leave it empty to use the default settings
-- refer to the configuration section below
},
keys = {
-- Set keybindings here
},
} use ("stephenkelly94/onecommand.nvim")When configuring onecommand you need to use the setup function
require("onecommand").setup({
-- configuration here
})Here is a list of the options that are configurable with their default settings
{
}Here are the things you can do and which key binds you can use
vim.api.nvim_set_keymap(
"n",
"<Leader>xc",
':lua require("onecommand").prompt_run_command()<CR>',
{ noremap = true }
)
vim.api.nvim_set_keymap(
"n",
"<Leader>xh",
':lua require("onecommand").view_history()<CR>',
{ noremap = true }
)
vim.api.nvim_set_keymap(
"n",
"<Leader>xl",
':lua require("onecommand").show_last_command_output()<CR>',
{ noremap = true }
)