[PATCH] Add a log subcommand

Herman van Rink helmo at initfour.nl
Tue Jun 28 12:39:11 UTC 2022


Hi,


I frequently use the Git history in a passwordstore.

But the current syntax is a bit cumbersome ... `pass git log 
pass/entry/foo.gpg`

With this patch we reduce that to `pass log pass/entry/foo` Especially 
the trailing '.gpg' annoyed me.

The bash completion seems to work, I've not tested the zsh and fish 
completion.

This code is also on https://github.com/helmo/password-store/tree/pass-log

---
  src/password-store.sh | 3 +++

  src/completion/pass.bash-completion | 4 ++++
  src/completion/pass.fish-completion | 1 +
  src/completion/pass.zsh-completion  | 4 ++++
   4 files changed, 12 insertions(+)


diff --git a/src/password-store.sh b/src/password-store.sh
index 22e818f..bc5dc07 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -306,6 +306,8 @@ cmd_usage() {
              Renames or moves old-path to new-path, optionally 
forcefully, selectively reencrypting.
          $PROGRAM cp [--force,-f] old-path new-path
              Copies old-path to new-path, optionally forcefully, 
selectively reencrypting.
+        $PROGRAM log pass-name
+            Show the Git history for pass-name.
          $PROGRAM git git-command-args...
              If the password store is a git repository, execute a git 
command
              specified by git-command-args.
@@ -715,6 +717,7 @@ case "$1" in
      delete|rm|remove) shift;    cmd_delete "$@" ;;
      rename|mv) shift;        cmd_copy_move "move" "$@" ;;
      copy|cp) shift;            cmd_copy_move "copy" "$@" ;;
+    log) shift;            cmd_git log "$@.gpg" ;;
      git) shift;            cmd_git "$@" ;;
      *)                cmd_extension_or_show "$@" ;;
  esac



diff --git a/src/completion/pass.bash-completion 
b/src/completion/pass.bash-completion
index 2d23cbf..2931db0 100644
--- a/src/completion/pass.bash-completion
+++ b/src/completion/pass.bash-completion
@@ -120,6 +120,10 @@ _pass()
                  COMPREPLY+=($(compgen -W "-r --recursive -f --force" 
-- ${cur}))
                  _pass_complete_entries
                  ;;
+            log|-*)
+                COMPREPLY+=($(compgen -W "" -- ${cur}))
+                _pass_complete_entries 1
+                ;;
              git)
                  COMPREPLY+=($(compgen -W "init push pull config log 
reflog rebase" -- ${cur}))
                  ;;
diff --git a/src/completion/pass.fish-completion 
b/src/completion/pass.fish-completion
index 0f57dd2..7745cd8 100644
--- a/src/completion/pass.fish-completion
+++ b/src/completion/pass.fish-completion
@@ -104,6 +104,7 @@ complete -c $PROG -f -n '__fish_pass_needs_command' 
-a "(__fish_pass_print_entri
  complete -c $PROG -f -n '__fish_pass_uses_command -c' -a 
"(__fish_pass_print_entries)"
  complete -c $PROG -f -n '__fish_pass_uses_command --clip' -a 
"(__fish_pass_print_entries)"

+complete -c $PROG -f -n '__fish_pass_needs_command' -a log -d 'Command: 
Show the Git history for pass-name.'
  complete -c $PROG -f -n '__fish_pass_needs_command' -a git -d 
'Command: execute a git command'
  complete -c $PROG -f -n '__fish_pass_uses_command git' -a 
'(__fish_pass_git_complete)'
  complete -c $PROG -f -n '__fish_pass_needs_command' -a find -d 
'Command: find a password file or directory matching pattern'
diff --git a/src/completion/pass.zsh-completion 
b/src/completion/pass.zsh-completion
index d911e12..77b2b35 100644
--- a/src/completion/pass.zsh-completion
+++ b/src/completion/pass.zsh-completion
@@ -72,6 +72,9 @@ _pass () {
                      "--recursive[recursively delete]"
                      _pass_complete_entries_with_subdirs
                  ;;
+            log)
+                    _pass_complete_entries_with_subdirs
+                ;;
              git)
                  local -a subcommands
                  subcommands=(
@@ -102,6 +105,7 @@ _pass () {
              "mv:Rename the password"
              "cp:Copy the password"
              "rm:Remove the password"
+            "log:Show the Git history for pass-name."
              "git:Call git on the password store"
              "version:Output version information"
              "help:Output help message"
-- 
2.30.2


-- 

Met vriendelijke groet / Regards,

Herman van Rink
Initfour websolutions



More information about the Password-Store mailing list