Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An option to print a colored message when the command completes #144

Closed
ethercrow opened this issue Jan 28, 2020 · 2 comments · Fixed by #698
Closed

An option to print a colored message when the command completes #144

ethercrow opened this issue Jan 28, 2020 · 2 comments · Fixed by #698
Labels
new feature Requests or requires a new feature

Comments

@ethercrow
Copy link

Here's what I do currently:

$ watchexec -- 'make build && echo "\n\033[0;32mOK\033[0m\n" || echo "\n\033[0;31mFAIL\033[0m\n"'

What I would like to do instead:

$ watchexec --colored -- make build

Please see a similar issue in another tool for some more motivation and screenshots: commercialhaskell/stack#1109

@passcod passcod added the new feature Requests or requires a new feature label Jan 28, 2020
@passcod passcod added this to the Command return improvements milestone Jan 28, 2020
@Mange
Copy link
Contributor

Mange commented Jan 28, 2020

Suggestion: Instead of bloating watchexec, you could have your own wrapper that you can use.

Place this in ~/.local/bin/show-exit:

#!/bin/sh

if ("$@"); then
  echo "$(tput setaf 3)Exited successfully$(tput sgr0)"
else
  status=$?
  echo "$(tput setaf 1)Failed with exit code ${status}$(tput sgr0)"
  exit $status
do

Then you can use it in front of any other command.

watchexec -- show-exit make build

I didn't test this script as I'm on my phone right now, but I think it would work.

@passcod
Copy link
Member

passcod commented Jan 18, 2022

Partial implementation in 1.18.0:

  • no colours
  • a message is only printed on non-success return

More improvements are likely!

@passcod passcod removed this from the Command return improvements milestone Jan 19, 2022
passcod added a commit that referenced this issue Nov 27, 2023
passcod added a commit that referenced this issue Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Requests or requires a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants