Easily select and launch commands directly from neovim
It uses toggleterm.nvim
as backend
{
"0xfraso/command.nvim",
opts = {}, -- see section below for configuration options
dependencies = {
"akinsho/toggleterm.nvim",
}
}
{
cache_file = vim.fn.stdpath("cache") .. "/commands", -- path to cache file
sort = 'asc' -- Can be "asc", "desc" or "none"
}
command.nvim
exposes the following user commands:
:CommandSelect
:CommandSelectShellHistory
:CommandExecLast
:CommandPrompt
:CommandPromptLast
:CommandEdit
For example, you can map commands using lazy.nvim
:
{
"0xfraso/command.nvim",
opts = {
cache_file = vim.fn.stdpath("cache") .. "/commands", -- path to cache file
shell_file = os.getenv('HOME') .. "/.zsh_history", -- change with your shell history file
sort = "asc"
},
dependencies = {
"akinsho/toggleterm.nvim",
"stevearc/dressing.nvim", -- optional, but recommended
},
keys = {
{ "<leader>tl", ":CommandSelect<CR>", desc = "Select command" },
{ "<leader>tr", ":CommandSelectShellHistory<CR>", desc = "Select command from history file" },
{ "<leader>tp", ":CommandPrompt<CR>", desc = "Prompt command" },
{ "<leader>tP", ":CommandPromptLast<CR>", desc = "Prompt last command" },
{ "<leader>tc", ":CommandExecLast<CR>", desc = "Exec last command" },
{ "<leader>te", ":CommandEdit<CR>", desc = "Edit commands file" },
}
}