Skip to content

feat: Support multiple bangs in the same query#75

Open
Tyarel8 wants to merge 1 commit intodmlls:mainfrom
Tyarel8:multiple-bangs
Open

feat: Support multiple bangs in the same query#75
Tyarel8 wants to merge 1 commit intodmlls:mainfrom
Tyarel8:multiple-bangs

Conversation

@Tyarel8
Copy link
Copy Markdown
Contributor

@Tyarel8 Tyarel8 commented Mar 10, 2026

Basically, it occurred to me that custom bangs already support multiple targets, so it would be cool to be able to do it without creating a custom bang first.

I made it possible to do !g!ddg!w to open google, duckduckgo, wikipedia, etc. Everything else should be working the same, I have tested myself that it works but I could've missed something. Feel free to reject the pull request if it breaks something or it's badly implemented.

@dmlls
Copy link
Copy Markdown
Owner

dmlls commented Mar 12, 2026

Hi @Tyarel8, thanks for the PR! I'm having a pretty busy week, but will review and test it next week :)

@dmlls
Copy link
Copy Markdown
Owner

dmlls commented Mar 22, 2026

Hi @Tyarel8, I finally got a chance to review the PR.

I think this is a useful feature. However, right now there seems to be a bug when setting the bang symbol to some character that might appear in a bang, e.g., a. For example:

  • a: Amazon.com
  • aub: Aalborg Universitetsbibliotek

In the first case, aa no longer triggers anything. In the second, it takes you to Göteborgs universitetsbibliotek, which corresponds to the bang ub (i.e., the a is being trimmed).

I actually had this feature noted down in my backlog, but I never got to implement it because it comes with some important caveats. For example, take the bang aaa. If the user has the bang symbol set to a and they type: aaaa, how do we disambiguate between:

  • Triggering twice the bang for Amazon (a).
  • Triggering once the bang for AAA (aaa).

Separating the multiple triggers by a space could solve this, e.g.:

  • aa aa → Twice Amazon.
  • aaaa → Once AAA.

However, we could now have false positives. E.g., if the bang symbol was ace and the user wanted to search on Amazon "acer computer" with acea acer computer, the logic above would trigger:

  • A single a bang → Amazon.
  • plus r computer → Reddit.

We could use more exotic syntax, like grouping the bang triggers within curly braces, e.g., !{a r} query, but this seems to be deviating from the simplicity I'd like to keep in Yang. Furthermore, currently nothing stops the user from setting a bang {a , which again leads to problems... Tricky!

@Tyarel8
Copy link
Copy Markdown
Contributor Author

Tyarel8 commented Mar 22, 2026

You are right, I hadn't considered that non-symbol characters could be used for the trigger. Maybe the simples solution is to disallow characters that are in bangs for the triggers. Looking at kagi, here is the list of characters that are used: &'+-./0123456789@_abcdefghijklmnopqrstuvwxyzàáäåéõöüāışβγεικλξρςτυόабвгдзиклмнопрстуцшыяայնגוחטילמספקרابتخرسطلمويაორსტㄴ다사음전

@dmlls
Copy link
Copy Markdown
Owner

dmlls commented Apr 4, 2026

@Tyarel8 I wouldn't want to restrict the core functionality of Yang for this to work, there are a number of users who use letters in their bang triggers. Furthermore, this solution would be fragile: what if Kagi or DuckDuckGo added bangs with new characters? Do we keep limiting the allowed symbols with every release? You can imagine how frustrating that would be for users...

For now, the only solution I see is:

  • Requiring whitespace to separate multiple bangs, and
  • adding a setting (off by default) to enable this functionality. The setting description must warn users of the caveats of this feature especially when using common symbols/letters in the bang triggers.

Also, we need to keep in mind that bang triggers can go at the beginning or at the end of the query. I guess now with this feature they could also go in both sides?

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