dotfiles/sub/bash/completion
2022-10-15 19:23:06 +03:00

34 lines
733 B
Plaintext

_ssh() {
local cur opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
opts=$(grep '^Host' ~/.ssh/config ~/.ssh/config.d/* 2>/dev/null | grep -v '[?*]' | cut -d ' ' -f 2-)
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
return 0
}
_bkp() {
local cur opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
opts=$(ls ~/.backup/1)
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
return 0
}
_workon() {
local cur prev envs
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
envs=$(ls /opt/pythonenv/)
COMPREPLY=( $(compgen -W "${envs}" -- ${cur}) )
}
complete -F _workon workon
complete -F _ssh ssh
complete -F _ssh sftp
complete -F _bkp bkp