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

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

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