diff options
| -rwxr-xr-x | angou | 14 | ||||
| -rw-r--r-- | contrib/autocomplete.ksh | 2 |
2 files changed, 12 insertions, 4 deletions
| @@ -25,11 +25,18 @@ view() { | |||
| 25 | fi | 25 | fi |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | # view the first line | ||
| 29 | view_single() { | ||
| 30 | [ ! -f $1 ] && usage && exit | ||
| 31 | |||
| 32 | view "$1" | sed 1q | tr -d \\n | ||
| 33 | } | ||
| 34 | |||
| 28 | # copy the first line from view to clipboard | 35 | # copy the first line from view to clipboard |
| 29 | copy() { | 36 | copy() { |
| 30 | [ ! -f $1 ] && usage && exit | 37 | [ ! -f $1 ] && usage && exit |
| 31 | 38 | ||
| 32 | view "$1" | sed 1q | $ANGOU_CLIPBOARD | 39 | view_single "$1" | $ANGOU_CLIPBOARD |
| 33 | } | 40 | } |
| 34 | 41 | ||
| 35 | # create new or existing password in ANGOU_DIR | 42 | # create new or existing password in ANGOU_DIR |
| @@ -46,7 +53,7 @@ edit() { | |||
| 46 | # edit a copy of a password if it already exists | 53 | # edit a copy of a password if it already exists |
| 47 | [ -f "$1" ] && $ANGOU_DECRYPT "$1" > "$tmpfile" | 54 | [ -f "$1" ] && $ANGOU_DECRYPT "$1" > "$tmpfile" |
| 48 | 55 | ||
| 49 | "${VISUAL:-${EDITOR:-ed}}" "$tmpfile" | 56 | ${VISUAL:-${EDITOR:-ed}} "$tmpfile" |
| 50 | 57 | ||
| 51 | mkdir -p "$(dirname "$1")" | 58 | mkdir -p "$(dirname "$1")" |
| 52 | $ANGOU_ENCRYPT "$tmpfile" >"$1" | 59 | $ANGOU_ENCRYPT "$tmpfile" >"$1" |
| @@ -54,7 +61,7 @@ edit() { | |||
| 54 | 61 | ||
| 55 | # print usage | 62 | # print usage |
| 56 | usage() { | 63 | usage() { |
| 57 | printf "Usage: %s [help|copy|edit|generate|view [file or directory]]\n" "$0" | 64 | printf "Usage: %s [help|copy|edit|generate|view|view_single [file or directory]]\n" "$0" |
| 58 | printf "\tThe edit and copy command expects a file as an argument,\n" | 65 | printf "\tThe edit and copy command expects a file as an argument,\n" |
| 59 | printf "\twhile the view command expects a directory as an argument.\n" | 66 | printf "\twhile the view command expects a directory as an argument.\n" |
| 60 | printf "\tThe arguments for view and edit are relative to\n" | 67 | printf "\tThe arguments for view and edit are relative to\n" |
| @@ -71,5 +78,6 @@ case "$option" in | |||
| 71 | edit) edit "$2" ;; | 78 | edit) edit "$2" ;; |
| 72 | generate) edit "$2" generate ;; | 79 | generate) edit "$2" generate ;; |
| 73 | view) view "$2" ;; | 80 | view) view "$2" ;; |
| 81 | pass) view_single "$2" ;; | ||
| 74 | *) view "$1" ;; | 82 | *) view "$1" ;; |
| 75 | esac | 83 | esac |
diff --git a/contrib/autocomplete.ksh b/contrib/autocomplete.ksh index ff5b15c..5c91ad8 100644 --- a/contrib/autocomplete.ksh +++ b/contrib/autocomplete.ksh | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #!/bin/ksh | 1 | #!/bin/ksh |
| 2 | set -A complete_angou_1 -- help copy edit view generate | 2 | set -A complete_angou_1 -- help copy edit view pass generate |
| 3 | set -A complete_angou_2 -- $(find ${ANGOU_DIR:-~/.angou} -type f | sort \ | 3 | set -A complete_angou_2 -- $(find ${ANGOU_DIR:-~/.angou} -type f | sort \ |
| 4 | | sed s,${ANGOU_DIR}/,, | sed s,\\.gpg$,,) | 4 | | sed s,${ANGOU_DIR}/,, | sed s,\\.gpg$,,) |
