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

Fixes bug #7 which allowed for multiple simultaneous pane monitoring #14

Merged
merged 7 commits into from
Nov 23, 2020
Merged

Fixes bug #7 which allowed for multiple simultaneous pane monitoring #14

merged 7 commits into from
Nov 23, 2020

Conversation

rickstaa
Copy link
Owner

This pull request fixes bug #7 which allowed the same pane to be monitored multiple times. Additionally with the new fix user are now also able to monitor multiple panes in different windows and sessions at the same time.

PANEID=$(tmux list-panes | grep "active" | awk -F\] '{print $3}' | awk '{print $1}')
PID_DIR=~/.tmux/notify
# Get current directory
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not using just using CURRENT_DIR=$(dirname $BASH_SOURCE)?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChanderG Thanks for bringing that up I missed that myself. I reused that code from commit 5f7554e. When I did that commit, I use the
code of the tmux-continuum plugin of @bruno- as a template. I did some research myself, and it looks like it is the most reliable way to get the ABSOLUTE script path (See this stackoverflow question). I am however not sure if there are cases where the relative path fails while the absolute path works. Maybe @bruno- still knows why he added the extra cd and pwd arguments in his original commit.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also seems to be the recommended answer in this stackoverflow question.

Copy link
Owner Author

@rickstaa rickstaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChanderG I quickly double-checked why the CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && PWD )" syntax is used in most bash scripts over the simpler CURRENT_DIR=$(dirname $BASH_SOURCE) syntax. The reason is explained in this blog post. The longer version always get the absolute path and therefore also works when the working directory is changed before you use the path. As this doesn't seem to be the case in our scripts, we can also use the shorter form. Nevertheless, I think it does not hurt the use of the longer version to prevent future possible errors if we change the scripts in the future. Let me know what you prefer so that I can merge this pull request.

PANEID=$(tmux list-panes | grep "active" | awk -F\] '{print $3}' | awk '{print $1}')
PID_DIR=~/.tmux/notify
# Get current directory
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChanderG Thanks for bringing that up I missed that myself. I reused that code from commit 5f7554e. When I did that commit, I use the
code of the tmux-continuum plugin of @bruno- as a template. I did some research myself, and it looks like it is the most reliable way to get the ABSOLUTE script path (See this stackoverflow question). I am however not sure if there are cases where the relative path fails while the absolute path works. Maybe @bruno- still knows why he added the extra cd and pwd arguments in his original commit.

PANEID=$(tmux list-panes | grep "active" | awk -F\] '{print $3}' | awk '{print $1}')
PID_DIR=~/.tmux/notify
# Get current directory
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also seems to be the recommended answer in this stackoverflow question.

This commit fixes a bug which used the `$CURRENT_DIR` variable before it
is used.
This commit fixes a bug which caused the cancel monitoring message to
appear twice.
This commit removes the codacy badge as the upstream does not use it.
@rickstaa rickstaa merged commit 941ac00 into rickstaa:master Nov 23, 2020
@rickstaa
Copy link
Owner Author

@ChanderG I fixed some last bugs and merged the changes into the master branch. Feel free to let me know if you want to use the simpler directory fetch syntax.

@ChanderG
Copy link
Collaborator

I wasn't aware of the use of the longer version. Makes sense.

@rickstaa
Copy link
Owner Author

I wasn't aware of the use of the longer version. Makes sense.

I wasn't familiar with it either. There is also the cd - p version to make it work with symlinks.

@rickstaa rickstaa deleted the fix_multi_call_#7 branch November 23, 2020 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants