zsh対応の修正
このコミットが含まれているのは:
コミット
53a5739fa4
|
@ -5,6 +5,7 @@
|
|||
* パスワード追加機能性で、パスワードが既に存在するかどうか確認
|
||||
* パスワード削除機能性で、パスワードが存在ないかどうか確認
|
||||
* パスワード変更機能性の追加
|
||||
* zsh対応の修正
|
||||
|
||||
# 1.1.2
|
||||
* OpenBSDでのコンパイラーが発生された問題を修正した
|
||||
|
|
|
@ -1,28 +1,48 @@
|
|||
# compdef sp
|
||||
#compdef sp
|
||||
#autoload
|
||||
|
||||
_sp () {
|
||||
local state
|
||||
local -a options
|
||||
local -a entries
|
||||
|
||||
_arguments -C \
|
||||
'-i[GPGと使ってパスワードストレージを初期設定]: :_sp_complete_keys' \
|
||||
'-s[パスワードを表示]: :_sp_complete_entries' \
|
||||
'-y[パスワードを表示せずクリップボードにコピーする]: :_sp_complete_entries' \
|
||||
'-l[パスワード一覧を表示]' \
|
||||
'-a[パスワードを追加]: :_sp_complete_entries' \
|
||||
'-d[パスワードを削除]: :_sp_complete_entries' \
|
||||
'-g[希望文字数でパスワードをランダムに作成する]: :_sp_complete_entries' \
|
||||
'-o[ワンタイムパスワード(TOTP)を表示]: :_sp_complete_entries' \
|
||||
'-h[ヘルプを表示]' \
|
||||
'-v[バージョンを表示]' \
|
||||
'*:: :->subcmds'
|
||||
|
||||
case $state in
|
||||
subcmds)
|
||||
_message "no more arguments"
|
||||
;;
|
||||
esac
|
||||
local cmd
|
||||
if (( CURRENT > 2)); then
|
||||
cmd=${words[2]}
|
||||
curcontext="${curcontext%:*:*}:pass-$cmd"
|
||||
(( CURRENT-- ))
|
||||
shift words
|
||||
case "${cmd}" in
|
||||
-i)
|
||||
_sp_complete_keys
|
||||
;;
|
||||
-i|-y|-d|-a|-e|-o)
|
||||
_sp_complete_entries_helper
|
||||
;;
|
||||
-g)
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
"secure:英数字+特別文字(デフォルト)"
|
||||
"risk:英数字のみ(不安)"
|
||||
)
|
||||
;;
|
||||
-s)
|
||||
_sp_cmd_show
|
||||
;;
|
||||
esac
|
||||
else
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
"-i:GPGと使ってパスワードストレージを初期設定"
|
||||
"-s:パスワードを表示"
|
||||
"-y:パスワードを表示せずクリップボードにコピーする"
|
||||
"-l:パスワード一覧を表示"
|
||||
"-a:パスワードを追加"
|
||||
"-d:パスワードを削除"
|
||||
"-e:パスワードを変更"
|
||||
"-g:希望文字数でパスワードをランダムに作成する。risk=英数字のみ(不安)、secure=英数字+特別文字(デフォルト)を使用"
|
||||
"-o:ワンタイムパスワード(TOTP)を表示。存在しなければ、創作する"
|
||||
"-h:ヘルプを表示"
|
||||
"-v:バージョンを表示"
|
||||
)
|
||||
_sp_cmd_show
|
||||
fi
|
||||
}
|
||||
|
||||
_sp_cmd_show () {
|
||||
|
@ -35,9 +55,9 @@ _sp_complete_entries() {
|
|||
|
||||
_sp_complete_entries_helper () {
|
||||
local IFS=$'\n'
|
||||
local prefix="${SP_DIR:-$HOME/.local/share/sp}"
|
||||
entries=("${(f)$(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o -type f -print 2>/dev/null | sed -e "s#${prefix}/##" -e 's#\.gpg$##')}")
|
||||
_describe 'password entries' entries
|
||||
local prefix
|
||||
zstyle -s ":completion:${curcontext}:" prefix prefix || prefix="${SP_DIR:-$HOME/.local/share/sp}"
|
||||
_values -C 'passwords' ${$(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print 2>/dev/null | sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' -e 's#\\#\\\\#g' -e 's#:#\\:#g' | sort):-""}
|
||||
}
|
||||
|
||||
_sp_complete_keys () {
|
||||
|
@ -45,4 +65,4 @@ _sp_complete_keys () {
|
|||
_values 'gpg keys' $(gpg2 --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')
|
||||
}
|
||||
|
||||
compdef _sp sp
|
||||
_sp
|
||||
|
|
読み込み中…
新しいイシューから参照