Skip to content

Commit

Permalink
feat(add): passgrep
Browse files Browse the repository at this point in the history
Adding 'passgrep' to fish shell. It allows an easy grep of 'pass' arguments like 'url' or 'user' etc.
  • Loading branch information
dme86 committed Mar 11, 2024
1 parent 5a9633b commit 731b66a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions config.fish
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ alias vim nvim
fish_add_path /opt/local/bin
set -gx GPG_TTY (tty)

function passgrep
set entry $argv[1]
set part $argv[2]

# Use pass command to retrieve the password, grep for the specified part, and format the output
set result (pass $entry | grep $part | cut -d ':' -f 2,3 | awk '{$1=$1;print}')

# Check if the result is empty
if test -n "$result"
# Copy the result to the clipboard
echo $result | xclip -sel clip
echo "$part for '$entry' copied to clipboard."
else
# Print a message indicating that the entry or part was not found
echo "Error: '$entry' or '$part' not found."
end
end

function ..
cd ..
end
Expand Down

0 comments on commit 731b66a

Please sign in to comment.