diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-30 12:20:21 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-30 12:20:21 +0100 |
commit | 5ffa294906a686f2a90410dbf76dd8a756278a74 (patch) | |
tree | d54a1c88a300445b63a273bd0b442644f97d4d26 | |
parent | 97b10cdc528d9f6954dc9ecf4511b089495d6b6f (diff) |
improve `pass duplicates` and `rofi-pass` matching
-rw-r--r-- | .config/rofi-pass/rofi.rasi | 4 | ||||
-rwxr-xr-x | .local/share/pass-extensions/duplicates.bash | 2 | ||||
-rwxr-xr-x | .local/share/pass-extensions/names.bash | 47 |
3 files changed, 43 insertions, 10 deletions
diff --git a/.config/rofi-pass/rofi.rasi b/.config/rofi-pass/rofi.rasi index 87528bd..829bcb0 100644 --- a/.config/rofi-pass/rofi.rasi +++ b/.config/rofi-pass/rofi.rasi @@ -2,6 +2,10 @@ // (see section on 'Multiple file handling' in man rofi-theme(5)) @import "config.rasi" +configuration { + matching: "prefix"; +} + listview { lines: 12; } diff --git a/.local/share/pass-extensions/duplicates.bash b/.local/share/pass-extensions/duplicates.bash index b7e57a4..cb1cbbc 100755 --- a/.local/share/pass-extensions/duplicates.bash +++ b/.local/share/pass-extensions/duplicates.bash @@ -1,7 +1,7 @@ #!/bin/bash declare -A dupe_tally dupe_map -pass_names="$(pass names)" +pass_names="$(pass names -l)" [ $? -ne 0 ] && exit 1 pass_count="$(echo "$pass_names" | wc -l)" diff --git a/.local/share/pass-extensions/names.bash b/.local/share/pass-extensions/names.bash index e96548f..aa42ebf 100755 --- a/.local/share/pass-extensions/names.bash +++ b/.local/share/pass-extensions/names.bash @@ -5,13 +5,42 @@ pass_dir="$(pass directory)" [ $? -ne 0 ] && exit 1 cd "$pass_dir" -# List all files in password store (ignoring .git and .extensions folders) and -# trim './' prefix and '.gpg' suffix -find -L . \ - -type d -name '.git' -prune \ - -o -type d -name '.extensions' -prune \ - -o -name '*.gpg' \ - -type f \ - -print |\ -cut -c3- | rev | cut -c5- | rev +usage() { + cat << EOF +usage: + pass names [-hl] + +options: + -l ignore symbolic links in password store + -h show this help +EOF + exit $1 +} + +ARGC=0 +while getopts lh OPT; do + [ $OPTIND -gt $ARGC ] && ARGC=$OPTIND + case $OPT in + l) + opt_ignore_symlinks=y + ;; + h) usage 0 ;; + \?|*) usage 1 ;; + esac +done + +find_args=() + +if [ -n "$opt_ignore_symlinks" ] ; then + find_args+=(-P) # ignore symbolic links +else + find_args+=(-L) # follow symbolic links +fi +find_args+=(.) +find_args+=(-type d -name .git -prune) # skip .git directory +find_args+=(-o -type d -name .extensions -prune) # skip .extensions directory +find_args+=(-o -type f -name '*.gpg') # only .gpg files +find_args+=(-print) + +find "${find_args[@]}" | cut -c3- | rev | cut -c5- | rev |