From b63101ef5e7ae638c3754c178525d4efd8a5462d Mon Sep 17 00:00:00 2001 From: Anton Zadvorny Date: Mon, 26 Aug 2019 21:21:50 +0300 Subject: [PATCH] Update commands --- home/.zsh/cmd/kp.sh | 6 +++--- home/.zsh/cmd/pf.sh | 39 +++++++++++++++++++++++++++++++++++++++ home/.zsh/cmd/vmc.sh | 2 +- 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100755 home/.zsh/cmd/pf.sh diff --git a/home/.zsh/cmd/kp.sh b/home/.zsh/cmd/kp.sh index 566869c..37f1ae9 100755 --- a/home/.zsh/cmd/kp.sh +++ b/home/.zsh/cmd/kp.sh @@ -1,10 +1,10 @@ ### PROCESS # mnemonic: [K]ill [P]rocess # show output of "ps -ef", use [tab] to select one or multiple entries -# press [enter] to kill selected processes. -# press [escape] to exit. +# press [enter] to kill selected processes +# press [escape] to exit -pid=$(ps -ef | sed 1d | eval "fzf ${FZF_DEFAULT_OPTS} -m --header='[kill:process]'" | awk '{print $2}') +pid=$(ps -ef | sed 1d | eval "fzf ${FZF_DEFAULT_OPTS} -m --header='[process:kill]'" | awk '{print $2}') if [ "x$pid" != "x" ] then diff --git a/home/.zsh/cmd/pf.sh b/home/.zsh/cmd/pf.sh new file mode 100755 index 0000000..fb44ade --- /dev/null +++ b/home/.zsh/cmd/pf.sh @@ -0,0 +1,39 @@ +### PASS +# mnemonic: [P]ass[F]ind +# search password in the passwotd store +# press [enter] to copy selected password +# press [escape] to exit + +function entry_from_path() { + local v=$1 + v=${v#$PASSWORD_STORE_DIR/} + v=${v%.gpg} + echo "$v" +} + +function candidate_selector() { + query=$1 + candidates=$2 + echo "$candidates" | fzf ${FZF_DEFAULT_OPTS} -q "$query" --header='[pass:find]' --select-1 +} + +function list_entries() { + if [ -z "${PASSWORD_STORE_DIR}" ]; then + PASSWORD_STORE_DIR="${HOME}/.password-store" + fi + + find "$PASSWORD_STORE_DIR" -name '*.gpg' | while read -r c; do + echo $(entry_from_path "$c"); + done +} + +query="$@" +candidates=$(list_entries) + +res=$(candidate_selector "$query" "$candidates") +if [ -n "$res" ]; then + pass show "$res" | tail -n +2 || exit $? + pass show -c "$res" +else + exit 1 +fi diff --git a/home/.zsh/cmd/vmc.sh b/home/.zsh/cmd/vmc.sh index 764a7c1..9655422 100755 --- a/home/.zsh/cmd/vmc.sh +++ b/home/.zsh/cmd/vmc.sh @@ -1,6 +1,6 @@ ### ASDF -# uninstall multiple languages at once, async # mnemonic [V]ersion [M]anager [C]lean +# uninstall multiple languages at once, async lang=${1}