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

New tmux options @1password-enabled-url-filter and @1password-items-jq-filter to disable and customize filtering #13

Closed
wants to merge 1 commit into from

Conversation

camspiers
Copy link

@camspiers camspiers commented Jan 3, 2020

Resolves #1 by providing two new tmux options:

@1password-enabled-url-filter to disable to default filtering
@1password-items-jq-filter to fully customize filtering

Enabled URL Filter

By default, the plugin maintains compatibility with sudolikeaboss by
filtering urls using the string "sudolikeaboss://local", by setting the following, the list of items will no longer be
filtered.

set -g @1password-enabled-url-filter 'off'

Default: 'on'

Customize URL Filtering

If complete customization of url filtering is required, a jq filter can be provided to filter and map
items.

Filtering by tags
set -g @1password-items-jq-filter '.[] | [select(.overview.tags | map(select(. == "tag_name")) | length == 1)?] | map([ .overview.title, .uuid ] | join(",")) | .[]'
Filtering by custom url
set -g @1password-items-jq-filter '.[] | [select(.overview.URLs | map(select(.u == "myspecial-url-filter")) | length == 1)?] | map([ .overview.title, .uuid ] | join(",")) | .[]'

Default: ''

Items come in the following format from which the filter operates:

[
  {
    "uuid": "some-long-uuid",
    "overview": {
      "URLs": [
        { "u": "sudolikeaboss://local" }
      ],
      "title": "Some item",
      "tags": ["tag_name"]
    }
  }
]

@camspiers
Copy link
Author

@yardnsm friendly ping 😃

@delucca
Copy link

delucca commented Jan 20, 2020

Tried here. It is working smoothly :)

@yardnsm
Copy link
Owner

yardnsm commented Jan 20, 2020

First of all - thanks! While this solution solves #1, it adds some complexity to the user and thus considered more "advanced" IMO.

I would suggest adding a tmux option to use the non-filtering method (the same filter that you used in this PR), for example:

# Default is 'on' in order to not break users
set -g @1password-enabled-url-filter 'off'

I'm all in favor for also keeping the TMUX_1PASSWORD_OP_ITEMS_JQ_FILTER, but use it as a tmux option as well:

set -g @1password-items-jq-filter '.[] | ......'

And the README should be updated as well:

  • Move the info regarding the the JQ_FILTER under the "Configuration" section, as it is a tmux option now.
  • Mention these new option under the "Configuring login items in 1Password" section.
  • Add a cool example usage to the @1password-items-jq-filter option, for example filtering only the items of a specific category.

WDYT?

And sorry for the delay 😅

@yardnsm yardnsm mentioned this pull request Jan 20, 2020
@camspiers
Copy link
Author

Sounds good to me, I will have a look into a solution meeting your suggestions some time in the coming week.

@delucca
Copy link

delucca commented Jan 28, 2020

@camspiers any updates on this?

…q-filter to disable and customize filtering
@camspiers camspiers changed the title Add ability to redefine JQ_FILTER for get_op_items function New tmux options @1password-enabled-url-filter and @1password-items-jq-filter to disable and customize filtering Jan 31, 2020
@camspiers
Copy link
Author

@yardnsm @odelucca New version ready for review.

Copy link

@delucca delucca left a comment

Choose a reason for hiding this comment

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

LGTM, but I suggested something :)

Also, I was taking a look where the script gets the items from op, why don't we develop a cache layer? In my opinion, if we disable the sudolikeaboss integration it became pretty slow, going to the web to fetch data every time.

I suggest we open a new PR to do this. If you want I can code based on your branch a suggestion to it :)

scripts/main.sh Show resolved Hide resolved
scripts/main.sh Show resolved Hide resolved
Copy link
Owner

@yardnsm yardnsm left a comment

Choose a reason for hiding this comment

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

Looks awesome! Sorry for the annoyance, but I have one last question: WDYT about removing the sudolikeaboss compatibility entirely? I mean, we have now the custom JQ filter option, so we can simply add a section to the README for users wanting to maintain the compatibility.

We can simply add the now legacy JQ filter that uses the URL filtering as an example of the @1password-items-jq-filter option in the README, and remove the @1password-enabled-url-filter option entirely.

What do you think? Sorry for the inconsistency of my comments 😅

@camspiers @odelucca

@delucca
Copy link

delucca commented Feb 1, 2020

@yardnsm I agree with you. sudolikeaboss works just in a pretty narrow use case, in my opinion we should support it, but not like we do today :)

@camspiers
Copy link
Author

Sorry, too much thrash for me.

@camspiers camspiers closed this Feb 23, 2020
yardnsm added a commit that referenced this pull request Feb 24, 2020
New tmux options @1password-enabled-url-filter and
@1password-items-jq-filter to disable and customize filtering #13

Originally opened by @camspiers
yardnsm added a commit that referenced this pull request Feb 24, 2020
* Apply changes from #13

New tmux options @1password-enabled-url-filter and
@1password-items-jq-filter to disable and customize filtering #13

Originally opened by @camspiers

* Remove the @1password-enabled-url-filter option

* Update README.md example

* Update README.md
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.

list items doesn't appear after fetching
3 participants