yardnsm / tmux-1password

:key: Access your 1Password login items within tmux!
MIT License
252 stars 24 forks source link

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

Closed camspiers closed 4 years ago

camspiers commented 4 years ago

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 commented 4 years ago

@yardnsm friendly ping 😃

delucca commented 4 years ago

Tried here. It is working smoothly :)

yardnsm commented 4 years ago

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:

WDYT?

And sorry for the delay 😅

camspiers commented 4 years ago

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

delucca commented 4 years ago

@camspiers any updates on this?

camspiers commented 4 years ago

@yardnsm @odelucca New version ready for review.

delucca commented 4 years ago

@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 commented 4 years ago

Sorry, too much thrash for me.