-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot.setup.sh
More file actions
31 lines (28 loc) · 863 Bytes
/
dot.setup.sh
File metadata and controls
31 lines (28 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Simple setup script invoker for bash with completion
# Author: Lukas Nellen
#
# Setup scripts are in $HOME/setup.d
# They get sourced to modify the current shell's environment
#
# Special case if $PYENV set to point to a directory with python virtual envs:
# setup py "the-env"
# will activate the python environment "the-env" in ${PYENV}
#
# Configure automatic name completion
_setup_complete () {
local cur="$2"
local prev="$3"
if [ ${COMP_CWORD} -gt 1 -a -f "${HOME}/.setup.d/${COMP_WORDS[1]}.compgen" ]
then
COMPREPLY=( $(bash "${HOME}/.setup.d/${COMP_WORDS[1]}.compgen" "${cur}" "${prev}") )
else
COMPREPLY=( $(builtin cd $HOME/.setup.d && \
compgen -f -X "*[~.]*" -- "${cur}" ) )
fi
}
function setup () {
script=$1
shift
source $HOME/.setup.d/${script} "$@"
}
complete -o nospace -F _setup_complete setup