7 .
/usr
/lib
/tool
/bash-utils
11 local i stack_size
=${#FUNCNAME[@]}
12 for (( i
=1; i
<stack_size
; i
++ )); do
13 local func
="${FUNCNAME[$i]}"
14 [[ $func = "" ]] && func
=MAIN
15 local linen
="${BASH_LINENO[$(( i - 1 ))]}"
16 local src
="${BASH_SOURCE[$i]}"
17 [[ "$src" = "" ]] && src
=non_file_source
19 echo " function: $func"
20 echo " file: $src (line $linen)"
21 nl -ba -w ${#linen} -s ' | ' "$src" |
grep -C 2 -E "^\s*$linen " | prefixlines
' ' |
sed -e "s/^\(\s*$linen .*\)/\x1B[1m\1\x1B[0m/"
25 trap 'print_traceback >&2' ERR
35 site
=${1:?'enter site name!'}
41 GLOBIGNORE
=${GLOBIGNORE:-}${GLOBIGNORE:+:}".:..:.[!/.]*:..[!/]*:-*"
49 if [[ $file =~ password|key|cvc|secret|pin
]]
51 if in_list reveal-secrets
"${options[@]}"
54 elif in_list hash-secrets
"${options[@]}"
56 echo "$file"$
'\t'MD5
=`cat "$file" | md5sum | cut -c 1-32`
59 echo "$file"$
'\t'"*****"
64 grep .
"$file" | prefixlines
"$file"$
'\t'
71 cred dump
"$parent" "${options[@]}"
76 site
=${1:?'enter site name!'}
77 cat "$basedir/$site/PASSWORD"
80 site
=${1:?'enter site name!'}
81 cat "$basedir/$site/PASSWORD" | xclip
-i -selection clipboard
84 find -L "$basedir" -path "$basedir/${1:-}*" -type d
-printf "%P\n"
87 site
=${1:?'enter site name and property name!'}
89 prop
=${1:?'enter property name!'}
93 cat "$basedir/$site/$prop"
99 mkdir
-p "$basedir/$site"
100 echo "$val" > "$basedir/$site/$prop"
103 mkdir
-p "$basedir/$site"
104 "${EDITOR:-$VISUAL}" "$basedir/$site/$prop"
107 rm "$basedir/$site/$prop"
116 site
=${1:?'enter site name, property name and value!'}
117 find "$basedir/$site" -type f
-printf "%P\n"
120 site
=${1:?'enter site name!'}
121 newpwd
=$
(pwgen
-y 8 1)$
(pwgen
-y 8 1)
122 pwdfile
=$basedir/$site/PASSWORD
123 mkdir
-p "$basedir/$site"
126 cur_pwd
=`cat "$pwdfile"`
127 atime
=`stat -c %x "$pwdfile"`
128 now
=`date +'%F %T.%N %z'`
129 echo "$atime $now $cur_pwd" >> "$basedir/$site/OLDPASSWORDS"
131 printf '%s' "$newpwd" > "$pwdfile"
135 _autocomplete_cred() {
137 local curr_word=${COMP_WORDS[$COMP_CWORD]}
138 local prev_word=${COMP_WORDS[$[COMP_CWORD - 1]]}
139 if [ $COMP_CWORD = 1 ]
141 compreply="list-sites dump dump-with-secrets password clip-password pwgen help compscript prop list-props"
142 elif [ $COMP_CWORD = 2 ]
144 compreply=`cred list-sites "$curr_word"`
146 case "${COMP_WORDS[1]}" in
150 site=${COMP_WORDS[2]}
151 compreply=`cred list-props "$site"`
154 compreply="set edit del"
161 compreply="reveal-secrets mask-secrets hash-secrets"
166 COMPREPLY=($(compgen -W "$compreply" -- "${COMP_WORDS[$COMP_CWORD]}"))
169 complete -F _autocomplete_cred cred
170 # use this in your bash session by eg: eval "$(cred compscript)"
175 echo 'Use tab-completion!'
177 echo 'eval "$(cred compscript)"'