From ac2f4b94ac2385fa62a9ae09717e4f1410654f7f Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Thu, 16 Feb 2023 20:56:12 +0800 Subject: [PATCH] add a current session history menu (#378) * add a current session history menu * Update current_session_history_menu.nu * Delete non_default_vars_menu.nu --- custom-menus/README.md | 9 +++++ custom-menus/current_session_history_menu.nu | 36 ++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 custom-menus/README.md create mode 100644 custom-menus/current_session_history_menu.nu diff --git a/custom-menus/README.md b/custom-menus/README.md new file mode 100644 index 0000000..a7c4fba --- /dev/null +++ b/custom-menus/README.md @@ -0,0 +1,9 @@ +# Custom menus folder + +In this folder you can find custom menus for nushell. + +To make them work: +1. insert the code of chosen menu into the `menus` section of the `config.nu` file. +2. Check, that the name of the menu is uniqe +3. Add a shortcut to call for the needed menu in the `keybindings` section of the `config.nu` file + diff --git a/custom-menus/current_session_history_menu.nu b/custom-menus/current_session_history_menu.nu new file mode 100644 index 0000000..be4e1c2 --- /dev/null +++ b/custom-menus/current_session_history_menu.nu @@ -0,0 +1,36 @@ +# The part below should be pasted inside the 'menus' list of the 'config.nu' file + + { + # session menu + name: current_session_history_menu + only_buffer_difference: false + marker: "# " + type: { + layout: list + page_size: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + source: { |buffer, position| + + history -l + | where session_id == (history session) + | select command + | where command =~ $buffer + | each { |it| {value: $it.command } } + | reverse + | uniq + } + +# The part below should be pasted into the 'keybindgs' list of the 'config.nu' file + + { + name: "current_session_history_menu" + modifier: alt + keycode: char_r + mode: emacs + event: { send: menu name: current_session_history_menu } + } \ No newline at end of file