PASSWORD_STORE_DIR changed dynamically is not taken into account
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
.envrcfile 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 allowin 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
.envrcfile) - Launch tmux
- Launch tmux-pass
You should see the passwords from the first folder
- Open another terminal (direnv should load the
.envrcfile) - 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 ?
Hi again !
Is it something you'd consider looking at ?
Thanks in advance !
Hey @rafi ! Do you think you could spare some time looking at this :pray: ?
Thanks !
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}'\""