A quick launch menu for Nushell.
Just Nushell
Warning
This requires nushell ^0.86.0Using it with previous version is possible but requires editing the very last line of
me.nu
Simply remove the--env
flag in after thedo
command.
The only downside is that commands that modify the env, such as those that navigate the filesystem likecd
, won't work.
- Download the
me.nu
script in a folder, such as~/.config/me.nu
- In your config in
$nu.config-path
source the script by adding
source '~/.config/me.nu` # Or another path
- Define your commands. You can follow the example here for some inspiration.
The menu searches for the variable $env.nu_menu_commands
, which should be defined as a List<Record>
with the following structure:
$env.nu_menu_commands = [
{
description: "Hello World" # Description to be displayed. Capital letters will be underlined
keymap: "hw" # Keys to invoke the command
command: { print "Hello World" } # **Closure** that will be invoked
group: "Examples" # [Optional] group of the command
}
]
Note
Commands must have unique keymaps!
Check out menu_config.nu for some Telescope.nvim inspired commands!
By default the menu launches with Ctrl + Space
.
After launching the command you can enter your sequence of characters to execute the command.
In our example, we can press h
followed by h
to print "Hello World".
In case of commands with the same prefix, for example a command hn
that prints "Hello Nu", when pressing the first h
key
the table output would display the commands that have the h
root.
By pressing <Space>
the menu will toggle the Edit Mode. In this mode, after typing the key sequence, the command will be inserted in your command line instead of being executed directly.
For example by pressing <space>hh
the command line will be set to > print "Hello World"
. This can be useful for passing flags to your own commands when required.
- Enter and Esc will close the menu
- Backspace will delete the last character
- Uppercase characters are allowed
Feel free to contribute! PRs are welcome!
- Install script
- Nupm compatibility