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

let user define their process completed key word #22

Closed
danie1Lin opened this issue Nov 4, 2021 · 19 comments · Fixed by #23
Closed

let user define their process completed key word #22

danie1Lin opened this issue Nov 4, 2021 · 19 comments · Fixed by #23

Comments

@danie1Lin
Copy link

Is your feature request related to a problem? Please describe.
At first, I found it did not work on my terminal. Then I looked into the script. I found we use # or $ to check the process if it is stopped.
here
But my command line is like 🤣
image

Describe the solution you'd like
If my understanding of the notify.sh is correct. We might let it be a customizable variable to capture the completed event.

@rickstaa
Copy link
Owner

rickstaa commented Nov 4, 2021

@danie1Lin Thanks for your feature request. We are indeed missing the % symbol that is used by the csh shell. Originally we only looked for the regular user indicator (i.e. $) but @ChanderG added support for the root user indicator (i.e. #) in 2aa2e2f.

I think adding % to this line list will solve the problem for most users. I think the csh prompt suffix should be included by default.

"$" | "#" | "%")

Apart from that, I have no problem adding a variable to specify additional prompt separators (e.g. @tnotify-prompt-suffix). I am, however, not sure for how many users such a variable would be helpful. Do you currently use shells with other prop prefixes? Since most shells use the $, # and % separators, I think such a use case only happens when a user changes the PS1 variable. @ChanderG, what do you think?

@rickstaa
Copy link
Owner

rickstaa commented Nov 4, 2021

@danie1Lin A fix for the bug you were experiencing is shipped in v1.2.0. Can you verify whether it works on your system?

I will keep this issue open so that we can discuss whether we want to also add a @tnotify-prompt-suffix variable. My preference is to keep the % for now and add the variable later when somebody requests a non-default prompt-suffix. But I first want to know what you and @ChanderG think.

@danie1Lin
Copy link
Author

danie1Lin commented Nov 8, 2021

Thank you for fast-developing this feature, @rickstaa!
I am using zsh. It is the theme of zsh modifying the $ps1 to %. I think it is quite common some themes will have many different types $PS1, and It is getting more complicated like p10k. Though, costuming the variable can resolve most of the situations. But I think the feature can be left until the day you don't want to add these patterns frequently, LOL. For now, It does solve my problem, thank you!

@rickstaa
Copy link
Owner

rickstaa commented Nov 8, 2021

@danie1Lin Thanks for your response and the use case. I added the @tnotify-prompt-suffixes variable to #24. The new version seems to work on my system. Can you please test to see if it works on your system? For example by using the https://github.com/romkatv/powerlevel10k you mentioned.

I asked @ChanderG to review the pull request since it contains a significant change. If @ChanderG approves my pull request I will merge it under v1.3.0

@danie1Lin
Copy link
Author

Hi @rickstaa, I tested #24. But sorry about the bad news, it does not work on p10k when the $PS1 like this, the capture of the last character will be the last character of time. Maybe we should consider regexp?
image

@rickstaa
Copy link
Owner

@danie1Lin Thanks a lot for testing my solution! Interesting, what is the literal version of your PS1 in that case? Is it ▸ or ~? What solution with regex do you have in mind?

Feel free to create a pull request on #24 if you think that is faster than explaining it here. The code can be debugged using breakpoints with the vscode bash extension using the following steps:

  • Replace the branch that is active in the /home/username/.tmux/plugins/tmux-notify.
  • Open vscode.
  • Open tmux in the integrated terminal.
  • Start the debug session on the script you want to debug.
  • The debugger should then stop on the breakpoints.

@rickstaa rickstaa self-assigned this Nov 12, 2021
@rickstaa
Copy link
Owner

rickstaa commented Jan 5, 2022

@danie1Lin I am currently not able to reproduce the problems you are experiencing. Did you see my previous questions?

@rickstaa rickstaa removed their assignment Jul 6, 2022
@kohane27
Copy link

Hello guys, I was wondering why tmux-notify was not working and I found this issue.

I'm using starship prompt that looks like below:

tmux-notify

As suggested in the above comment, I tried the following solution:

"$" | "#" | "%" | "➜")

but it doesn't work. Any input is much appreciated. Thank you!

@rickstaa
Copy link
Owner

Hello guys, I was wondering why tmux-notify was not working and I found this issue.

I'm using starship prompt that looks like below:

tmux-notify

As suggested in the above comment, I tried the following solution:

"$" | "#" | "%" | "➜")

but it doesn't work. Any input is much appreciated. Thank you!

Hey @kohane27. Could you maybe check if #24 solves your problem? I created that PR some time ago but since @danie1Lin didn't respond, did not merge it since I was uncertain if it worked. I'm happy to merge that pull request if it works for you 👍🏻.

@rickstaa
Copy link
Owner

@danie1Lin and @kohane27 this feature was released under #24. You can now set the bash prefix of your choice using the following tmux config command:

set -g @tnotify-prompt-suffixes ''

@kohane27
Copy link

Hello @rickstaa ,

Hope you're doing well.

Apologies for not checking the fix from the earlier msg.

I have just updated tmux-notify and I'm very happy to report that it's working!

2023-05-13-20-05-52

It's really handy to be notified about some long running processes.

Thank you so much and have a good day!

@cometta
Copy link

cometta commented Aug 24, 2023

image

i'm using zsh, may i know what should i set for tnotify-prompt-suffixes as my prompt look like above

@rickstaa
Copy link
Owner

@cometta I do not know by head which symbols are used to create that prompt. Can you please give me the result of echo $PS1?

@cometta
Copy link

cometta commented Aug 24, 2023

echo $PS1

$(kube_ps1)%{%f%b%k%}$(build_prompt)

@rickstaa
Copy link
Owner

echo $PS1

$(kube_ps1)%{%f%b%k%}$(build_prompt)

Ah, the symbol you are looking for is the last character returned by the build_prompt function. You could try to print the results of $(build_prompt) to see if this function is in the global scope. What customizations are you using in your .zshrc file? When I use the zsh shell, I use https://ohmyz.sh/.

@rickstaa rickstaa reopened this Aug 24, 2023
@cometta
Copy link

cometta commented Aug 24, 2023

echo $(build_prompt)

%{%K{black}%}%{%F{default}%} %(!.%{%F{yellow}%}.)%n@%m %{%K{blue}%F{black}%}%{%F{black}%} %~ %{%k%F{blue}%}%{%f%}

yes i'm using https://ohmyz.sh/. as well

@rickstaa
Copy link
Owner

rickstaa commented Aug 24, 2023

echo $(build_prompt)

%{%K{black}%}%{%F{default}%} %(!.%{%F{yellow}%}.)%n@%m %{%K{blue}%F{black}%}%{%F{black}%} %~ %{%k%F{blue}%}%{%f%}

yes i'm using https://ohmyz.sh/. as well

Ah, I think this is the setup you're using:

  • Shell: zsh
  • Configuration: Oh My Zsh
  • Theme: agnoster

The agnoster theme involves intricate PS1 modifications not currently monitored by the tmux-notify plugin. To address this, you need to focus on the prompt suffix defined in the following function block:

Main prompt
build_prompt() {
  RETVAL=$?
  prompt_status
  prompt_context
  prompt_dir
  prompt_git
  prompt_end
}

Source: agnoster.zsh-theme

This suffix is dynamically generated through the prompt_end function. To access the current suffix for a specific directory, you can use the SEGMENT_SEPERATOR symbol:

SEGMENT_SEPARATOR=''

Source: agnoster.zsh-theme

For your scenario, you should set the following in your Tmux configuration:

set -g @tnotify-prompt-suffixes ''

If you also want to support bash, you can specify multiple suffixes:

set -g @tnotify-prompt-suffixes ',$'

@rickstaa
Copy link
Owner

@cometta I created #52 for future reference. Please let me know if it also works on your side so that we can close this issue 👍🏻.

@cometta
Copy link

cometta commented Aug 24, 2023

it works. thank you

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 a pull request may close this issue.

4 participants