use external editor for creating new entries
This commit is contained in:
parent
0d6f2882ed
commit
160e5d11df
@ -41,6 +41,11 @@ help_color=""
|
|||||||
# Possible options: primary, clipboard, both
|
# Possible options: primary, clipboard, both
|
||||||
clip=primary
|
clip=primary
|
||||||
|
|
||||||
|
# Options for generating new password entries
|
||||||
|
default_user=john_doe
|
||||||
|
default_user2=mary_ann
|
||||||
|
password_length=12
|
||||||
|
|
||||||
# Custom Keybindings
|
# Custom Keybindings
|
||||||
autotype="Alt+1"
|
autotype="Alt+1"
|
||||||
type_user="Alt+2"
|
type_user="Alt+2"
|
||||||
|
99
rofi-pass
99
rofi-pass
@ -385,97 +385,26 @@ manageEntry () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
insertPass () {
|
insertPass () {
|
||||||
if [[ -z "$pass" ]]; then
|
cd "${root}"
|
||||||
if [[ -n "$1" ]]; then
|
name="$(echo -e "$(list_passwords 2>/dev/null)" | rofi -dmenu -mesg "Type name, make sure it is unique" -p "> ")"
|
||||||
pass="$1"
|
val=$?
|
||||||
pass2="***"
|
if [[ $val -eq 1 ]]; then exit; fi
|
||||||
else
|
user=$(echo -e "${default_user2}\n$USER\n${default_user}" | rofi -dmenu -mesg "Chose Username or type" -p "> ")
|
||||||
pass2="Empty"
|
val=$?
|
||||||
fi
|
if [[ $val -eq 1 ]]; then exit; fi
|
||||||
fi
|
group=$(echo -e "No Group\n---\n$(find -type d -not -iwholename '*.git*' -printf '%d\t%P\n' | sort -r -nk1 | cut -f2-)" | rofi -dmenu -p "Choose Group > ")
|
||||||
if [[ -z "$user" ]]; then user="Empty"; fi
|
val=$?
|
||||||
if [[ -z "$domain" ]]; then domain="Empty"; fi
|
if [[ $val -eq 1 ]]; then exit; fi
|
||||||
if [[ -z "$name" ]]; then name="Empty"; fi
|
|
||||||
|
|
||||||
insertmenu=$(echo -e "0 Return to Main Menu\n* Accept Values and Add Password Entry\n---\n1 Name ($name)\n2 URL ($domain)\n3 User ($user)\n4 Password ($pass2)" | _rofi -dmenu -mesg "<span color='$help_color'>For faster adding use the addpass command</span>" -p "Add Entry > ")
|
|
||||||
insert_val=$?
|
|
||||||
if [[ $insert_val -eq 1 ]]; then exit
|
|
||||||
else
|
|
||||||
if [[ $insertmenu == "0 Return to Main Menu" ]]; then mainMenu
|
|
||||||
elif [[ $insertmenu == "" ]]; then exit
|
|
||||||
elif [[ $insertmenu == "* Accept Values and Add Password Entry" ]]; then
|
|
||||||
cd "${root}" || exit
|
|
||||||
group=$(echo -e "No Group\n---\n$(find -type d -not -iwholename '*.git*' -printf '%d\t%P\n' | sort -r -nk1 | cut -f2-)" | _rofi -dmenu -p "Choose Group > ")
|
|
||||||
if [[ "$group" == "No Group" ]]; then
|
if [[ "$group" == "No Group" ]]; then
|
||||||
PASSWORD_STORE_DIR="${root}" pass insert -m -f "${name}" < <(echo -e "${pass}\n${USERNAME_field}: ${user}\n---\n${URL_field}: ${domain}")
|
echo $EDITOR
|
||||||
elif [[ "$group" == "" ]]; then
|
echo -e "PASS\n---\nuser: $user" | pass insert -m "${name}" > /dev/null && pass generate -ni "${name}" "${password_length}" >/dev/null && pass edit "${name}"
|
||||||
exit
|
|
||||||
else
|
else
|
||||||
PASSWORD_STORE_DIR="${root}" pass insert -m -f "${group}/${name}" < <(echo -e "${pass}\nU${USERNAME_field}: ${user}\n---\n${URL_field}: ${domain}")
|
echo $EDITOR
|
||||||
fi
|
echo -e "PASS\n---\nuser: $user" | pass insert -m "${group}/${name}" > /dev/null && pass generate -ni "${group}/${name}" "${password_length}" >/dev/null && pass edit "${group}/${name}"
|
||||||
exit
|
|
||||||
elif [[ $insertmenu == "1 Name"* ]]; then
|
|
||||||
name=$(echo "" | _rofi -dmenu -p "Enter Name > ")
|
|
||||||
insertPass
|
|
||||||
|
|
||||||
elif [[ $insertmenu == "2 URL"* ]]; then
|
|
||||||
HELP="<span color='$help_color'>Enter Domain Name</span>"
|
|
||||||
domain=$(echo -e "< Return" | _rofi -dmenu -mesg "${HELP}" -p "URL > ")
|
|
||||||
if [[ $domain == "< Return" ]]; then
|
|
||||||
insertPass
|
|
||||||
elif [[ $domain == "" ]]; then
|
|
||||||
exit
|
|
||||||
else
|
|
||||||
insertPass
|
|
||||||
fi
|
|
||||||
elif [[ $insertmenu == "3 User"* ]]; then
|
|
||||||
HELP="<span color='$help_color'>Enter Username</span>"
|
|
||||||
user=$(echo -e "" | _rofi -dmenu -mesg "${HELP}" -p "Username > ")
|
|
||||||
insertPass
|
|
||||||
elif [[ $insertmenu == "4 Password"* ]]; then
|
|
||||||
password_length=12
|
|
||||||
symbols="False"
|
|
||||||
numerals="True"
|
|
||||||
capitals="True"
|
|
||||||
password_gen
|
|
||||||
else
|
|
||||||
insertPass
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
password_gen () {
|
|
||||||
if [[ $capitals == "True" ]]; then cap="-c"; else cap="-A"; fi
|
|
||||||
if [[ $symbols == "True" ]]; then sym="-y"; else sym=""; fi
|
|
||||||
if [[ $numerals == "True" ]]; then num="-n"; else num="-0"; fi
|
|
||||||
HELP="<span color='$help_color'>Choose one password or type your own</span>"
|
|
||||||
menu=$(echo -e "0 Return to Insert Menu\n* Generate new Password\n---\n1 Password Length\n2 Include Capitals ($capitals)\n3 Include Numerals ($numerals)\n4 Include Symbols ($symbols)\n---\n$(pwgen $num $cap $sym -B -1 $password_length 5)" | _rofi -dmenu -mesg "${HELP}" -p "Password > ")
|
|
||||||
|
|
||||||
if [[ $menu == "1 Password Length" ]]; then
|
|
||||||
password_length=$(echo -e "5\n7\n10\n12\n15\n20" | _rofi -dmenu -p "Choose Length > ")
|
|
||||||
password_gen
|
|
||||||
elif [[ $menu == "0 Return to Insert Menu" ]]; then
|
|
||||||
insertPass
|
|
||||||
elif [[ $menu == "* Generate new Password" ]]; then
|
|
||||||
password_gen
|
|
||||||
elif [[ $menu == "2 Include Capitals"* ]]; then
|
|
||||||
capitals=$(echo -e "True\nFalse" | _rofi -dmenu -p "Capitals? > ")
|
|
||||||
password_gen
|
|
||||||
elif [[ $menu == "3 Include Numerals"* ]]; then
|
|
||||||
numerals=$(echo -e "True\nFalse" | _rofi -dmenu -p "Numerals? > ")
|
|
||||||
password_gen
|
|
||||||
elif [[ $menu == "4 Include Symbols"* ]]; then
|
|
||||||
symbols=$(echo -e "True\nFalse" | _rofi -dmenu -p "Symbols? > ")
|
|
||||||
password_gen
|
|
||||||
else
|
|
||||||
insertPass "$menu"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#function _rofi () {
|
|
||||||
# rofi -dmenu -z ${rofiopts} "$@"
|
|
||||||
#}
|
|
||||||
|
|
||||||
help_msg () {
|
help_msg () {
|
||||||
echo "rofi-pass (Version: 1.2)"
|
echo "rofi-pass (Version: 1.2)"
|
||||||
echo ""
|
echo ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user