summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Gerstner <Matthias.Gerstner at nefkom.net>2025-05-22 15:11:39 +0300
committerc4llv07e <igor@c4llv07e.xyz>2025-05-22 15:11:39 +0300
commitdc18f3ac43d930ff2a9a57ec7d266fbc1e36016f (patch)
treefa1a76a19fc9be5f178efeb5aa83b149fbfeabfe /src
parente07a3166db10c69af3d087803733efab407bcd92 (diff)
downloadneopass-master.tar.gz
neopass-master.tar.bz2
neopass-master.zip
Currently something like `pass ls | cat` will still produce color escapeHEADmaster
sequences. This is problematic when trying to parse the output, or otherwise storing the output in a file etc.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/password-store.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/password-store.sh b/src/password-store.sh
index 22e818f..dcf7d47 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -19,6 +19,7 @@ CLIP_TIME="${PASSWORD_STORE_CLIP_TIME:-45}"
GENERATED_LENGTH="${PASSWORD_STORE_GENERATED_LENGTH:-25}"
CHARACTER_SET="${PASSWORD_STORE_CHARACTER_SET:-[:punct:][:alnum:]}"
CHARACTER_SET_NO_SYMBOLS="${PASSWORD_STORE_CHARACTER_SET_NO_SYMBOLS:-[:alnum:]}"
+[[ -t 1 ]] && TREE_COLORIZE="-C"
unset GIT_DIR GIT_WORK_TREE GIT_NAMESPACE GIT_INDEX_FILE GIT_INDEX_VERSION GIT_OBJECT_DIRECTORY GIT_COMMON_DIR
export GIT_CEILING_DIRECTORIES="$PREFIX/.."
@@ -402,7 +403,7 @@ cmd_show() {
else
echo "${path%\/}"
fi
- tree -N -C -l --noreport "$PREFIX/$path" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of line, but keep colors
+ tree -N $TREE_COLORIZE -l --noreport "$PREFIX/$path" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of line, but keep colors
elif [[ -z $path ]]; then
die "Error: password store is empty. Try \"pass init\"."
else
@@ -414,7 +415,7 @@ cmd_find() {
[[ $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND pass-names..."
IFS="," eval 'echo "Search Terms: $*"'
local terms="*$(printf '%s*|*' "$@")"
- tree -N -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g'
+ tree -N $TREE_COLORIZE -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g'
}
cmd_grep() {