Skip to main content

See output/input status of all sub-folders

Project description

PyPi version licence PyPI - Downloads

coi: manage shell script templates for reuse

I often improvise the same (boring) bash scripts over and over again. This is my solution to cut the repetitive work.

This command-line tool can

  1. manage (CRUD) templates
  2. run template command with substitutions
  3. keep track of commands run in each folder for later reference


Three examples are in order here. They are all small frequent for loops. One could alternatively define shell functions for them.

In the first example, I need to delete jobs with some key word. The varying part is BIHYEW10.

for x in `qstat -u nosarthur |grep BIHYEW10 |awk '{print $1}'`; do
  qdel $x

With coi set up, I can simply do

coi run -i BIHYEW10

The corresponding template is

for x in `qstat -u nosarthur |grep $i |awk '{print $$1}'`; do
  qdel $$x

Note that it's simply the Python [template strings]( ]).

In the second example, I often need to process data with a common directory pattern, e.g., ABC_5/ABC-out.cms:

for dname in *_5/; do python3 $dname${dname%/}-out.cms; done

Here the variable parts are

  1. folder name pattern: *_5/
  2. command: $ABIN/

After saving a template, we can run

coi run -i "*_5" -c "python3" some-path

and the template is

cd $path
for dname in $i; do
  $c $$dname$${dname%/}-out.cms

where some-path will substitute $path.

In the third example, I often want to know how many jobs are done in many folders, and the criteria of 'done' may vary.

Suppose the folder structure is as follows

├── 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" \


  • run command
    • coi run -i <i> -c <c> -o <o> -t <name> <path>: run template command <name>
  • templates command
    • coi templates add <name>: create a new template called <name>
    • coi templates cp <name> <new-name>: copy <name> to a new template called <new-name>
    • coi templates ll <name>: show content of template <name>
    • coi templates ls <name>: show path of template <name>; You can pass it to your favorate editor.
    • coi templates rm <name>: delete template <name>
    • coi templates set <name>: set template <name> as default template
    • coi templates set: show default template name

The run command takes up to 3 parameters c, 'o', and 'i'. If template -t is not specified, default template is used. If <path> is omitted, current working directory is used.


User defined templates are saved/searched in $XDG_CONFIG_HOME/coi (most likely ~/.config/coi/).

other tune-ups

alias coir='coi run'
alias coit='coi template'


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


  • default template
  • auto complete for templates

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.8.tar.gz (9.1 kB view hashes)

Uploaded source

Supported by

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