Created
February 16, 2020 18:10
-
-
Save amanjuman/7e8155be9777f68a67b0380f8236d9aa to your computer and use it in GitHub Desktop.
Nginx bash autocomplete script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Name: nginx | |
# Desc: Nginx bash autocomplete script | |
# Ver: 1.0 | |
_nginx_allcomp() | |
{ | |
command ls /etc/nginx/$1 2>/dev/null | |
} | |
_nginx_sites() | |
{ | |
COMPREPLY=( $( compgen -W '$( _nginx_allcomp $1 )' -- $cur ) ) | |
} | |
_nginx_conf() | |
{ | |
COMPREPLY=( $( compgen -W '$( _nginx_allcomp $1 \ | |
| sed -e 's/[.]conf$//' )' -- $cur ) ) | |
} | |
_n2ensite() | |
{ | |
local cur | |
COMPREPLY=() | |
cur=${COMP_WORDS[COMP_CWORD]} | |
_nginx_sites sites-available | |
} | |
complete -F _n2ensite n2ensite | |
_n2dissite() | |
{ | |
local cur | |
COMPREPLY=() | |
cur=${COMP_WORDS[COMP_CWORD]} | |
_nginx_sites sites-enabled | |
} | |
complete -F _n2dissite n2dissite | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment