Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
# bash completion for pw -*- shell-script -*-
_pw()
{
local cur prev words cword
_init_completion || return
local db_dir=${XDG_DATA_HOME:-$HOME/.local/share/pw}/
case $prev in
-h|--help)
return 0
;;
-d|--db)
local dbs opts local_path_re
local_path_re='^(/|\.|~)'
if [[ "${cur}" =~ $local_path_re ]] ; then
opts="-f"
dbs="*"
else
dbs=$( find $db_dir -type f -print )
dbs=${dbs//$db_dir/}
fi
local IFS=$'\n'
compopt -o filenames
COMPREPLY=( $( compgen $opts -W "$dbs" -- "$cur" ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
local helpopts=$( _parse_help "$1" )
COMPREPLY=( $( compgen -W "${helpopts//#/}" -- "$cur" ) )
return 0
fi
local db labels ids
db='passwords' # FIXME: support for -d DB
labels=$( cat "$db_dir/$db" | cut -d : -f 2 )
ids=$( cat "$db_dir/$db" | cut -d : -f 4 )
local IFS=$'\n'
COMPREPLY=( $( compgen -W "$labels$IFS$ids" -- "$cur" ) )
} &&
complete -F _pw pw-autotype pw-diff pw-edit pw-insert pw-show
# ex: ts=4 sw=4 et filetype=sh