up
up searches upwards through the tree for a given file then runs commands there
Why
Initially so that it was easier to call build and run scripts (up build
, up run
), then so that I could call Makefiles (up make
) and then so I could check for nested git (up -r git
). Finally so that I could package a utility up and make it look pretty.
Usage
up [OPTIONS] FILE [ARGS...]
up [OPTIONS] -f FILE COMMAND [ARGS...]
up [OPTIONS] -c COMMAND FILE [ARGS...]
Options
f
- the file to search forc
- the command to execute in the directory where the file is found- optional
- default:
./<file>
~ $ up -c ls srv /home/normal-gaussian bin etc lib64 opt run sys var boot home lost+found proc sbin tmp dev lib mnt root srv usr
r
- recursively call up until the root of the tree is reachedt
- test without running the commani
- invert the match som
- supress colour. Live life in monochromed
- provide debug informationq
- be quiet by not printing on stdoutQ
- be quieter by not printing on stderr or stdoutv
- print version information to stdout
Examples
List all parent directories
~ $ up -qrf . pwd
/home/normal-gaussian
/home
/
~ $ up -qrf .git pwd
/home/<user>/<company>/<repository/<submodule>
/home/<user>/<company>/<repository
/home/<user>
Run a build script in a parent directory
/srv/normal-gaussian.com/content/pages/up $ up build
/srv/normal-gaussian.com/content
[ Passed ] 00-acquire-sudo.sh
[ Passed ] 01-clear-temp.sh
[ Passed ] 10-copy-source.sh
[ Passed ] 20-run-bash.sh
[ Passed ] 30-style-sass.sh
[ Passed ] 35-convert-charsets.sh
[ Passed ] 40-render-pug.sh
[ Passed ] 90-nginx-rules.sh
[ Passed ] 99-publish.sh
[ Complete ] No Errors