GithubHelp home page GithubHelp logo

nschlimm / easykey.shellmenu Goto Github PK

View Code? Open in Web Editor NEW
20.0 1.0 1.0 326 KB

Simple script to generate shell / bash menu with key selectors.

License: MIT License

Shell 100.00%
bash linux menu shell shell-script git git-commands kubectl kubectl-commands shell-menu

easykey.shellmenu's Introduction

Just a shell menu ๐Ÿฅ
(that simplified my work)

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 ๐Ÿ˜Š

Get started

Easy ! ๐Ÿ˜Ž

  1. Clone this repository.
  2. Then look into maven_example.sh
  3. Update that to write your own menu.
  4. To start the menu run bash maven_example.sh in your terminal (or rename as you wish)
  5. 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.

Syntax

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>

Simplest example menu

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

Maven demo menu (single column)

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

Example double column menu

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

Tipp: sourcing shellmenu.sh

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"

easykey.shellmenu's People

Contributors

nschlimm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

aadams35

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.