File tree Expand file tree Collapse file tree 2 files changed +35
-4
lines changed
Expand file tree Collapse file tree 2 files changed +35
-4
lines changed Original file line number Diff line number Diff line change 1+ # bash completion for crew-sudo command
2+
3+ function _crew-sudo () {
4+ # available options
5+ local avail_opts=(--bashrc --foreground --replace)
6+
7+ # available commands
8+ local cmds=(client daemon stop-daemon)
9+
10+ # parameter that trigger this function
11+ local current=" ${COMP_WORDS[COMP_CWORD]} "
12+
13+ if [[ " ${current: 0: 1} " == ' -' ]]; then
14+ # match ${current} with available option list if ${current} start with '-'
15+ # save result to $COMPREPLY variable
16+ COMPREPLY=( $( compgen -W " ${avail_opts[*]} " -- " ${current} " ) )
17+ elif [[ ${COMP_CWORD} == 1 ]]; then
18+ # match ${current} with command list if ${current} is the first argument
19+ COMPREPLY=( $( compgen -W " ${cmds[*]} " -- " ${current} " ) )
20+ else
21+ return 1
22+ fi
23+ }
24+
25+ # register this function as completion function for crew-sudo command
26+ complete -F _crew-sudo crew-sudo
Original file line number Diff line number Diff line change @@ -5,16 +5,21 @@ if [ ${EUID} != 0 ] && [ ! -w ${INSTALL_PREFIX} ]; then
55 exit 1
66fi
77
8- INSTALL_PREFIX=" ${CREW_PREFIX:-/ usr/ local} "
8+ if [ -z " ${CREW_DEST_PREFIX} " ]; then
9+ INSTALL_PREFIX=" ${CREW_DEST_PREFIX} "
10+ else
11+ : " ${INSTALL_PREFIX:=/ usr/ local} "
12+ fi
913
1014cp -r . ${INSTALL_PREFIX} /lib/crew-sudo
1115
12- ln -s ../lib/crew-sudo/crew-sudo ${INSTALL_PREFIX} /bin/crew-sudo
13- ln -s ../lib/crew-sudo/crew-sudo ${INSTALL_PREFIX} /bin/sudo
16+ ln -sf ../lib/crew-sudo/crew-sudo ${INSTALL_PREFIX} /bin/crew-sudo
17+ ln -sf ../lib/crew-sudo/crew-sudo ${INSTALL_PREFIX} /bin/sudo
1418
1519if [ -d ${INSTALL_PREFIX} /etc/env.d ]; then
1620 # installing under chromebrew
17- ln -s ../lib/crew-sudo/autostart/crew-sudo.sh ${INSTALL_PREFIX} /etc/env.d/crew_sudo
21+ ln -sf ../lib/crew-sudo/autostart/crew-sudo.sh ${INSTALL_PREFIX} /etc/env.d/crew_sudo
22+ ln -sf ../lib/crew-sudo/autocomplete/crew-sudo.sh ${INSTALL_PREFIX} /etc/bash.d/crew_sudo
1823else
1924 # installing without chromebrew, append the autostart script to bashrc
2025 echo " source ${INSTALL_PREFIX} /lib/crew-sudo/autostart/crew-sudo.sh" > ~ /.bashrc
You can’t perform that action at this time.
0 commit comments