Notes
This syntax,
foo = "!f() { echo $$; sleep 20; }; f"
is an alternate way to define aliases.
When you run:
git zz arg1 arg2 arg3
git runs it this way:
['/bin/sh', '-c', 'f() { echo $$; sleep 20; }; f "$@"', 'f() { echo $$; sleep 20; }; f', 'arg1', 'arg2', 'arg3']
NOTE: The choice of /bin/sh
appears to be hard-coded into git.
Example
git nothave
If you use pipes, etc., it seems you might need to create a
subshell for the function or /bin/sh
compains
nothave = ls-files --others --exclude-standard # See also "git clean -df" nothave-rm = "!f() {( git nothave | xargs -opn1 rm )}; f"
NOTE: The subshell is needed in the nothave-rm
definition. Without it, I get this error:
f() { git nothave | xargs -opn1 rm }; f: -c: line 1: syntax error: unexpected end of file