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

fix(scm-prompt): suppress cd output #985

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

vegerot
Copy link
Contributor

@vegerot vegerot commented Nov 22, 2024

Summary:
If a user has a chpwd hook that prints output, it will be prepended to the
dir variable which breaks the prompt. This change suppresses the output of
cd to prevent this.

Alternatively I considered doing cd -q to skip running the chpwd hook, but
decided against it.

Test Plan:

$ zsh --no-rcs
$ source ~/workspace/github.com/facebook/sapling/eden/scm/contrib/scm-prompt.sh && _scm_prompt
# things should be fine
$ say_hi() { echo hello } && chpwd_functions+=(say_hi) && _scm_prompt

prior to this commit, the prompt would be broken. After this commit, it should
be fine.

Background: in my particular case, I have a chpwd hook that
sources custom scripts
depending on the directory, and will tell me if it does so. This was breaking
the prompt, so I added this change to fix it.

Summary:
If a user has a `chpwd` hook that prints output, it will be prepended to the
`dir` variable which breaks the prompt. This change suppresses the output of
`cd` to prevent this.

Alternatively I considered doing `cd -q` to skip running the chpwd hook, but
decided against it.

Test Plan:

```zsh
$ zsh --no-rcs
$ source ~/workspace/github.com/facebook/sapling/eden/scm/contrib/scm-prompt.sh && _scm_prompt
# things should be fine
$ say_hi() { echo hello } && chpwd_functions+=(say_hi) && _scm_prompt
```
prior to this commit, the prompt would be broken. After this commit, it should
be fine.

Background: in my particular case, I have a `chpwd` hook that
[sources custom scripts](https://github.com/vegerot/dotfiles/blob/032f88715fa2911bec6b3c09aa012145bb1dae7e/.zshrc#L250-L252)
depending on the directory, and will tell me if it does so. This was breaking
the prompt, so I added this change to fix it.
@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants