Skip to content

Conversation

@AnnatarHe
Copy link
Contributor

Summary

  • Pass parent process ID (PPID) to shelltime track command for terminal emulator detection

Changes

  • bash.bash: Add --ppid=$PPID to track calls
  • zsh.zsh: Add --ppid=$PPID to track calls
  • fish.fish: Capture PPID at shell startup (ps -o ppid= -p %self), add --ppid=$FISH_PPID to track calls

Related PRs

Notes

  • Bash and Zsh have native $PPID variable
  • Fish requires ps command to get parent PID at shell startup

🤖 Generated with Claude Code

Pass parent process ID to shelltime track command for terminal
emulator detection in daemon service.

- bash: add --ppid=$PPID to track calls
- zsh: add --ppid=$PPID to track calls
- fish: capture PPID at startup, add --ppid flag

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @AnnatarHe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement to the shelltime tracking system by integrating the Parent Process ID (PPID) into the command tracking data. This addition provides a crucial piece of information for identifying the specific terminal emulator environment from which commands are executed, thereby enriching the context of collected usage statistics and facilitating more precise analysis of shell activity.

Highlights

  • PPID Capture: Implemented the capture and passing of the Parent Process ID (PPID) to the shelltime track command.
  • Terminal Tracking Enhancement: This enables improved terminal emulator detection for more accurate usage tracking within the shelltime system.
  • Shell-Specific Implementation: Bash and Zsh leverage their native "$PPID" variable, while Fish shell uses a "ps -o ppid= -p %self" command to determine and store the PPID at startup.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds parent process ID (PPID) capturing to the bash, zsh, and fish shell hooks. This is a useful feature for terminal emulator detection. The implementation for bash and fish shells is correct. However, in the zsh hook, there's a potential issue with unquoted variables that could cause problems for commands containing spaces. I've added suggestions to address this.

hooks/zsh.zsh Outdated
fi

shelltime track -s=zsh -id=$SESSION_ID -cmd=$CMD -p=pre &> /dev/null
shelltime track -s=zsh -id=$SESSION_ID -cmd=$CMD -p=pre --ppid=$PPID &> /dev/null

Choose a reason for hiding this comment

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

high

The $CMD variable is not quoted. If a command contains spaces or other special characters (e.g., ls -l), it will undergo word splitting, and the shelltime track command will receive incorrect arguments. To ensure the entire command is passed as a single argument to the -cmd flag, you should double-quote the variable. This is already done correctly in the bash.bash and fish.fish hooks.

    shelltime track -s=zsh -id=$SESSION_ID -cmd="$CMD" -p=pre --ppid=$PPID &> /dev/null

hooks/zsh.zsh Outdated
return
fi
shelltime track -s=zsh -id=$SESSION_ID -cmd=$CMD -p=post -r=$LAST_RESULT &> /dev/null
shelltime track -s=zsh -id=$SESSION_ID -cmd=$CMD -p=post -r=$LAST_RESULT --ppid=$PPID &> /dev/null

Choose a reason for hiding this comment

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

high

Similar to the preexec function, the $CMD variable here should be double-quoted. This will prevent word splitting for commands that contain spaces, ensuring the command is correctly passed to shelltime track.

    shelltime track -s=zsh -id=$SESSION_ID -cmd="$CMD" -p=post -r=$LAST_RESULT --ppid=$PPID &> /dev/null

@AnnatarHe
Copy link
Contributor Author

Code Review

This pull request adds parent process ID (PPID) capturing to the bash, zsh, and fish shell hooks. This is a useful feature for terminal emulator detection. The implementation for bash and fish shells is correct. However, in the zsh hook, there's a potential issue with unquoted variables that could cause problems for commands containing spaces. I've added suggestions to address this.

@claude fix the code review issues

Commands containing spaces (e.g., `ls -l`) would undergo word splitting,
causing incorrect arguments to be passed to shelltime track. This aligns
with the quoting pattern already used in bash.bash and fish.fish.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@AnnatarHe AnnatarHe merged commit 72016a3 into main Jan 6, 2026
4 of 6 checks passed
@AnnatarHe AnnatarHe deleted the feat/terminal-tracking branch January 6, 2026 13:16
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