PATCH: fish-completion: don't print full path when PASSWORD_STORE_DIR is set

Johannes Altmanninger aclopte at gmail.com
Mon May 17 22:32:14 UTC 2021


>From 2a9a0a03e9c8d87b92a9f9d2cc93213c13fb3acd Mon Sep 17 00:00:00 2001
From: Johannes Altmanninger <aclopte at gmail.com>
Date: Tue, 18 May 2021 00:17:42 +0200
Subject: [PATCH] fish-completion: don't print full path when
 PASSWORD_STORE_DIR is set

"__fish_pass_print" enumerates all files in the password store and
strips the password store directory prefix from file paths using sed.
If $PASSWORD_STORE_DIR had a trailing slash, sed would fail to remove the
prefix. Sanitize PASSWORD_STORE_DIR by removing all trailing slashes.

---

On Mon, May 17, 2021 at 10:01:02PM +0100, Sam A. Horvath-Hunt wrote:
> Hey there!
> 
> I recently set $PASSWORD_STORE_DIR, and in doing so my fish completions
> have broken. I think this is the most appropriate place to report this?
> Specifically what happens is as follows:
> 
> $ pass show <tab>
> $ pass show path/to/password/store/dir/

This patch will fix this.
A workaround is to set $PASSWORD_STORE_DIR without a trailing slash.

 src/completion/pass.fish-completion | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/completion/pass.fish-completion b/src/completion/pass.fish-completion
index 3e70af1..eca62de 100644
--- a/src/completion/pass.fish-completion
+++ b/src/completion/pass.fish-completion
@@ -7,6 +7,7 @@ set -l PROG 'pass'
 
 function __fish_pass_get_prefix
     set -l prefix "$PASSWORD_STORE_DIR"
+    set prefix (string replace --regex -- '(^.+?)/*$' '$1' $prefix)
     if [ -z "$prefix" ]
         set prefix "$HOME/.password-store"
     end
-- 
2.31.1




More information about the Password-Store mailing list