Code Monkey home page Code Monkey logo

smash's Introduction

Smash

Script merging app for shell - a set of functions allowing to slice and dice bash scripts

the tool is powered by zsh, bash is not supported

Usage

For example, to expand references to shell scripts in the same folder execute (for more details on this example see tests):

smasha bar.sh 'sudo apt-get install'

There are 4 separate functions supported:

  1. smash - expand references to the scripts in the same folder (substitute content from the scripts instead of their name mentions);
  2. smashd - expand references to files located in folders, mentioned in the script (substitude folder names with paths to specific files);
  3. smashc - combine commands with given prefix by merging the lists of arguments and removing duplicates;
  4. smashp - generate links to the source file by making all possible permutations of the parameter-value pairs in the filename, for example, if filename foo/bar/baz/qux-quux-foo=bar-hex=nex-one=two.quuz is passed as input, the command generates following links:
foo/bar/baz/qux-quux-foo=bar-one=two-hex=nex.quuz
foo/bar/baz/qux-quux-hex=nex-foo=bar-one=two.quuz
foo/bar/baz/qux-quux-hex=nex-one=two-foo=bar.quuz
foo/bar/baz/qux-quux-one=two-foo=bar-hex=nex.quuz
foo/bar/baz/qux-quux-one=two-hex=nex-foo=bar.quuz
  1. smasha - execute all operations listed above for the script located at given path.

Installation

To install the tool, just clone the repo at $HOME directory and update your .zshrc config:

git clone [email protected]:zeionara/smash.git "$HOME/smash"
echo -e '\n. "$HOME/smash/.zshrc"' >> "$HOME/.zshrc"

Testing

Alternatively, test script may be called:

./test/test.sh

The script expands file test/bar.sh, which has the following content:

#!/bin/bashh

echo 'foo'

qux

echo 'bax'

garply

echo 'mono'

and the following containing directory structure:

test
├── bar.sh
├── foo-expanded.sh
├── foo-updated.sh
├── foo.sh
├── garply
│   ├── fred.sh
│   └── waldo.sh
├── qux
│   ├── corge.sh
│   └── quux.sh
├── qux-quux.sh
└── test.sh

Into the following 4 files:

bar-qux=corge-garply=fred.sh

#!/bin/bashh

echo 'foo'

echo 'i am corge'

sudo apt-get install foo bar baz qux corge garply

echo 'bax'

echo 'i am fred'

echo 'mono'


bar-qux=corge-garply=waldo.sh

#!/bin/bashh

echo 'foo'

echo 'i am corge'

sudo apt-get install foo bar baz qux

echo 'bax'

echo 'i am waldo'

echo 'mono'


bar-qux=quux-garply=fred.sh

#!/bin/bashh

echo 'foo'

echo 'i am quux'

echo 'bax'

echo 'i am fred'

sudo apt-get install baz qux corge garply

echo 'mono'


bar-qux=quux-garply=waldo.sh

#!/bin/bashh

echo 'foo'

echo 'i am quux'

echo 'bax'

echo 'i am waldo'

echo 'mono'

smash's People

Contributors

zeionara avatar

Watchers

 avatar

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.