Skip to main content

See output/input status of all sub-folders

Project description

coi: manage shell script templates for reuse

I often improvise bash scripts and later regret not saving them. This tool manages shell script templates for reuse.

  1. run shell command templates with substitutions
  2. keep track of commands run in each folder for later reference
  3. store common templates

For example, the variable parts of the following batch execution may be

  1. folder name pattern: *_5/
  2. command: $ABIN/generate.py
for dname in *_5/; do python3 $ABIN/generate.py $dname${dname%/}-out.cms; done

After saving a template, we can rerun this command at current working directory with

coi -i "*_5" -c "python3 $ABIN/generate.py"

commands

  • templates sub command
    • coi templates add <name>
    • coi templates add <name> -t <template-file>
    • coi templates edit <name>
    • coi templates ls
    • coi templates rm <name>
    • coi templates set <name>
    • coi templates show <name>

example

Suppose the folder structure

jobs-folder
├── sub1
│   ├── 1.input
│   ├── 1.output
│   └── 2.input
├── sub2
│   ├── 1.input
│   └── 2.input
├── sub3
│   ├── 1.input
│   ├── 1.output
│   ├── 2.input
│   └── 2.output
└── sub4
    ├── 1.input
    └── 1.output
coi -c "wc -l" \
    -o "ll *.output" \
    -i "ll *.input" \
    jobs-folder
sub1 (1 / 2)
sub2 (0 / 2)
sub3 (2 / 2)
sub4 (1 / 1)

customization

Python [template strings](https://docs.python.org/3/library/string.html#template-strings ])

design

Essentially this is a tool for shell script templating, with up to 3 substitutions.

  • templates are saved in
    • system folder: default
    • XDG/coi/templates/: user defined
    • the user defined templates shadow default ones if name clashes
  • when a command is run once in path, save path/.coi/1.json where the keys are c, o, i, and template name

TODO:

  • default template
  • state machine when running main: q, r (always show the shell command to be run)

integration with fzf

If json files exists in a path, we can let the user pick with fzf

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coi-0.0.4.tar.gz (4.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page