tmux-pass icon indicating copy to clipboard operation
tmux-pass copied to clipboard

PASSWORD_STORE_DIR changed dynamically is not taken into account

Open CaptainQuirk opened this issue 4 years ago • 3 comments

Hi !

I'm currently trying to have client related password stores and use direnv to achieve it in the shell (zsh). But if fails.

Environment

  • Linux Mint 20.2
  • Tmux 3.2a
  • Bash 5.0.17
  • zsh 5.8
  • direnv 2.28
  • pass 1.7.4
  • fzf 0.27.3

Prerequisites

  • Install direnv
  • Create two separate folders
  • create an .envrc file in each folder
  • Fill it with something like the following (where <my-path> is the absolute path to the folder)
export PASSWORD_STORE_DIR=<my-path>/.password-store
  • Run direnv allow in each folder to validate both files
  • Make sure no tmux session is running by executing tmux kill-server
  • Initialize a password store in each folder

Steps to reproduce

  • Open a new terminal in the first folder (direnv should load the .envrc file)
  • Launch tmux
  • Launch tmux-pass

You should see the passwords from the first folder

  • Open another terminal (direnv should load the .envrc file)
  • Launch tmux
  • Launch tmux-pass

Current behavior

The passwords from the first folder are shown while $(pwd) corresponds to the second folder

Expected behavior

The passwords should be the ones of the second folder

Suggestion

This can be solved by adding eval "$(direnv export bash)" at the top of the plugin's scripts/main.sh file but I realize that it is quite specific. In any case, the existence of the direnv binary should be checked before doing anything.

Would a simple hook system be a solution ?

CaptainQuirk avatar Oct 28 '21 23:10 CaptainQuirk

Hi again !

Is it something you'd consider looking at ?

Thanks in advance !

CaptainQuirk avatar Nov 04 '21 20:11 CaptainQuirk

Hey @rafi ! Do you think you could spare some time looking at this :pray: ?

Thanks !

CaptainQuirk avatar Nov 16 '21 10:11 CaptainQuirk

Hi, hope it's still relevant. I merged your PR, regardless, it all comes down to the key binding command, and the sub-shell it spawns. You could try re-mapping it yourself, e.g.:

tmux bind-key b run-shell "tmux split-window -l 10 \"eval \"$(direnv export bash)\" && /path/to/plugin/pass/scripts/main.sh '#{pane_id}'\""

rafi avatar Jul 31 '24 18:07 rafi