-
Notifications
You must be signed in to change notification settings - Fork 79
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
base: master
Are you sure you want to change the base?
Conversation
applescript/functions
Outdated
else | ||
return $? | ||
else | ||
return $? |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
@@ -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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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, likeset -e
. (It should probably have beenerr_return
which causes the function to return.)
Docs:
setopt
in https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html forLOCAL_OPTIONS
andERR_EXIT
in https://zsh.sourceforge.io/Doc/Release/Options.html (butERR_RETURN
might have been better)
This is very clever! I like it. I just had a couple of minor comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
@danielparks can you merge? Or is it necessary for someone else to review this? |
I cannot. Sorry, I couldn’t remember if this was one of the (few) repos I had access to. |
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.