[PATCH] Add support for mingw/git shell in Windows

Cameron Cross cameroncros at gmail.com
Tue May 28 00:14:25 CEST 2019


Hello All,

I have added support for using pass on a Windows machine from git bash/mingw.
The only changes are to use the CLIP.EXE command for clipboard, and
TREE.com for generating the directory list.
Unfortunately, the tree.com output looks kinda terrible after putting
it through grep, but I don't know a way around that.

---

diff --git a/src/password-store.sh b/src/password-store.sh
index b746101..683d711 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -152,7 +152,11 @@ check_sneaky_paths() {
 #

 clip() {
-       if [[ -n $WAYLAND_DISPLAY ]]; then
+       if [[ ! -z "$(which CLIP)" ]]; then
+               # Windows CLIP.exe detected.
+               local copy_cmd=( CLIP )
+               local paste_cmd=( )
+       elif [[ -n $WAYLAND_DISPLAY ]]; then
                local copy_cmd=( wl-copy )
                local paste_cmd=( wl-paste -n )
                if [[ $X_SELECTION == primary ]]; then

---

diff --git a/src/password-store.sh b/src/password-store.sh
index c6abf47..683d711 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -403,7 +403,12 @@ cmd_show() {
                else
                        echo "${path%\/}"
                fi
-               tree -C -l --noreport "$PREFIX/$path" | tail -n +2 |
sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of
line, but keep colors
+               if [[ ! -z $(which tree.com) ]]; then
+                       win_path=$(echo $PREFIX/$path | sed -e
's/^\///' -e 's/\//\\/g' -e 's/^./\0:/' -e 's/\\$//')
+                       tree.com "$win_path" "//F"  | tail -n +4 |
grep -a -v " \." | sed -E 's/.gpg//g'
+               else
+                       tree -C -l --noreport "$PREFIX/$path" | tail
-n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg
at end of line, but keep colors
+               fi
        elif [[ -z $path ]]; then
                die "Error: password store is empty. Try \"pass init\"."
        else


More information about the Password-Store mailing list