Skip to content
New issue

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

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

Already on GitHub? # to your account

Fixes crontab throwing errors when tmux isn't running #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

AmirGhiassian
Copy link

Previously, when the plugin was installed, changing directories or every couple minutes it would throw an error because there wasn't any tmux session. So I did this:

If you run echo $TERM_PROGRAM in tmux, the value will be tmux

So first commit I did was to test this fix to see if it works on one function, so then I implemented it in a function and put them for everything:

# Check if we are in tmux
check_tmux() {
  if [ "$TERM_PROGRAM" = "tmux" ]; then
    true
  else
    false
  fi
}

That's all! Tested on my Mac-book M1 Pro, running Mac OS V15.0 beta

And formatted code a little bit. Reason for this check is because the
cron job runs even if tmux isn't open and causes error messages because
there isn't any active tmux session
@AmirGhiassian
Copy link
Author

Edit: My prettier plugin also formatted the lines so that is why the lines changed is high

@AmirGhiassian
Copy link
Author

Never mind, didn't fix the issue:
image

@thepante
Copy link
Owner

thepante commented Aug 5, 2024

Hey thanks for the heads up.
That's right, I saw that error on the shell when not under tmux. That's something to address!

As I understood, the capture should be about something else.
That seems to be the job daemon log. It should be suppressed by editing the cronjob:

crontab -e

And there append this > /dev/null 2>&1 to this plugin job, something like this and save it:

*/1 * * * * /Users/thepante/.tmux/plugins/tmux-git-autofetch/git-autofetch.tmux --scan-paths > /dev/null 2>&1

That should suppress that noise under mail.
Let me know if that worked.

I'll better check standards about how to handle cronjobs and update it 😅


Will check out your PR and merge it! Thanks for it.

@thepante thepante reopened this Aug 5, 2024
@AmirGhiassian
Copy link
Author

Hi, sorry for the late response.

Thank you for the temp fix, I won't apply it for myself just yet, il try and see if I can help out and adjust the cron job 😁

@AmirGhiassian
Copy link
Author

Don't merge yet, I messed up my gpg key and also I haven't tested it yet.

Instead of checking in each function, it will check before the switch
statement, less lines of code = efficient code =)

Signed-off-by: Amirreza Ghiassian <amir@Amirs-Macbook.local>
@AmirGhiassian
Copy link
Author

Should be fixed now 👍🏽

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants