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

Setting gpg-tui --select key_id to a variable doesn't load #27

Closed
lmburns opened this issue Jul 14, 2021 · 9 comments
Closed

Setting gpg-tui --select key_id to a variable doesn't load #27

lmburns opened this issue Jul 14, 2021 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@lmburns
Copy link

lmburns commented Jul 14, 2021

Wanting to try and use gpg-tui in scripts or with neomutt and when attempting to do something like the following:

key=$(gpg-tui --select key_id)

The screen to select never loads. I can do this in either a script or just in the shell and it doesn't work. If I do not set it to a variable it works just fine.

Edit: If I do the same as above and set it to a variable, then I click enter (no screen present to select a key), the program quits stalling. Then when printing the variable it was set to does print out a key_id, I was just never able to visually select it.

System Information (if useful):

uname -a
Darwin void.local 20.5.0 Darwin Kernel Version 20.5.0: Sat May  8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64 i386 MacBookPro14,1 Darwin

echo $SHELL
/usr/local/bin/zsh

echo $ZSH_VERSION
5.8

Terminal: iTerm2

@lmburns lmburns added the bug Something isn't working label Jul 14, 2021
@orhun
Copy link
Owner

orhun commented Jul 14, 2021

Ah, good catch. It's a simple standard stream issue I reckon.

In 916ded7, I set the TUI stream as stderr so the output should not be blocked now.

key=$(cargo run -- --select key_id) && echo "Selected: ${key}"

Can you try and let me know if it works?

@lmburns
Copy link
Author

lmburns commented Jul 14, 2021

Yes, the new update does work, awesome!

@orhun
Copy link
Owner

orhun commented Jul 14, 2021

Great! I'll ship a new release soon. 🥂

Wanting to try and use gpg-tui in scripts or with neomutt and when attempting to do something like the following:

If you don't mind my curiosity, what exactly are you using gpg-tui for? I want to add a shell script example to README.md about the usage of --select that's why I'd like to know.

Also what do you think of #19? Does gpg-tui need any additional implementation for it? How did you utilize it? That'd be really awesome if you can give me some information :)

@lmburns
Copy link
Author

lmburns commented Jul 14, 2021

Well I'm using it on macOS, and I created a fairly long script that involves tagging files, and one of the options involves editing the file if it is gpg encrypted, and another options is to just simply encrypt or decrypt it. I am now trying to provide the user the ability to select the key to encrypt the file with if they have gpg-tui installed.

Another option that I would like to do is incorporate it with neomutt; however, I haven't looked too much into it and am not sure exactly how I could do that. neomutt will prompt the user which key to use when selecting an email, but getting it to use gpg-tui may be a different story. I only thought of this because I saw the comment on your reddit post on the newest release.

One feature that I think could be added, I mean it would obviously be dependent upon what you'd like this program to ultimately be, but whenever I first downloaded it I thought that there was an option to enter a file or directory within the TUI to have it encrypted. So I do think that that would be kind of neat, if somehow TUI file-managers or some option to browse files within a directory or to pass a path to the program (within the TUI) and have the option to encrypt or sign the file/directory that is entered. This may be leaning more towards turning this into a file-manager if this is incorporated, although I don't necessarily think so. I think there could be some sort of configuration that would allow the user to provide a file manager that would only be used in selecting files to encrypt through gpg-tui. Incorporating fzf or something like it is also another option. Just any way to select files an encrypt them.

Once I finish this part real quick, having incorporated gpg-tui to my script, I can comment again to let you know, if you'd like to use something like it and modify it for the README.

Something simple is

function encrypt() { gpg -e -r $(gpg-tui --select key_id) "$@"; }

@lmburns
Copy link
Author

lmburns commented Jul 14, 2021

If trying to use gpg-tui with fzf, it doesn't work. Using another TUI program like lf, ranger, or lazygit all do work.

Edit: removed xplr, as it doesn't work.
I've noticed that some of the Rust TUI programs I have don't really work within fzf (e.g., xplr (loads, but freezes), gitui, btm (loads and displays movement, but no interaction) ) .

All of the Go programs do (e.g., lf, lazygit, lazydocker, glow).

The reproduce:

fzf --bind 'A:execute(gpg-tui (add any options here) )'

# This one messes up the terminal and it has to be restarted
fzf --bind 'A:execute(gpg-tui < /dev/tty > /dev/tty )'

@orhun
Copy link
Owner

orhun commented Jul 17, 2021

Well I'm using it on macOS, and I created a fairly long script that involves tagging files, and one of the options involves editing the file if it is gpg encrypted, and another options is to just simply encrypt or decrypt it. I am now trying to provide the user the ability to select the key to encrypt the file with if they have gpg-tui installed.

Very cool! Don't hesitate to tell me if you need anything about gpg-tui for that. I'm more than happy to help with it.

Another option that I would like to do is incorporate it with neomutt; however, I haven't looked too much into it and am not sure exactly how I could do that. neomutt will prompt the user which key to use when selecting an email, but getting it to use gpg-tui may be a different story. I only thought of this because I saw the comment on your reddit post on the newest release.

Got it. It seems like I still have to try out neomutt myself to find out how to integrate gpg-tui to it.

One feature that I think could be added, I mean it would obviously be dependent upon what you'd like this program to ultimately be, but whenever I first downloaded it I thought that there was an option to enter a file or directory within the TUI to have it encrypted. So I do think that that would be kind of neat, if somehow TUI file-managers or some option to browse files within a directory or to pass a path to the program (within the TUI) and have the option to encrypt or sign the file/directory that is entered.

This may be leaning more towards turning this into a file-manager if this is incorporated, although I don't necessarily think so. I think there could be some sort of configuration that would allow the user to provide a file manager that would only be used in selecting files to encrypt through gpg-tui. Incorporating fzf or something like it is also another option. Just any way to select files an encrypt them.

Yes, that's one of the core features that gpg itself provides: sign/encrypt files. Eventually I don't want gpg-tui to derail and become something else other than a simple program to manage GnuPG keys but it seems like sooner or later I'll be implementing most of the features that gpg provides. So maybe instead of just giving the filename/path to sign/encrypt to gpg-tui, I can make this happen via options menu and use the selected key for this operation. For example, selecting an entry in the options menu like sign a file using this key will launch xplr for file selection (or any other file browsing utility, preferably specified with #5) and afterwards sign the selected file. An application command for this scenario will be present so it will be also possible to do this with the default key, without launching a file manager. I created #28 for tracking.

Once I finish this part real quick, having incorporated gpg-tui to my script, I can comment again to let you know, if you'd like to use something like it and modify it for the README.

Something simple is

function encrypt() { gpg -e -r $(gpg-tui --select key_id) "$@"; }

Thanks! 2dcd41f

If trying to use gpg-tui with fzf, it doesn't work. Using another TUI program like lf, ranger, or lazygit all do work.

Edit: removed xplr, as it doesn't work.
I've noticed that some of the Rust TUI programs I have don't really work within fzf (e.g., xplr (loads, but freezes), gitui, btm (loads and displays movement, but no interaction) ) .

All of the Go programs do (e.g., lf, lazygit, lazydocker, glow).

The reproduce:

fzf --bind 'A:execute(gpg-tui (add any options here) )'

# This one messes up the terminal and it has to be restarted
fzf --bind 'A:execute(gpg-tui < /dev/tty > /dev/tty )'

I'm not sure I get your use case here but I tried the commands to reproduce and they both worked when I press A in fzf. Do you mind submitting a separate issue for this? I kinda want to investigate what's wrong.

@orhun
Copy link
Owner

orhun commented Jul 20, 2021

I think we're good to close this.

@orhun orhun closed this as completed Jul 20, 2021
@lmburns
Copy link
Author

lmburns commented Jul 20, 2021

Sorry for the late reply, I'm unsure as to why I'm not getting github email notifications. But awesome to the things you had said replying to my comment. I'm looking forward to the future of this project. I'm learning Rust now, so perhaps I'd be able to make some contributions.

Lastly, the fzf issue I was having does not work at all on my Mac. It could have something to do with iTerm on macOS maybe? I'll test it out in alacritty and see if it works. I may need to submit an issue to fzf and not here, because any Rust program that I use as a binding within fzf does not work; however, every single Go TUI program does work.

@orhun
Copy link
Owner

orhun commented Jul 20, 2021

Sorry for the late reply, I'm unsure as to why I'm not getting github email notifications. But awesome to the things you had said replying to my comment. I'm looking forward to the future of this project. I'm learning Rust now, so perhaps I'd be able to make some contributions.

No problem. Very good to hear!

Lastly, the fzf issue I was having does not work at all on my Mac. It could have something to do with iTerm on macOS maybe? I'll test it out in alacritty and see if it works. I may need to submit an issue to fzf and not here, because any Rust program that I use as a binding within fzf does not work; however, every single Go TUI program does work.

Alright. I'd be glad if you can share the issue link here (but you don't have to). I want to see "why" as well.

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

2 participants