From 1183381eb6b70c0b0dbd192a8607b985e976e156 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 5 Dec 2016 23:22:07 -0800 Subject: [PATCH 1/6] [git] Clean up whitespace in config --- dotfiles/gitconfig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dotfiles/gitconfig b/dotfiles/gitconfig index 184fe3b6..2b3316a1 100644 --- a/dotfiles/gitconfig +++ b/dotfiles/gitconfig @@ -23,14 +23,14 @@ ffr = "!ffr() { git fetch $1 && git ff $1/$(git which-branch) && git suir; }; ffr" file-exists = "!f() { git ls-files $1 --error-unmatch > /dev/null 2> /dev/null; }; f" force-master = "!f() { git fetch origin && git rh && git master; }; f" - icd = "!d() { git difftool --no-prompt --extcmd 'icdiff --cols=200' $@ | $(git config --get core.pager); }; d" + icd = "!d() { git difftool --no-prompt --extcmd 'icdiff --cols=200' $@ | $(git config --get core.pager); }; d" icdl = "!d() { git difftool --no-prompt --extcmd 'icdiff --line-numbers --cols=200' $@ | $(git config --get core.pager); }; d" ignore = "!i() { printf \"\n$1\" >> "`git root`/.gitignore"; }; i" ignore-untracked="!git untracked | xargs -n1 git ignore" l = log --pretty=oneline --graph master = checkout origin/master -B master modified = diff HEAD --name-only - poh = push origin HEAD + poh = push origin HEAD pohm = push origin HEAD:master power-clean = clean -ffd reb = "!r() { git rebase -i HEAD~$1; }; r" # Interactive rebase with the given number of latest commits @@ -74,10 +74,10 @@ added = green changed = yellow untracked = red - + [merge] conflictstyle = diff3 - + [include] path = ~/.gitconfig.custom path = ~/.gitconfig.this-machine @@ -92,4 +92,4 @@ insteadOf = https://code.uber.internal/ [branch] - autosetuprebase = always \ No newline at end of file + autosetuprebase = always From ea283b3c9367a4d0dd8a1c24ceaedbf777004b7d Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Wed, 7 Dec 2016 13:47:31 -0800 Subject: [PATCH 2/6] [Linux] Rename system_password to type_system_password --- dotfiles/lib/bin/{system_password.sh => type_system_password.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename dotfiles/lib/bin/{system_password.sh => type_system_password.sh} (100%) diff --git a/dotfiles/lib/bin/system_password.sh b/dotfiles/lib/bin/type_system_password.sh similarity index 100% rename from dotfiles/lib/bin/system_password.sh rename to dotfiles/lib/bin/type_system_password.sh From cd21eb25ddced6e0781e902fde47b4de49b2adad Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Wed, 7 Dec 2016 13:47:58 -0800 Subject: [PATCH 3/6] [Linux] Fixup type_system_password --- dotfiles/lib/bin/type_system_password.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dotfiles/lib/bin/type_system_password.sh b/dotfiles/lib/bin/type_system_password.sh index 26df938f..2e4a15f6 100755 --- a/dotfiles/lib/bin/type_system_password.sh +++ b/dotfiles/lib/bin/type_system_password.sh @@ -1,4 +1,3 @@ -#!/usr/bin/env bash -PASSWORD="$(keepasshttp.py --get -u "http://system.com" | jq '.[].password' | unescape.py)" -sleep .1s -xdotool type "$PASSWORD" +#!/usr/bin/env zsh + +xdotool type --clearmodifiers "$(keepass_system_password)" From 5844b4e921f9a0cd9c0c3763663ab7dbbc60fa43 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Wed, 7 Dec 2016 13:48:21 -0800 Subject: [PATCH 4/6] [Linux] Add keepass get password functions --- dotfiles/lib/shellenv/functions.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dotfiles/lib/shellenv/functions.sh b/dotfiles/lib/shellenv/functions.sh index ebcfeb2c..931b84d2 100644 --- a/dotfiles/lib/shellenv/functions.sh +++ b/dotfiles/lib/shellenv/functions.sh @@ -87,7 +87,7 @@ function confirm() { # call with a prompt string or use a default read -r -p "$1" response case $response in - [yY][eE][sS]|[yY]) + [yY][eE][sS]|[yY]) return 0 ;; *) @@ -463,3 +463,13 @@ function localip { ;; esac } + +function keepass_system_password { + keepasshttp.py --get -u "http://$(hostname).systempassword" | + jq '.[].password' | unescape.py +} + +function keepass_keepass_password { + keepasshttp.py --get -u "http://keepass.password" | + jq '.[].password' | unescape.py +} From ee1df2f5360929a4b92a3ca750e8146fb409b15c Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Wed, 7 Dec 2016 13:48:34 -0800 Subject: [PATCH 5/6] [XMonad] Change Hyper p target to type_system_password --- dotfiles/xmonad/xmonad.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotfiles/xmonad/xmonad.hs b/dotfiles/xmonad/xmonad.hs index 0918c922..6848ff18 100644 --- a/dotfiles/xmonad/xmonad.hs +++ b/dotfiles/xmonad/xmonad.hs @@ -624,7 +624,7 @@ addKeys conf@XConfig {modMask = modm} = , ((mod3Mask .|. controlMask, xK_1), toggleFadingForActiveScreen) , ((mod3Mask, xK_e), moveTo Next EmptyWS) , ((mod3Mask, xK_v), spawn "copyq_rofi.sh") - , ((mod3Mask, xK_p), spawn "system_password.sh") + , ((mod3Mask, xK_p), spawn "type_system_password.sh") , ((mod3Mask, xK_h), spawn "screenshot.sh") , ((mod3Mask, xK_c), spawn "shell_command.sh") , ((mod3Mask .|. shiftMask, xK_l), spawn "dm-tool lock") From ee68f3f15cbd7473d8f8e2c200c4d70cd91c324f Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Wed, 7 Dec 2016 18:10:32 -0800 Subject: [PATCH 6/6] [Linux] Add keepass functions --- dotfiles/lib/shellenv/functions.sh | 10 ++------ dotfiles/lib/shellenv/keepass.sh | 39 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 dotfiles/lib/shellenv/keepass.sh diff --git a/dotfiles/lib/shellenv/functions.sh b/dotfiles/lib/shellenv/functions.sh index 931b84d2..08723e80 100644 --- a/dotfiles/lib/shellenv/functions.sh +++ b/dotfiles/lib/shellenv/functions.sh @@ -464,12 +464,6 @@ function localip { esac } -function keepass_system_password { - keepasshttp.py --get -u "http://$(hostname).systempassword" | - jq '.[].password' | unescape.py -} - -function keepass_keepass_password { - keepasshttp.py --get -u "http://keepass.password" | - jq '.[].password' | unescape.py +function all_lines_after { + sed -n "/$1/"'$p' } diff --git a/dotfiles/lib/shellenv/keepass.sh b/dotfiles/lib/shellenv/keepass.sh new file mode 100644 index 00000000..0ad355e4 --- /dev/null +++ b/dotfiles/lib/shellenv/keepass.sh @@ -0,0 +1,39 @@ +keepass_system_password() { + keepasshttp.py --get -u "http://$(hostname).systempassword" | + jq '.[].password' | unescape.py +} + +keepass_password() { + keepasshttp.py --get -u "http://keepass.password" | + jq '.[].password' | unescape.py +} + +my_kp() { + kpcli --kdb "$HOME/SparkleShare/config/db.kdbx" \ + --key "$HOME/SparkleShare/config/creds/keepass.key" \ + --pwfile <(keepass_password) "$@" +} + +list_passwords() { + my_kp --command 'ls Root/' | sed -n '/=== Entries ===/,$p' | tail -n +2 +} + +get_pass_from_entry() { + grep -E '^ *Pass:' | get_cols 2 +} + +select_password() { + list_passwords | rofi -dmenu -i | get_cols 2 +} + +get_password() { + my_kp --command "show -f Root/$1" | get_pass_from_entry +} + +echo_selected_password() { + get_password "$(select_password)" +} + +type_selected_password() { + xdotool type --clearmodifiers "$(echo_selected_password)" +}