ksh-completion

Korn shell completion installer
Log | Files | Refs

install.sh (1152B)


      1 #!/bin/ksh
      2 function error {
      3 	echo "$1"
      4 	exit 1
      5 }
      6 
      7 if [[ "`id -u`" -eq 0 ]]; then
      8 	echo -e "Checking Root User(Oke)"
      9 else
     10 	echo -e "Checking Root User(Failed). Switching to root user"
     11 	doas ksh $0
     12 	exit 0
     13 fi
     14 
     15 PROFILE_SHELL=`sh -c 'ps -p $$ -o ppid=' | xargs ps -o comm= -p`
     16 if [ "$PROFILE_SHELL" \!= "ksh" ]; then
     17 	error "You should be using ksh for ksh-completion!"
     18 fi
     19 
     20 wget -O /tmp/ksh_completion "https://ircforever.org/ksh_completion"
     21 
     22 function Install {
     23 	USERS=$1 
     24 	LOCATION=$2
     25 	for USER in $USERS; do
     26 		cp /tmp/ksh_completion $LOCATION$USER/.ksh_completions
     27 		if [ \! -f $LOCATION$USER/.kshrc ]; then
     28 			if grep -q "if \[ -e ~/.ksh_completions ]; then . ~/.ksh_completions; fi" $LOCATION$USER/.profile; then
     29 				continue
     30 			else
     31 				echo "if [ -e ~/.ksh_completions ]; then . ~/.ksh_completions; fi" >> $LOCATION$USER/.profile
     32 			fi
     33 		else
     34 			if grep -q "if \[ -e ~/.ksh_completions ]; then . ~/.ksh_completions; fi" $LOCATION$USER/.kshrc; then
     35 				continue
     36 			else
     37 				echo "if [ -e ~/.ksh_completions ]; then . ~/.ksh_completions; fi" >> $LOCATION$USER/.kshrc
     38 			fi
     39 		fi	
     40 	done
     41 }
     42 
     43 USERS=$(ls /home)
     44 
     45 Install "$USERS" /home/
     46 Install "skel" /etc/