listener - How to listen for a command on bash? -


i trying write webhook whenever specific command run in bash. example, when ls called, run script.

more specifically, when command spark ran, want write slack channel using webhooks.

put wrapper earlier in path. let's spark in /usr/bin. if users' paths have /usr/local/bin before /usr/bin, can in /usr/local/bin/spark:

#!/bin/sh [ "${_spark_wrapper_done}" ] || send-to-slack-here "$@" export _spark_wrapper_done=1 exec /usr/bin/spark "$@" 

...where send-to-slack-here, of course, code send message slack.

you move /usr/bin/spark /usr/bin/spark.real , put wrapper in original executable's place.


if control .bashrc, use shell function (though work in fewer scenarios):

spark() {   send-to-slack-here "$@"   /usr/bin/spark "$@" } 

Comments

Popular posts from this blog

python - argument must be rect style object - Pygame -

c++ - Qt setGeometry: Unable to set geometry -

php - Zend Framework / Skeleton-Application / Composer install issue -