Easily select and launch commands directly from neovim
It uses snacks.nvim as backend, providing a lighter and more integrated terminal experience
{
"0xfraso/command.nvim",
opts = {}, -- see section below for configuration options
dependencies = {
"folke/snacks.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
The snacks terminal includes these built-in keymaps (customizable):
q- Hide terminalgf- Edit file under cursor<esc><esc>- Exit insert mode (double ESC)
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 = {
"folke/snacks.nvim",
},
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" },
}
}