sobolevn / wakatime-zsh-plugin

🕒Track how much time you have spent in your terminal!
https://wakatime.com/terminal
MIT License
91 stars 10 forks source link

fix WAKATIME_DO_NOT_TRACK documentation #9

Closed ronlut closed 4 years ago

ronlut commented 4 years ago

Hi. Sure - this feature didn't work at all for me. I'm not very familiar with zsh syntax TBH, so I'm not sure about the original syntax ((( VAR ))) to check if a variable is set. I tried the original syntax in a simple test script and it doesn't work:

test.sh

if (( A )); then
  echo "A"
fi
❯ zsh -c "export A=B && ./test.sh"
./test.sh: 1: ./test.sh: A: Permission denied

While this works: test_working.sh

if [ "$A" ]; then
  echo "A"
fi
❯ zsh -c "export A=B && ./test_working.sh"
A

That's why I switched to the new syntax. Try it and let me know what you think, maybe I'm missing something :)

sobolevn commented 4 years ago

Are you sure that your test.sh has correct shebang? Can you please try the same with: A=1 zsh ./test.sh?

Because my test works correctly:

~                                                                                    
» if (( A )); then
  echo "A"
fi

~                                                                                    
» export A=1

~                                                                                    
» if (( A )); then
  echo "A"
fi
A
ronlut commented 4 years ago

I just want to say that I started checking this behavior as I tried to stop tracking by running export WAKATIME_DO_NOT_TRACK=true, which didn't stop without my proposed fix.

Few things:

I guess the options are either to use a different condition in the if as I proposed or change the documentation that states:

$WAKATIME_DO_NOT_TRACK: you can also disable tracking for some period of time by setting environment variable to any non-empty value, defaults to false

sobolevn commented 4 years ago

Yes, let's better change the docs to be "set WAKATIME_DO_NOT_TRACK=1"

ronlut commented 4 years ago

Did that. I still think it might be confusing but let's see how it goes 🙂

sobolevn commented 4 years ago

Thanks a lot!