Add interactive prompts
This commit is contained in:
parent
d37ecda693
commit
52ef90ea45
|
@ -12,7 +12,11 @@ This is my repository of files needed for general setup of my machines. It inclu
|
|||
|
||||
## Installation
|
||||
|
||||
`curl -L http://git.chrissexton.org/cws/dotfiles/raw/master/setup.sh | bash -s -- -n "<<YOUR NAME>>" -e "<<YOUR EMAIL>>"`
|
||||
`bash <( curl -L http://git.chrissexton.org/cws/dotfiles/raw/master/setup.sh)`
|
||||
|
||||
Or if you want to customize without an interactive prompt:
|
||||
|
||||
`bash <(curl -L http://git.chrissexton.org/cws/dotfiles/raw/master/setup.sh) -n "<<YOUR NAME>>" -e "<<YOUR EMAIL>>" -i`
|
||||
|
||||
You may customize the irssi configuration with the `server`, `port`, `nick`, and `password` options. Any of these options may be specified by environment variables instead of switches.
|
||||
|
||||
|
|
41
setup.sh
41
setup.sh
|
@ -4,10 +4,12 @@ set -o pipefail
|
|||
|
||||
[ "$NAME" ] || NAME=
|
||||
[ "$EMAIL" ] || EMAIL=
|
||||
[ "$IRCSET" ] || IRCSET=
|
||||
[ "$IRCSERVER" ] || IRCSERVER=irc.freenode.net
|
||||
[ "$IRCPORT" ] || IRCPORT=6667
|
||||
[ "$IRCNICK" ] || IRCNICK=coward
|
||||
[ "$IRCPASS" ] || IRCPASS=
|
||||
[ "$DOTFILES" ] || DOTFILES="$HOME"/.dotfiles
|
||||
|
||||
die() { echo "$1" 1>&2 && show_help && [ "$2" ] && [ "$2" -ge 0 ] && exit "$2" || exit 1; }
|
||||
|
||||
|
@ -19,6 +21,7 @@ show_help() {
|
|||
-h, --help # This help message
|
||||
-n, --name # Name for git
|
||||
-e, --email # Email for git
|
||||
-i, --irssi # Do not prompt for irssi options
|
||||
-s, --server # Server for irssi
|
||||
-p, --port # Port for irssi
|
||||
-N, --nick # Nick for irssi
|
||||
|
@ -35,18 +38,37 @@ NARGS=-1; while [ "$#" -ne "$NARGS" ]; do NARGS=$#; case $1 in
|
|||
shift && NAME="$1" && shift; ;;
|
||||
-e|--email) # Email for git
|
||||
shift && EMAIL="$1" && shift; ;;
|
||||
-i|--irssi)
|
||||
shift && IRCSET=1 && shift; ;;
|
||||
-s|--server) # server for irssi
|
||||
shift && IRCSERVER="$1" && shift; ;;
|
||||
shift && IRCSERVER="$1" && IRCSET=1 && shift; ;;
|
||||
-p|--port) # port for irssi
|
||||
shift && IRCPORT="$1" && shift; ;;
|
||||
shift && IRCPORT="$1" && IRCSET=1 && shift; ;;
|
||||
-N|--nick) # nick for irssi
|
||||
shift && IRCNICK="$1" && shift; ;;
|
||||
shift && IRCNICK="$1" && IRCSET=1 && shift; ;;
|
||||
-P|--password) # password for irssi
|
||||
shift && IRCPASS="$1" && shift; ;;
|
||||
shift && IRCPASS="$1" && IRCSET=1 && shift; ;;
|
||||
esac; done
|
||||
|
||||
[ "$NAME" ] || die "You must provide a name!"
|
||||
[ "$EMAIL" ] || die "You must provide an email!"
|
||||
if [ ! "$NAME" ]; then
|
||||
read -e -p "Git author name: " NAME
|
||||
fi
|
||||
[ "$NAME" ] || die "You must specify a Git author name"
|
||||
if [ ! "$EMAIL" ]; then
|
||||
read -e -p "Git author email: " EMAIL
|
||||
fi
|
||||
[ "$EMAIL" ] || die "You must specify a Git author email"
|
||||
if [ ! "$IRCSET" ]; then
|
||||
read -e -p "Would you like to set up irssi [Y/n]? " -i"n" yn
|
||||
case $yn in
|
||||
[Yy]* )
|
||||
read -e -p "irssi server: " -i"irc.freenode.net" IRCSERVER
|
||||
read -e -p "irssi port: " -i"6667" IRCPORT
|
||||
read -e -p "irssi nick: " -i"coward" IRCNICK
|
||||
read -e -p "irssi psasword: " IRCPASS
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
fn_distro(){
|
||||
if [ -f /etc/lsb-release ]; then
|
||||
|
@ -71,12 +93,11 @@ elif [[ "$UNAMESTR" == 'Darwin' ]]; then
|
|||
true
|
||||
fi
|
||||
|
||||
if [ ! -d "$HOME"/.dotfiles ]; then
|
||||
git clone git@git.chrissexton.org:cws/dotfiles.git "$HOME"/.dotfiles
|
||||
elif [ ! -d "$HOME"/.dotfiles/files ]; then
|
||||
if [ ! -d "$DOTFILES" ]; then
|
||||
git clone git@git.chrissexton.org:cws/dotfiles.git "$DOTFILES"
|
||||
elif [ ! -d "$DOTFILES"/files ]; then
|
||||
die "You must have a destination for the dotfiles repository!"
|
||||
fi
|
||||
DOTFILES="$HOME"/.dotfiles
|
||||
|
||||
cat "$DOTFILES"/files/gitignore_global > "$HOME"/.gitignore_global
|
||||
|
||||
|
|
Loading…
Reference in New Issue