Compare commits
	
		
			No commits in common. "17550da1fa10d24ed4a5048cd0069354799d557e" and "c21b7aa85d44912085735b4ae6cca91c81b57e54" have entirely different histories.
		
	
	
		
			17550da1fa
			...
			c21b7aa85d
		
	
		
							
								
								
									
										107
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										107
									
								
								README.md
									
									
									
									
									
								
							|  | @ -1,105 +1,2 @@ | ||||||
| # pass-reveal | # pass-backup | ||||||
| An extension for [pass](https://www.passwordstore.org/) (the standard Unix password manager) to easily find elements of the password store. | An extension for pass (the standard Unix password manager) to easily create backups of the password store | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| ## Motivation |  | ||||||
| 
 |  | ||||||
| `pass show` requires that one type in the full path of the service, but I am too lazy to do that. |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| ## Usage |  | ||||||
| 
 |  | ||||||
| ``` |  | ||||||
| Usage: |  | ||||||
| 
 |  | ||||||
|     pass reveal [reveallocation] |  | ||||||
|         On the first run it creates a directory ".reveals" in \$PASSWORD_STORE_DIR. |  | ||||||
|         By default this is ~/.password-store/.reveals". |  | ||||||
|         It creates a reveal of the complete password store by creating a |  | ||||||
|         compressed tar-file with extension .tar.bz2. |  | ||||||
|         reveals themselves are excluded from the reveal. |  | ||||||
|         Without argument the reveal file will receive the default name "passwordstore.DATE.TIME.tar.bz2" |  | ||||||
|         where DATE and TIME are the current date and time. |  | ||||||
|         If an argument is given and it is a directory, the reveal file will be placed |  | ||||||
|         into the specified directory instead of the default ".reveals" directory. |  | ||||||
|         If an argument is given and it is not a directory, it is used as a file |  | ||||||
|         name and the reveal is stored with this filename with .at.gz2 appended. |  | ||||||
|     pass reveal help |  | ||||||
|         Prints this help message. |  | ||||||
|     pass reveal version |  | ||||||
|         Prints the version number. |  | ||||||
| 
 |  | ||||||
| Usage: |  | ||||||
|     pass reveal [search-terms] |  | ||||||
|       Searches and displays passwords from \$PASSWORD_STORE_LOCATION. |  | ||||||
|           A simple wrapper over pass show, find, and grep. |  | ||||||
|           Based on the pass reveal extension. |  | ||||||
|     $PROGRAM reveal help |  | ||||||
|         Prints this help message. |  | ||||||
|     $PROGRAM reveal version |  | ||||||
|         Prints the version number. |  | ||||||
| 
 |  | ||||||
| Example: $PROGRAM reveal web |  | ||||||
|           Searches for any files in $PASSWORD_STORE_LOCATION whose filenames contain |  | ||||||
|           the keyword "web" |  | ||||||
| 
 |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| ## Example |  | ||||||
| Let's generate a password for this example |  | ||||||
| 
 |  | ||||||
| ``` |  | ||||||
| pass generate test/test |  | ||||||
| [master 1dd0d0b] Add generated password for test/test. |  | ||||||
|  1 file changed, 0 insertions(+), 0 deletions(-) |  | ||||||
|  rewrite test/test.gpg (100%) |  | ||||||
| The generated password for test/test is: |  | ||||||
| ]$OJ&<J18JSk!(Y4u:~n\`E3B |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| Then we can search with: |  | ||||||
| ``` |  | ||||||
| > pass reveal test |  | ||||||
| Best match: test/test |  | ||||||
| ]$OJ&<J18JSk!(Y4u:~n\`E3B |  | ||||||
| Copied test/test to clipboard. Will clear in 45 seconds. |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| ## Installation |  | ||||||
| 
 |  | ||||||
| For installation download and place this bash script file ```reveal.bash``` into |  | ||||||
| the passwordstore extension directory specified with ```$PASSWORD_STORE_EXTENSIONS_DIR```. |  | ||||||
| By default this is ```~/.password-store/.extensions```. |  | ||||||
| ``` |  | ||||||
| $ cp reveal.bash ~/.password-store/.extensions |  | ||||||
| ``` |  | ||||||
| Give the file execution permissions: |  | ||||||
| ``` |  | ||||||
| $ chmod 700 ~/.password-store/.extensions/reveal.bash |  | ||||||
| ``` |  | ||||||
| Set the variable ```PASSWORD_STORE_ENABLE_EXTENSIONS```, to true to enable extensions, e.g., in your `.bashrc` |  | ||||||
| ``` |  | ||||||
| $ export PASSWORD_STORE_ENABLE_EXTENSIONS=true |  | ||||||
| ``` |  | ||||||
| Download and source the bash completion file ```pass-reveal.bash.completion``` for bash completion. |  | ||||||
| ``` |  | ||||||
| $ source ~/.password-store/.bash-completions/pass-reveal.bash.completion |  | ||||||
| ``` |  | ||||||
| Type ```pass reveal keyword``` to make your first search. |  | ||||||
| ``` |  | ||||||
| $ pass reveal keyword |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| ## Requirements |  | ||||||
| 
 |  | ||||||
| - `pass` from [https://www.passwordstore.org/](https://www.passwordstore.org/) |  | ||||||
| - `tar` to be installed for zipping and compression. |  | ||||||
| 
 |  | ||||||
| ## License |  | ||||||
| This work is released under the [GNU GENERAL PUBLIC LICENSE](https://www.gnu.org/licenses/gpl-3.0.en.html). |  | ||||||
| 
 |  | ||||||
| ## Notes |  | ||||||
| 
 |  | ||||||
| Both files are tiny: 92 lines (script) and 17 lines (autocompletion)  respectively. You can check them yourself quickly. No need to trust anyone. |  | ||||||
| 
 |  | ||||||
| This extension is heavily based on the [pass-backup](https://github.com/8go/pass-backup) extension (archived [here](https://git.loki.red/open.source/pass-backup)). Because `pass-backup` is open source, it was easy to take its architecture and use it for a different purpose. |  | ||||||
|  |  | ||||||
|  | @ -1,17 +0,0 @@ | ||||||
| PASSWORD_STORE_EXTENSION_COMMANDS+=(reveal) |  | ||||||
| 
 |  | ||||||
| __password_store_extension_complete_reveal() { |  | ||||||
|   if [[ $COMP_CWORD -gt 2 ]]; then |  | ||||||
|     case "${COMP_WORDS[2]}" in |  | ||||||
|     help|--help|-h) |  | ||||||
|       _pass_complete_entries |  | ||||||
|       ;; |  | ||||||
|     version|--version|-v) |  | ||||||
|       _pass_complete_entries |  | ||||||
|       ;; |  | ||||||
|     esac |  | ||||||
|   else |  | ||||||
|       COMPREPLY+=($(compgen -W "help version -h --help -v --version" -- ${cur})) |  | ||||||
|       _pass_complete_entries 1 |  | ||||||
|   fi |  | ||||||
| } |  | ||||||
							
								
								
									
										92
									
								
								reveal.bash
									
									
									
									
									
								
							
							
						
						
									
										92
									
								
								reveal.bash
									
									
									
									
									
								
							|  | @ -1,92 +0,0 @@ | ||||||
| #!/usr/bin/env bash |  | ||||||
| # pass reveal - Password Store Extension (https://www.passwordstore.org/) |  | ||||||
| # Copyright (C) 2021 |  | ||||||
| # |  | ||||||
| #    This program is free software: you can redistribute it and/or modify |  | ||||||
| #    it under the terms of the GNU General Public License as published by |  | ||||||
| #    the Free Software Foundation, either version 3 of the License, or |  | ||||||
| #    (at your option) any later version. |  | ||||||
| # |  | ||||||
| #    This program is distributed in the hope that it will be useful, |  | ||||||
| #    but WITHOUT ANY WARRANTY; without even the implied warranty of |  | ||||||
| #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the |  | ||||||
| #    GNU General Public License for more details. |  | ||||||
| # |  | ||||||
| #    You should have received a copy of the GNU General Public License |  | ||||||
| #    along with this program.  If not, see <http://www.gnu.org/licenses/>. |  | ||||||
| # [] |  | ||||||
| 
 |  | ||||||
| VERSION="0.0.1" |  | ||||||
| PASSWORD_STORE_LOCATION="~/password-store" |  | ||||||
| 
 |  | ||||||
| cmd_reveal_usage() { |  | ||||||
|   cat <<-_EOF |  | ||||||
| Usage: |  | ||||||
|     $PROGRAM reveal [search-terms] |  | ||||||
|       Searches and displays passwords from \$PASSWORD_STORE_LOCATION. |  | ||||||
|           A simple wrapper over pass show, find, and grep. |  | ||||||
|           Based on the pass reveal extension. |  | ||||||
|     $PROGRAM reveal help |  | ||||||
|         Prints this help message. |  | ||||||
|     $PROGRAM reveal version |  | ||||||
|         Prints the version number. |  | ||||||
| 
 |  | ||||||
| Example: $PROGRAM reveal web |  | ||||||
|           Searches for any files in $PASSWORD_STORE_LOCATION whose filenames contain |  | ||||||
|           the keyword "web" |  | ||||||
| For installation place this bash script file "reveal.bash" into |  | ||||||
| the passwordstore extension directory specified with \$PASSWORD_STORE_EXTENSIONS_DIR. |  | ||||||
| By default this is ~/.password-store/.extensions. |  | ||||||
| E.g. cp reveal.bash ~/.password-store/.extensions |  | ||||||
| Give the file execution permissions: |  | ||||||
| E.g. chmod 700 ~/.password-store/.extensions/reveal.bash |  | ||||||
| Set the variable PASSWORD_STORE_ENABLE_EXTENSIONS to true to enable extensions. |  | ||||||
| E.g. export PASSWORD_STORE_ENABLE_EXTENSIONS=true |  | ||||||
| Source the bash completion file "pass-reveal.bash.completion" for bash completion. |  | ||||||
| E.g. source ~/.password-store/.bash-completions/pass-reveal.bash.completion |  | ||||||
| Type "pass reveal query" to make your first query |  | ||||||
| E.g. pass reveal query |  | ||||||
| _EOF |  | ||||||
|   exit 0 |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| cmd_reveal_version() { |  | ||||||
|   echo $VERSION |  | ||||||
|   exit 0 |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| cmd_reveal_reveal() { |  | ||||||
|   ## [[ $# -gt 1 ]] && die "Too many arguments. At most 1 argument allowed." |  | ||||||
| 
 |  | ||||||
|   # expect 0 or 1 argument |  | ||||||
|   # ignore 2nd argument and higher |  | ||||||
|   if [ $# -eq 0 ]; then |  | ||||||
|    echo "Error: Query is empty" |  | ||||||
|   else |  | ||||||
| 
 |  | ||||||
|     ARGS="$@" |  | ||||||
|     BEST_FIT="$(find ~/.password-store -type f -printf "%P\n" | grep -v '^\.'  | grep -i "$ARGS" | sed 's/.gpg//' | head -1)" |  | ||||||
|     if [ -z "$BEST_FIT" ]; then |  | ||||||
|     # $STRING is empty |  | ||||||
|       echo "No match found for $ARGS" |  | ||||||
|     else |  | ||||||
|       echo "Best match: $BEST_FIT" |  | ||||||
|       pass show "$BEST_FIT" |  | ||||||
| 			pass show -c "$BEST_FIT" |  | ||||||
|     fi |  | ||||||
| 
 |  | ||||||
|   fi |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| case "$1" in |  | ||||||
| help | --help | -h) |  | ||||||
|   shift |  | ||||||
|   cmd_reveal_usage "$@" |  | ||||||
|   ;; |  | ||||||
| version | --version | -v) |  | ||||||
|   shift |  | ||||||
|   cmd_reveal_version "$@" |  | ||||||
|   ;; |  | ||||||
| *) cmd_reveal_reveal "$@" ;; |  | ||||||
| esac |  | ||||||
| exit 0 |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user