MACROPAD for ls command line options menu

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
macewmi
 
Posts: 69
Joined: Sat Feb 08, 2020 10:26 am

MACROPAD for ls command line options menu

Post by macewmi »

I was excited to assemble and run the MacroPad from Adabox019. I was less excited about the Hotkeys app -- beautifully written, great source for programming ideas, but I didn't see how hitting a key on the pad instead of the TAB key was going to improve my life. I thought a bit and came up with something that will help me a lot.

I often use the terminal window and enter linux commands. Some, like the ls command have dozens of options. Typing them onto the command line with dashes, caps, lowercase, etc. can get tiresome. Not to mention having to remember options that I don't use frequently, e.g., the difference between -R and -r, or -T and -t.

So I created a macros file that lets me pick the command line options from a menu.

Usage:
  • Open a terminal window or switch to an existing one
    Push the Encoder to "type" the "ls" command
    Push the key(s) for my most frequently used file types
    Push the key(s) for any options
    Push the CR key (11) to run the command.
The biggest challenge here is coming up with short but descriptive key labels and colors to enhance usability. (I still have a lot of work to do there.)

Code: Select all

# MACROPAD Hotkeys for the ls terminal command
from adafruit_hid.keycode import Keycode # Not used in this example

app = {                    # REQUIRED dict, must be named 'app'
    'name' : 'Terminal ls', # Application name
    'macros' : [           # List of button macros...
        # COLOR    LABEL    KEY SEQUENCE
        # 1st row ----------
        (0x004000, '-h',  [' -h ']), # display filesize units
        (0x004000, '-R',  [' -R ']), # recurse into subdirectories
        (0x004000, '-r',  [' -r ']), # reverse sort order
        # 2nd row ----------
        (0x202000, '-S',  [' -S ']), # sort by filesize
        (0x202000, '-T',  [' -T ']), # format dates as Mdhmsy
        (0x202000, '-t',  [' -t ']), # sort by time changed
        # 3rd row ----------
        (0x400000, '-u',  [' -u ']), # sort by time accessed
        (0x400000, '-U',  [' -U' ]), # sort by time creation
        (0x5000ff, '.py', ['*.py *.sh *.sed']), # "Code" files
        # 4th row ----------
        (0x5000ff, '.txt', ['*.txt *.csv']),              # "Text" files
        (0x5000ff, '.png', ['*.jpg *.jpeg *.png *.img']), # "Graphics" files
        (0x50505f, 'CR',   ['\n']),                       # Send
        # Encoder button ---
        (0x000000, '', ['ls ']) # ls
    ]
}

User avatar
petronivs
 
Posts: 14
Joined: Tue Oct 07, 2014 10:05 pm

Re: MACROPAD for ls command line options menu

Post by petronivs »

Awesome! I've been intending to do a vi set, but haven't gotten to it yet.

Locked
Please be positive and constructive with your questions and comments.

Return to “AdaBox! Show us what you made!”