Protect what matters – even after you're gone. Make a plan for your digital legacy today.
Forum Discussion
Former Member
5 years ago[32] Set value from other variable / assignment
The simple use case is to copy one value somewhere else.
Let's say I have an Item as follow
MyItem
- oldSection
- a_var=value
For the basic "copy.paste" use case, I would have something like
op item edit newSection.my_var[Text]=op.oldSection.a_var
It would result in
MyItem
- oldSection
- a_var=value
- newSection
- my_var=value
With this, I would be able to curate (clean) my existing items in more sophisticated ways ::chuffed:
And the question is: any chance to get this feature ? ;)
1Password Version: 7.9.2
Extension Version: 2.0.0-beta.7
OS Version: macOS
5 Replies
- 1P_Simon
1Password Team
I was just looking for smoothing the process, and get this "updating" code out of python, back into 1password templates
When we're dreaming for a little (more long-term, I don't want to suggest that we can get to this right away), how would an ideal solution look like for you? Would you like to continue using the CLI directly from your Python code or would you prefer if 1Password would take care of that by supporting a Python SDK that allows you to perform actions like copying items?
For example, I could imagine https://github.com/1Password/connect-sdk-python supporting both Connect as well as personal accounts via Biometric Unlock (optionally via CLI) as a backing service.
The main benefit being that you can clean up your code further by replacing your
os.systemcalls with direct calls to the 1Password SDK.Would love to hear your thoughts and dreams!
That said, a more short-term solution: could you start a shell in your call to
os.systemso it does support evaluation?My Python is a little rusty, so excuse any errors. I imagine something like this:
os.system("sh -c op item edit MyItem "newSection.my_var[Text]=$(op item get MyItem --field a_var)")
- Former Member
Hi @"Justin.Yoon_1P" ,
I am actually managing the updates in a two-commands process similar to what you suggest (except within python code)
Therefore it works :)
-> I was just looking for smoothing the process, and get this "updating" code out of python, back into 1password templatesBests,
Emmanuel - Former Member
Hey @ebreton !
First off, I apologize, as it has been a while since our last correspondence.
I've filed an internal issue to look into the design for such referencing functionality on the value side of the assignment.
My first concern is that simply referencing another field would be ambiguous as to whether or not the CLI should assign the raw value
a.bor resolve that field.For the time being, would you be able to assign
op item get MyItem --field a_varto a variable, and pass that variable into theop item editcommand? - Former Member
Hi @eddy_1P ,
Thanks for helping out. It does not work since I am calling the op command from a python script (as a subprocess) and I do not have access to the command shell
$().-> It ends out writing the string
$(op item get MyItem --field a_var)in the item, as value for my field (which makes sense ;) ) - Former Member
Hey @ebreton,
The "copy-paste" scenario you mention can be achieved in the following way:
shell
op item edit MyItem "newSection.my_var[Text]=$(op item get MyItem --field a_var)"
Does this work for you?