commit 943606918ecbce27185da8adc6cc1dfe1a3d0215 parent 6ff95106fe7d62c42a15c1c2e802b334f8a2c3bd Author: Oscar Benedito <oscar@oscarbenedito.com> Date: Sun, 13 Dec 2020 17:09:21 +0100 Add pass configuration Diffstat:
M | .config/nvim/init.vim | | | 1 | + |
A | .local/bin/passmenu | | | 32 | ++++++++++++++++++++++++++++++++ |
M | .profile | | | 1 | + |
3 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim @@ -16,6 +16,7 @@ Plug 'tpope/vim-commentary' " easily comment objects Plug 'tpope/vim-repeat' " make surround commands repeatable Plug 'tpope/vim-fugitive' " git wrapper Plug 'vimwiki/vimwiki' +Plug 'https://sanctum.geek.nz/code/vim-redact-pass.git' call plug#end() " netrw diff --git a/.local/bin/passmenu b/.local/bin/passmenu @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +shopt -s nullglob globstar + +typeit=0 +if [ "$1" = "--type" ]; then + typeit=1 + shift +elif [ "$1" = "--type-all" ]; then + typeit=2 + shift +fi + +prefix="${PASSWORD_STORE_DIR-~/.password-store}" +password_files=( "$prefix"/**/*.gpg ) +password_files=( "${password_files[@]#"$prefix"/}" ) +password_files=( "${password_files[@]%.gpg}" ) + +password=$(printf '%s\n' "${password_files[@]}" | dmenu -i "$@") + +[ -n "$password" ] || exit + +if [ "$typeit" = "0" ]; then + pass show -c "$password" 2>/dev/null +elif [ "$typeit" = "1" ]; then + pass show "$password" | head -n 1 - | xdotool type --clearmodifiers --file - +else + pass="$(pass show "$password")" + username="$(echo "$pass" | sed -n "s/^username:[ ]*//p")" + pass="$(echo "$pass" | head -n 1 -)" + printf "%s %s" "$username" "$pass" | xdotool type --clearmodifiers --file - +fi diff --git a/.profile b/.profile @@ -13,6 +13,7 @@ export XDG_CACHE_HOME="$HOME/.cache" # XDG paths export R_LIBS_USER="$XDG_DATA_HOME/R" +export PASSWORD_STORE_DIR="$XDG_DATA_HOME/password-store" export ATOM_HOME="$XDG_DATA_HOME/atom" export GOPATH="$XDG_DATA_HOME/go" export ZDOTDIR="$XDG_CONFIG_HOME/zsh"