Add blackbox_less. (#263)

* Add blackbox_view and use PAGER (default to less)
This commit is contained in:
winter0mute
2018-07-26 16:24:32 +02:00
committed by Tom Limoncelli
parent ebaa22a981
commit 74de17a4f6
2 changed files with 21 additions and 0 deletions

View File

@@ -99,6 +99,7 @@ Commands
| `blackbox_edit_start <file>` | Decrypt a file so it can be updated |
| `blackbox_edit_end <file>` | Encrypt a file after blackbox_edit_start was used |
| `blackbox_cat <file>` | Decrypt and view the contents of a file |
| `blackbox_view <file>` | Like blackbox_cat but pipes to `less` or $PAGER |
| `blackbox_diff` | Diff decrypted files against their original crypted version |
| `blackbox_initialize` | Enable blackbox for a GIT or HG repo |
| `blackbox_register_new_file <file>` | Encrypt a file for the first time |

20
bin/blackbox_view Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
#
# blackbox_view -- Decrypt a file, view it, shred it
#
set -e
source "${0%/*}/_blackbox_common.sh"
for param in "$@" ; do
shreddable=0
unencrypted_file=$(get_unencrypted_filename "$param")
if [[ ! -e "$unencrypted_file" ]]; then
"${BLACKBOX_HOME}/blackbox_edit_start" "$param"
shreddable=1
fi
${PAGER:-less} "$unencrypted_file"
if [[ $shreddable = 1 ]]; then
shred_file "$unencrypted_file"
fi
done