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

Add support for any macOS terminal #100

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

Conversation

stepan-tikunov
Copy link

After this change, the plugin will determine the app ID by the PID of the top-level parent process (which corresponds to the currently used terminal emulator) when using any terminal besides iTerm or Apple Terminal. This enables basic plugin functionality, such as determining if the terminal emulator is in focus, sending notifications, and navigating the user back to the terminal after they press "Show" button inside notification.

else
return $?
else
return $?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is less understandable then it was before — this clause is part of the outer if, so it should either be the way it was before, or on the same level (4 spaces less indent) as the outer if.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, my bad. Fixed it

lib
@@ -16,6 +16,31 @@ function current-tty {
fi
}

# Find the top level parent PID of current shell (not including root process), also accounting for TMUX
function top-level-ppid {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function will infinitely recurse if ps doesn’t take the expected options (maybe on other BSDs? I dunno), or if there is no process with PID 1 (maybe in a container?).

I’m not especially worried about this, but it could be prevented by setting setopt localoptions errexit here.

Copy link
Author

Choose a reason for hiding this comment

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

but it could be prevented by setting setopt localoptions errexit here

Tried to google this option and barely found anything. I think I fixed it much simpler :)

Copy link
Contributor

Choose a reason for hiding this comment

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

That works too!

setopt localoptions errexit might be hard to google because zsh ignores underscores in the options. Just running setopt gives a list of options, which are reported without underscores, but the manual lists them with underscores. So the above is equivalent to setopt local_options err_exit.

  • local_options causes the shell options to only be set for the duration of the local function.
  • err_exit causes the shell to exit when a command fails, like set -e. (It should probably have been err_return which causes the function to return.)

Docs:

@danielparks
Copy link
Contributor

This is very clever! I like it. I just had a couple of minor comments.

Copy link
Contributor

@danielparks danielparks left a comment

Choose a reason for hiding this comment

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

Looks good!

@stepan-tikunov
Copy link
Author

@danielparks can you merge? Or is it necessary for someone else to review this?

@danielparks
Copy link
Contributor

I cannot. Sorry, I couldn’t remember if this was one of the (few) repos I had access to.

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