Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mhio/mash
mash - simple shell task runner
https://github.com/mhio/mash
bash build-scripts make shell task-runner
Last synced: about 2 months ago
JSON representation
mash - simple shell task runner
- Host: GitHub
- URL: https://github.com/mhio/mash
- Owner: mhio
- License: mit
- Created: 2018-04-08T22:46:07.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-06-05T07:23:34.000Z (8 months ago)
- Last Synced: 2024-06-05T08:46:23.562Z (8 months ago)
- Topics: bash, build-scripts, make, shell, task-runner
- Language: Shell
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### mash
A simple make-ish task runner in bash to avoid makefiles. Nothing fancy.
_______
Define functions in bash with the name `run:x` and then execute with `./mash x`
```
run:task:name () {
echo "I am task:name"
}
run:other(){
printf "I'm %s\n" "$*"
}
```$ ./mash task:name #runs `run:task:name`
I am task:name$ ./mash other a bunch of things #runs `run:other`
I'm a bunch of things### Setup
The `mash` scripts header and footer can be printed with the `dump` task to initialize a new file
$ ~/repos/make.sh/mash dump > ~/myrepo/mash
$ chmod 755 my/mashOr all in one
./mash dump:to ~/myrepo/mash### Tasks
List tasks
$ ./mash
or
$ ./mash help
Commands:
task:name
otherThe default `dump` task includes a shell completion helper
$ ./mash completion:words
task:name
otherFor zsh completions add a `_mash` file in `$fpath`
```
#compdef mashlocal context state state_descr line
tasks=( $(_call_program completion:words $words[1] completion:words) )
_arguments "1:task:($tasks)" \
"*:arg:->args"
```bash completion `/etc/bash_completion.d/mash`
```
_mash()
{
#pwd
#echo "0:$0 1:$1"
_script_commands=$($1 completion:words)local cur
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "${_script_commands}" -- ${cur}) )return 0
}
# no space after
#complete -o nospace -F _mash ./mash.sh
complete -F _mash mash
```### `sh` or `bash`
POSIX `sh` doesn't guarentee a function named with a `:` works, even though it does work for most
implementations. `bash` also allows for much simpler `${var:1:2}` substring indexing.MIT license