The time when you forget your favorite commands is over! 😅
EasyKey.shellmenu is a simple script to generate menus for command execution in your favorite shell environment. ✨
- Execute your favorite commands with a keystroke
- Use single or double column menu
- Call user-defined shell functions or immediately execute shell command
- Return to menu once command or function completed
- Log executed commands
👌 Increase your productivity and relax !
Please leave a star ⭐ if you like EasyKey.shellmenu. If you experience any problems, please let me know 😊
Easy ! 😎
- Clone this repository.
- Then look into
maven_example.sh
- Update that to write your own menu.
- To start the menu run
bash maven_example.sh
in your terminal (or rename as you wish) - Optionally store the menu startup command on your function keys for easy access
You can also look into EasyKey.git git.sh
or EasyKey.kubectl kubectl.sh
. Two utilities based on EasyKey.shellmenu that I use in my daily work.
Use menuInit
to initialize a new menu.
Use submenuHead
to structure your menu into sub sections.
Use menuItem
to define keys in single column menus.
Use menuItemClm
to define keys for multi column menus (allows more actions in the menu).
Use startMenu
to start your menu in your shell window.
menuInit <menu title>
submenuHead <sub menu title>
menuItem <key> <description> <shell command>
menuItemClm <key> <description> <shell command> <key> <description> <shell command>
startMenu <optional: status info function>
The simplest menu requires this code:
source "./shellmenu.sh"
menuItem c "Clean all" "mvn clean:clean"
menuItem x "Compile" "mvn clean compile"
menuItem t "Test" "mvn clean test"
menuItem i "Install" "mvn clean install"
startMenu
![image](https://private-user-images.githubusercontent.com/876604/316422646-4a61a5f0-fadc-4018-b570-7b5e42551a02.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4NTcxNzIsIm5iZiI6MTcyMzg1Njg3MiwicGF0aCI6Ii84NzY2MDQvMzE2NDIyNjQ2LTRhNjFhNWYwLWZhZGMtNDAxOC1iNTcwLTdiNWU0MjU1MWEwMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODE3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxN1QwMTA3NTJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01MTY2ZjUzMWUxNWI0NWVlODQwNjAyNmIxNDJmMGFmZGRjZGM1NmEzZTgxN2JiMWNkZTkzMGU3ZmFjMDliNjQ5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.oOp-B6IFwILKvKADdXZje2ZjSZ06gSSq-uk2tZMA4jY)
The following example are taken from maven_example.sh
for illustration.
The Maven demo has its own heading and sub menu sections, but has only one column.
source "/path/to/shellmenu.sh"
menuInit "Maven demo menu"
submenuHead "Life cycle commands:"
menuItem c "Clean all" "mvn clean:clean"
menuItem x "Compile" "mvn clean compile"
menuItem t "Test" "mvn clean test"
menuItem i "Install" "mvn clean install"
submenuHead "Also usefull:"
menuItem d "Analyze dependencies" "mvn dependency:analyze"
menuItem u "Clean compile force updates" "mvn clean compile -U -DskipTests"
menuItem e "Show effective settings" "mvn help:effective-settings"
menuItem r "Show local repo location" "mvn help:evaluate -Dexpression=settings.localRepository | grep -v '\[INFO\]'"
menuItem l "Show global settings file location" showGlobalSettingFile
startMenu
Result is the following menu:
![image](https://private-user-images.githubusercontent.com/876604/316422854-5ad8e8d4-966c-493d-b8d0-ef2a514e242e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4NTcxNzIsIm5iZiI6MTcyMzg1Njg3MiwicGF0aCI6Ii84NzY2MDQvMzE2NDIyODU0LTVhZDhlOGQ0LTk2NmMtNDkzZC1iOGQwLWVmMmE1MTRlMjQyZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODE3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxN1QwMTA3NTJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04OTU5OTBiODYwOWUxYzQ1YjhiZDNkNjBmODZmMjQ5YjU4MmZiZWIwNzI5OWJmMTdlYTBjMDU4NjkzOTkzMjE5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.SeInn3H2ekPDhYSnsN0o9qNV00Z4A9UruQeM65bFKZs)
The following menu example is taken from the EasyKey.kubectl utility.
The kubectl
menu has many functions and sub sections in two columns to enable maximum amount auf commands in your menu.
![image](https://private-user-images.githubusercontent.com/876604/316423024-9130ac29-0a4f-42ee-9d7b-abdb882c80ff.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4NTcxNzIsIm5iZiI6MTcyMzg1Njg3MiwicGF0aCI6Ii84NzY2MDQvMzE2NDIzMDI0LTkxMzBhYzI5LTBhNGYtNDJlZS05ZDdiLWFiZGI4ODJjODBmZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODE3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxN1QwMTA3NTJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00YTEyYjcyMGIxYzA0MDI4NTBmOTUxNGI1MjRiYjI2MzliZTQ3MmJiNmY5OTNkNzViZDIwYjlhYWZjMjYxNmI2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.XCI5u5fRR3oy0uh1J7pYJFE5pfrp_Ur0S0NEGvSNxp4)
Every menu script you will write needs to source shellmenu.sh
.
Here are several options for sourcing shellmenu.sh
from your menu script:
Option 1: Use absolute paths
# Source shellmenu.sh using absolute paths
source "/path/to/shellmenu.sh"
Option 2: Set a variable for script directory
# Set the variable for the main script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Source shellmenu.sh using the variable
source "$SCRIPT_DIR/relative/path/to/shellmenu.sh"