diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2014-04-25 02:38:11 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2014-04-25 02:38:11 +0200 |
commit | 366f3d4c7cd7125a89b1a049b91a7dd9ab52ec6b (patch) | |
tree | d571178cf6a305f6b714e9c70f6f192ef36333c9 /src/password-store.sh | |
parent | tests: remember to escape $ (diff) | |
download | password-store-366f3d4c7cd7125a89b1a049b91a7dd9ab52ec6b.tar.xz password-store-366f3d4c7cd7125a89b1a049b91a7dd9ab52ec6b.zip |
Pipe everything to a pager.
Diffstat (limited to 'src/password-store.sh')
-rwxr-xr-x | src/password-store.sh | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/password-store.sh b/src/password-store.sh index d7f5eb0..6233a00 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -18,6 +18,12 @@ CLIP_TIME="${PASSWORD_STORE_CLIP_TIME:-45}" export GIT_DIR="${PASSWORD_STORE_GIT:-$PREFIX}/.git" export GIT_WORK_TREE="${PASSWORD_STORE_GIT:-$PREFIX}" +export LESS="${PASSWORD_STORE_LESS:-FRSXMK}" +PAGER="${PAGER:-pager}" +which "$PAGER" &>/dev/null || PAGER="less" +which "$PAGER" &>/dev/null || PAGER="more" +which "$PAGER" &>/dev/null || PAGER="cat" + # # BEGIN helper functions # @@ -313,12 +319,14 @@ cmd_show() { clip "$pass" "$path" fi elif [[ -d $PREFIX/$path ]]; then + { if [[ -z $path ]]; then echo "Password Store" else echo "${path%\/}" fi tree -C -l --noreport "$PREFIX/$path" | tail -n +2 | sed 's/\.gpg$//' + } | "$PAGER" elif [[ -z $path ]]; then die "Error: password store is empty. Try \"pass init\"." else @@ -328,9 +336,11 @@ cmd_show() { cmd_find() { [[ -z "$@" ]] && die "Usage: $PROGRAM $COMMAND pass-names..." + { IFS="," eval 'echo "Search Terms: $*"' local terms="*$(printf '%s*|*' "$@")" tree -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" | tail -n +2 | sed 's/\.gpg$//' + } | "$PAGER" } cmd_grep() { @@ -346,7 +356,7 @@ cmd_grep() { passfile="${passfile##*/}" printf "\e[94m%s/\e[1m%s\e[0m:\n" "$passfile_dir" "$passfile" echo "$grepresults" - done < <(find "$PREFIX" -iname '*.gpg' -print0) + done < <(find "$PREFIX" -iname '*.gpg' -print0) | "$PAGER" } cmd_insert() { |