You can run the script pw_command.py
to manage your passwords in the command line. See the explanation
for the commands below. Here is what this tool can do:
- Copy secrets such as passwords from a json file into your clipboard
- Generate a random passwords with or without special characters
- Save, update and delete secrets
pw <entity>
-> Get the password of<entity>
from the section mainpw -as
-> Print all sectionspw -s <section>
-> Print all available entities of<section>
pw -s <section> <entity>
-> Get the password of<entity>
from<section>
pw -r
-> Generate a random password with 42 characters, print it and copy it to the clipboardpw -rn
-> Generate a random password without special characterspw -rl 20
-> Generate a random password with 20 characterspw -rl 20 -rn
-> Generate a random password with 20 characters and without special characterspw -n <name>
-> Add a new randomly created password to the creds.json file for the entity<name>
pw -n <entity> -w <website> -u <username>
-> Create a new password with information on the website and the usernamepw -rm <entity>
-> Remove the password for<entity>
from the section mainpw -rm <entity> -s <section>
-> Remove the password for<entity>
from<section>
pw -rms <section>
-> Remove the section<section>
Make sure pytest
is installed, then:
pwd # make sure you are at root of repo
pytest -c pytest.ini tests/
"section": {
"key": {
"password": "lorem",
"username": "ipsum",
"website": "www.website.swiss"
"additional_info": "..."
}
},
"main": {
"GitHub": {
"password": "lorem",
"username": "ipsum",
"website": "www.GitHub.com"
"additional_info": "..."
},
"netlify": {
"password": "lorem",
"username": "ipsum",
"website": "www.netlify.com"
"additional_info": "..."
}
, ...
}
I create a symlink to the python script pw_command.py
(command 3). The name of this symlink is just "pw".
The symlink needs execution permissions (command 4). The symlink needs to be in a folder that is listed
in the PATH (command 2). In my case, that's the folder .bin
which exists in my home directory (command 1).
mkdir ~/.bin/ && cd ~/.bin/
Create the folder.bin
in your homedir ($HOME
)echo "export PATH=\$PATH:\$HOME/xyz" >> $HOME/.zshrc
-> Add the newly created directory to your$PATH
ln -s ~/dev/python_pw_cli/src/pw_command.py pw
-> Create the symlinkpw
to the scriptchmod 744 pw
-> Change file permissions so that the script becomes executable
Furthermore, you need to assure two things:
- Update line 1 of
/src/pw_command.py
by specifying your path to Python3 (find out withwhich python3
) - Create a passwords.json somewhere and pass the path to the variables in
/src/pw/pw_config.py
accordingly