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

Message printed to iTerm2 after every input #499

Open
LorenzoManfrediSegato opened this issue Apr 1, 2024 · 3 comments
Open

Message printed to iTerm2 after every input #499

LorenzoManfrediSegato opened this issue Apr 1, 2024 · 3 comments
Labels
🐛 bug Something isn't working

Comments

@LorenzoManfrediSegato
Copy link

LorenzoManfrediSegato commented Apr 1, 2024

Describe the bug

After entering a git directory, every command/input entered into iTerm 2 yields the following message printed:

set: -e: option requires an argument

~/.config/fish/functions/_tide_pwd.fish (line 23):
            set -e glob[(contains -i $parent_dir/$dir_section/ $glob)] # This is faster than inverse string match
            ^
in function '_tide_pwd'
	called on line 1 of file ~/.config/fish/functions/fish_prompt.fish
in command substitution
	called on line 1 of file ~/.config/fish/functions/fish_prompt.fish
in command substitution
	called on line 16 of file ~/.config/fish/functions/fish_prompt.fish
in function 'fish_prompt'
in command substitution
(Type 'help set' for related documentation)

Typing "help set" directs me back to the most recent existing open browser tab

Steps to reproduce

  1. cd into a git directory
  2. run input commands

Screenshots

Video:
https://github.com/IlanCosman/tide/assets/51752036/7d7c0be6-f3e3-46dc-826c-40b8c49a85cd

Environment

Output of tide bug-report:

fish version: 3.6.1
tide version: 6.1.1
term: xterm-256color
os: macOS
terminal emulator: iTerm2
fish startup: 5.54 millis
fisher plugins: jorgebucaran/fisher ilancosman/tide@v6

Additional context

@LorenzoManfrediSegato LorenzoManfrediSegato added the 🐛 bug Something isn't working label Apr 1, 2024
@ALuck0
Copy link

ALuck0 commented May 24, 2024

I'm also running into this same issue:

fish version: 3.7.1
tide version: 6.1.1
term: xterm-256color
os: macOS
terminal emulator: iTerm2
fish startup: 26.33 millis
fisher plugins: jorgebucaran/fisher ilancosman/tide@v6 edc/bass fabioantunes/fish-nvm

@MujiP
Copy link

MujiP commented Aug 3, 2024

Those error messages seem to only happen when the terminal window is small enough such that the working directory path gets abbreviated.

@Xadeck
Copy link

Xadeck commented Sep 25, 2024

TL;DR: are you using a pristine _tide_pwd.fish? That may be the problem.

I have the same issue but this is because I modified _tide_pwd.fish to remove a prefix from $PWD. The reason is that I work on a virtual filesystem mounting a huge mono repo under /company/cloud/$USER/$PROJECT, and:

  • I don't need the full /company/cloud/$USER/$PROJECT prefix, I only care about the subdirectories, as I'm typically working in a given project
  • Tide's pwd actually globs in all directories to abbreviate names, which makes it quite slow because cloud/ and the first two levels below have a lot of users and projects directories (shared monorepo!).

So I had the following diff:

10,11c10
<     set -l pwd (string replace -r \"/company/cloud/depot/$USER/([^/]+)/\" '' \$PWD)
<     if set -l split_pwd (string replace -r '^$HOME' '~' -- \$pwd | string split /)
---
>     if set -l split_pwd (string replace -r '^$HOME' '~' -- \$PWD | string split /)

This breaks the logic for shortening path when it can't be displayed because the length of the prompt is larger than the terminal (minus other left and right prompt, which in tide is the dist_btwn_sides variable).

The reason is that the logic tries to disambiguate by globing in each subdirectory, to truncate to a unique prefix AFAICT. IT has a strong assumption than when globing $parent_dir/$trunc it will find entries and one of them will be $parent_dir/$dir_section. That's a entirely valid assumption if you haven't messed with the initial $PWD. Its consequence is that the contains -i instructions will always return an integer. But when messing with the prefix, the assumption no longer holds, and contains -i returns nothing. You can repeat the error on the command line with:

$ set -e someval[(contains -i fruit carot potato cabbage)]
set: --erase: option requires an argument

(Type 'help set' for related documentation)

With that simple repro, you can devise a fix, by just adding a | echo so that a (empty) string is returned:

$ set -e someval[(contains -i fruit carot potato cabbage | echo)]

In conclusion, for me, the problem was solved with the following additional diff.

32c31
<             set -e glob[(contains -i \$parent_dir/\$dir_section/ \$glob | echo)] # This is faster than inverse string match
---
>             set -e glob[(contains -i \$parent_dir/\$dir_section/ \$glob)] # This is faster than inverse string match

Feature request

For @IlanCosman (thanks for Tide, it's amazing!) maybe you can add the | echo hack? Note that I wasn't able to reproduce the problem with a pristine _tide_pwd.fish even with a very narrow terminal, or in a git repo. So I strongly suspect that the cause is the OP tinkering. Or maybe being in a situation where glob returns nothing (maybe some intermediate dir has some weird permissions?).

Alternatively, it would be nice to have an option to disable the disambiguation logic, as the glob can be costly for non-local, non-sparse directories.

Finally, I tried to clone the directory and worked on this issue by running make test but that tries to do a make install, and even if commenting that, most test fails. What is the process for developing on Tide? I'd be happy to contribute but I need a good rinse & repeat setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants