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