Created
November 12, 2013 11:46
-
-
Save ivyl/7429582 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -ue | |
if ! command -v xdotool &> /dev/null; then | |
printf "You need to install xdotool.\n" 1>&2 | |
exit 1 | |
fi | |
output="$(pass $@)" | |
exit_code="$?" | |
if [[ "$exit_code" -gt 0 ]]; then | |
exit "$exit_code" | |
fi | |
password="$(printf "%s" "$output" | head -n 1)" | |
username="$(printf "%s" "$output" | grep '^username: ' | cut -c 11-)" | |
active_window_id="$(xdotool getactivewindow)" | |
if [[ -n "$password" ]]; then | |
if [[ -n "$username" ]]; then | |
xdotool type --window "$active_window_id" "$username" | |
xdotool key --window "$active_window_id" "Tab" | |
xdotool type --window "$active_window_id" "i" | |
fi | |
xdotool type --window "$active_window_id" "$password" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment