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.
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
]
}