mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-03-27 21:37:05 +01:00
Merge f56eb6de31
into f97e871c33
This commit is contained in:
commit
07c2182b18
2 changed files with 63 additions and 0 deletions
plugins/expressvpn
14
plugins/expressvpn/README.md
Normal file
14
plugins/expressvpn/README.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# ExpressVPN
|
||||
|
||||
This plugin provides completion support for [`ExpressVPN`](https://www.expressvpn.com/vpn-software/vpn-linux)
|
||||
command line interface on Linux.
|
||||
|
||||
To use it, add expressvpn to the plugins array in your zshrc file.
|
||||
|
||||
```zsh
|
||||
plugins=(... expressvpn)
|
||||
```
|
||||
|
||||
## INSTALLATION NOTES
|
||||
|
||||
Besides oh-my-zsh, `expressvpn` needs to be installed by following these steps: https://www.expressvpn.com/support/vpn-setup/app-for-linux/.
|
49
plugins/expressvpn/_expressvpn
Normal file
49
plugins/expressvpn/_expressvpn
Normal file
|
@ -0,0 +1,49 @@
|
|||
#compdef expressvpn
|
||||
|
||||
# bash completion for expressvpn -*- shell-script -*-
|
||||
|
||||
_expressvpn_bash_autocomplete() {
|
||||
local cur cmd opts
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
|
||||
if [ "$COMP_CWORD" -gt 1 ]; then
|
||||
cmd="${COMP_WORDS[1]}"
|
||||
opts=$( ${COMP_WORDS[0]} "$cmd" "${COMP_WORDS[@]:2:$COMP_CWORD-2}" --generate-bash-completion )
|
||||
else
|
||||
opts=$( ${COMP_WORDS[0]} --generate-bash-completion )
|
||||
fi
|
||||
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||
|
||||
local escaped_single_qoute="\\'"
|
||||
local i=0
|
||||
for entry in ${COMPREPLY[*]}
|
||||
do
|
||||
if [[ "${cur:0:1}" == "'" ]]
|
||||
then
|
||||
# started with single quote, escaping only other single quotes
|
||||
# [']bla'bla"bla\bla bla --> [']bla'\''bla"bla\bla bla
|
||||
COMPREPLY[$i]="${entry//\'/${escaped_single_qoute}}"
|
||||
elif [[ "${cur:0:1}" == "\"" ]]
|
||||
then
|
||||
# started with double quote, escaping all double quotes and all backslashes
|
||||
# ["]bla'bla"bla\bla bla --> ["]bla'bla\"bla\\bla bla
|
||||
entry="${entry//\\/\\\\}"
|
||||
COMPREPLY[$i]="${entry//\"/\\\"}"
|
||||
else
|
||||
# no quotes in front, escaping _everything_
|
||||
# [ ]bla'bla"bla\bla bla --> [ ]bla\'bla\"bla\\bla\ bla
|
||||
entry="${entry//\\/\\\\}"
|
||||
entry="${entry//\'/\'}"
|
||||
entry="${entry//\"/\\\"}"
|
||||
COMPREPLY[$i]="${entry// /\\ }"
|
||||
fi
|
||||
(( i++ ))
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _expressvpn_bash_autocomplete expressvpn
|
Loading…
Add table
Reference in a new issue