Originally posted by programmerjake
View Post
Code:
#!/bin/sh editors=(nano vim) selection=1 echo "Please select your default text editor:" echo "(1) Simple (nano)" echo "(2) Programmer/Advanced (vim)" while true; do echo -n "Input number (default 1)? " read -n 1 selection echo if [ $selection ]; then if ! [ "$selection" -eq "$selection" ] 2>/dev/null; then selection=0 echo "Please input a number (1 or 2)." else if [ $selection -gt 2 ] || [ $selection -lt 1 ]; then selection=0 echo "Please input a number (1 or 2)." else selection=$((selection-1)) break fi fi else selection=0 break fi done echo >> $HOME/.profile echo "# editor-selector" >> $HOME/.profile echo "EDITOR=${editors[selection]}" >> $HOME/.profile export EDITOR=${editors[selection]} echo "Default text editor set to ${editors[selection]}." echo "You may need to relog for the change to take effect." sleep 3 exec ${editors[selection]} $@
Comment