Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Use Growl to monitor long-running shell commands' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use Growl to monitor long-running shell commands
Authored by: dbingham on Oct 12, '07 08:05:05AM
For those of you with the "Some Command" problem:

On OS X 10.4, you can fix this by changing

export PREEXEC_CMD="$BASH_COMMAND"

in the preexec function in your bashrc to

export PREEXEC_CMD="$1"

Since the version of bash that ships with 10.4 doesn't support the BASH_COMMAND variable, you can depend on the value passed by the .preexec.bash.

Also, I changed the default text for the title to "Shell Command" instead of "Some Command" so that to a casual observer, the message seems more purposeful and less confused. You know...to each his own.

-dbingham

[ Reply to This | # ]
Use Growl to monitor long-running shell commands
Authored by: kyngchaos on Oct 12, '07 09:10:26AM

Ack! That works, but is not good. $1 is the WHOLE command, including all parameters. First, long commands can create a large notify box. Second, growlnotify tries to interpret any flags in that command - those parameters that start with a hyphen (this must be a bug). I tried quoting ${PREEXEC_CMD:-Some Command} but that didn't help.

How would you get the first word of $1, which would be just the command with no parameters?



[ Reply to This | # ]
Use Growl to monitor long-running shell commands
Authored by: dbingham on Oct 12, '07 09:48:53AM
Try:

export PREEXEC_CMD="$(echo $1 | awk '{print $1}')"

However, note that unless I'm mistaken, $BASH_COMMAND would include the entire command and all its arguments were it working. So, not sure if just getting the first word is entirely correct. I concur that this seems more like an issue with growlcode than with using $1 or $BASH_COMMAND.

Perhaps instead of just taking the first word, a better workaroud would be to just replace the dash with another character like tilde:

export PREEXEC_CMD="$(echo $1 | sed 's/-/~/g')"

Now, at a quick glance it still looks right.

-dbingham

[ Reply to This | # ]
Use Growl to monitor long-running shell commands
Authored by: kyngchaos on Oct 12, '07 11:53:36AM

that awk bit works. Thanks.

The full command may be what was originally intended. But whether that's appropriate or not gets back to my first point - long commands (I often run configures with a long stream of options) can either create a large growl box, unless limited in the growl prefs. In the end, all I need to see for a quick notification is the command and not all its parameters.



[ Reply to This | # ]