mirror of
https://github.com/nikdoof/dotfiles.git
synced 2026-01-31 11:28:14 +00:00
[zsh] Add completions
This commit is contained in:
@@ -1,19 +1,4 @@
|
|||||||
|
fpath+=($HOME/.config/zsh/completions)
|
||||||
|
|
||||||
autoload -Uz compinit
|
autoload -Uz compinit
|
||||||
compinit
|
compinit
|
||||||
|
|
||||||
function _add-sshkey() {
|
|
||||||
local -a identities
|
|
||||||
|
|
||||||
# check for .ssh folder presence
|
|
||||||
if [[ ! -d $HOME/.ssh ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
for id in $HOME/.ssh/id_ed25519_*; do
|
|
||||||
name=$(basename $id | cut -d'_' -f3- | cut -d'.' -f1)
|
|
||||||
[[ ${id:-3} != 'pub' ]] && identities+=$name
|
|
||||||
done
|
|
||||||
|
|
||||||
compadd $identities
|
|
||||||
}
|
|
||||||
compdef _add-sshkey add-sshkey
|
|
||||||
|
|
||||||
|
|||||||
18
zsh/.config/zsh/completions/_add_sshkey
Normal file
18
zsh/.config/zsh/completions/_add_sshkey
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#compdef add-sshkey
|
||||||
|
|
||||||
|
_add-sshkey() {
|
||||||
|
local -a identities
|
||||||
|
|
||||||
|
# check for .ssh folder presence
|
||||||
|
if [[ ! -d $HOME/.ssh ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
for id in $HOME/.ssh/id_ed25519_*; do
|
||||||
|
name=$(basename $id | cut -d'_' -f3- | cut -d'.' -f1)
|
||||||
|
[[ ${id:-3} != 'pub' ]] && identities+=$name
|
||||||
|
done
|
||||||
|
|
||||||
|
compadd $identities
|
||||||
|
}
|
||||||
|
|
||||||
|
_add-sshkey "$@"
|
||||||
36
zsh/.config/zsh/completions/_awslogin
Normal file
36
zsh/.config/zsh/completions/_awslogin
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#compdef awslogin
|
||||||
|
|
||||||
|
_awslogin() {
|
||||||
|
local context state state_descr line
|
||||||
|
typeset -A opt_args
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
'--profile[AWS profile name]:profile:->profiles' \
|
||||||
|
'--region[AWS region]:region:->regions'
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
profiles)
|
||||||
|
local profiles
|
||||||
|
profiles=(${(f)"$(aws --no-cli-pager configure list-profiles 2>/dev/null)"})
|
||||||
|
_describe 'AWS profiles' profiles
|
||||||
|
;;
|
||||||
|
regions)
|
||||||
|
local regions
|
||||||
|
regions=(
|
||||||
|
'us-east-1:US East (N. Virginia)'
|
||||||
|
'us-east-2:US East (Ohio)'
|
||||||
|
'us-west-1:US West (N. California)'
|
||||||
|
'us-west-2:US West (Oregon)'
|
||||||
|
'eu-west-1:Europe (Ireland)'
|
||||||
|
'eu-west-2:Europe (London)'
|
||||||
|
'eu-central-1:Europe (Frankfurt)'
|
||||||
|
'ap-southeast-1:Asia Pacific (Singapore)'
|
||||||
|
'ap-southeast-2:Asia Pacific (Sydney)'
|
||||||
|
'ap-northeast-1:Asia Pacific (Tokyo)'
|
||||||
|
)
|
||||||
|
_describe 'AWS regions' regions
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
_awslogin "$@"
|
||||||
Reference in New Issue
Block a user