Updated install script

Removed Jekyll template option - it does not really belong in Bash-it.

Removed the all/some/none options. Most people selected `all` and then
complained about things not working, or error messages being shown. This
was mostly due to missing dependencies.

The installer now uses a 'sane' default - it just enables completion for
the 'bash-it' command and nothing else. At the end of the installation,
it prints a message explaining the ways to see the available plugins and
how to enable them.

Updated readme with install options
This commit is contained in:
Nils Winkler
2015-08-06 09:19:20 +02:00
parent a161455c98
commit 237816b782
3 changed files with 28 additions and 125 deletions

View File

@@ -13,7 +13,7 @@ esac
BACKUP_FILE=$CONFIG_FILE.bak
if [ -e "$HOME/$BACKUP_FILE" ]; then
echo "Backup file already exists. Make sure to backup your .bashrc before running this installation." >&2
echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2
while true
do
read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP
@@ -34,104 +34,37 @@ fi
test -w "$HOME/$CONFIG_FILE" &&
cp -a "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" &&
echo "Your original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak"
echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m"
cp "$HOME/.bash_it/template/bash_profile.template.bash" "$HOME/$CONFIG_FILE"
echo "Copied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it"
echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m"
function load_all() {
function load_one() {
file_type=$1
file_to_enable=$2
[ ! -d "$BASH_IT/$file_type/enabled" ] && mkdir "$BASH_IT/${file_type}/enabled"
for src in $BASH_IT/${file_type}/available/*; do
filename="$(basename ${src})"
[ ${filename:0:1} = "_" ] && continue
dest="${BASH_IT}/${file_type}/enabled/${filename}"
if [ ! -e "${dest}" ]; then
ln -s "../available/${filename}" "${dest}"
else
echo "File ${dest} exists, skipping"
fi
done
dest="${BASH_IT}/${file_type}/enabled/${file_to_enable}"
if [ ! -e "${dest}" ]; then
ln -s "../available/${file_to_enable}" "${dest}"
else
echo "File ${dest} exists, skipping"
fi
}
function load_some() {
file_type=$1
[ -d "$BASH_IT/$file_type/enabled" ] || mkdir "$BASH_IT/$file_type/enabled"
for path in `ls $BASH_IT/${file_type}/available/[^_]*`
do
file_name=$(basename "$path")
while true
do
read -e -n 1 -p "Would you like to enable the ${file_name%%.*} $file_type? [y/N] " RESP
case $RESP in
[yY])
ln -s "../available/${file_name}" "$BASH_IT/$file_type/enabled"
break
;;
[nN]|"")
break
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
done
done
}
echo ""
echo "Enabling sane defaults"
load_one completion bash-it.completion.bash
if [[ "$1" == "--none" ]]
then
echo "Not enabling any aliases, plugins or completions"
elif [[ "$1" == "--all" ]]
then
echo "Enabling all aliases, plugins and completions."
load_all aliases
load_all plugins
load_all completion
else
while true
do
read -e -n 1 -p "Do you use Jekyll? (If you don't know what Jekyll is, answer 'n') [y/N] " RESP
case $RESP in
[yY])
cp "$HOME/.bash_it/template/jekyllconfig.template.bash" "$HOME/.jekyllconfig"
echo "Copied the template .jekyllconfig into your home directory. Edit this file to customize bash-it for using the Jekyll plugins"
break
;;
[nN]|"")
break
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
done
for type in "aliases" "plugins" "completion"
do
while true
do
read -p "Would you like to enable all, some, or no $type? Some of these may make bash slower to start up (especially completion). (all/some/none) " RESP
case $RESP
in
some)
load_some $type
break
;;
all)
load_all $type
break
;;
none)
break
;;
*)
echo "Unknown choice. Please enter some, all, or none"
continue
;;
esac
done
done
echo ""
echo -e "\033[0;32mInstallation finished successfully! Enjoy bash-it!\033[0m"
fi
echo -e "\033[0;32mTo start using it, open a new tab or 'source "$HOME/$CONFIG_FILE"'.\033[0m"
echo ""
echo "To show the available aliases/completions/plugins, type one of the following:"
echo " bash-it show aliases"
echo " bash-it show completions"
echo " bash-it show plugins"
echo ""
echo "To avoid issues and to keep your shell lean, please enable only features you really want to use."
echo "Enabling everything can lead to issues."