Merge pull request #543 from nwinkler/install-options-sane

Updated install script
pull/547/head
Omer Katz 2015-08-11 11:23:06 +03:00
commit 2541ca965a
3 changed files with 36 additions and 94 deletions

View File

@ -11,20 +11,16 @@ Bash it provides a solid framework for using, developing and maintaining shell s
## Install ## Install
1. Check a clone of this repo: `git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it` 1. Check a clone of this repo: `git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it`
2. Run `~/.bash_it/install.sh` (it automatically backs up your `~/.bash_profile` or `~/.bashrc`, depends on your OS) 2. Run `~/.bash_it/install.sh` (it automatically backs up your `~/.bash_profile` or `~/.bashrc`, depending on your OS)
3. Edit your modified config (`~/.bash_profile` or `~/.bashrc`) file in order to customize bash it. 3. Edit your modified config (`~/.bash_profile` or `~/.bashrc`) file in order to customize Bash it.
4. Check out available aliases, completions and plugins and enable the ones you want to use (see the next section for more details).
**NOTE:**
The install script will also prompt you asking if you use [Jekyll](https://github.com/mojombo/jekyll).
This is to set up the `.jekyllconfig` file, which stores info necessary to use the Jekyll plugin.
**INSTALL OPTIONS:** **INSTALL OPTIONS:**
The install script can take the following options: The install script can take the following options:
* `--all`: Enable all aliases, plugins and completions. * `--interactive`: Asks the user which aliases, completions and plugins to enable.
* `--none`: Don't enable any aliases, plugins or completions.
If none of these parameters is provided, the install script will ask the user. When run without the `--interactive` switch, Bash it only enables a sane default set of functionality to keep your shell lean and to avoid issues with missing dependencies. Feel free to enable the tools you want to use after the installation.
## Help Screens ## Help Screens

View File

@ -13,7 +13,7 @@ esac
BACKUP_FILE=$CONFIG_FILE.bak BACKUP_FILE=$CONFIG_FILE.bak
if [ -e "$HOME/$BACKUP_FILE" ]; then 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 while true
do 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 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,25 +34,23 @@ fi
test -w "$HOME/$CONFIG_FILE" && test -w "$HOME/$CONFIG_FILE" &&
cp -a "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && 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" 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_type=$1
file_to_enable=$2
[ ! -d "$BASH_IT/$file_type/enabled" ] && mkdir "$BASH_IT/${file_type}/enabled" [ ! -d "$BASH_IT/$file_type/enabled" ] && mkdir "$BASH_IT/${file_type}/enabled"
for src in $BASH_IT/${file_type}/available/*; do
filename="$(basename ${src})" dest="${BASH_IT}/${file_type}/enabled/${file_to_enable}"
[ ${filename:0:1} = "_" ] && continue
dest="${BASH_IT}/${file_type}/enabled/${filename}"
if [ ! -e "${dest}" ]; then if [ ! -e "${dest}" ]; then
ln -s "../available/${filename}" "${dest}" ln -s "../available/${file_to_enable}" "${dest}"
else else
echo "File ${dest} exists, skipping" echo "File ${dest} exists, skipping"
fi fi
done
} }
function load_some() { function load_some() {
@ -80,58 +78,27 @@ function load_some() {
done done
} }
if [[ "$1" == "--none" ]] if [[ "$1" == "--interactive" ]]
then 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" for type in "aliases" "plugins" "completion"
do do
while true echo -e "\033[0;32mEnabling $type\033[0m"
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 load_some $type
break
;;
all)
load_all $type
break
;;
none)
break
;;
*)
echo "Unknown choice. Please enter some, all, or none"
continue
;;
esac
done done
done else
echo -e "\033[0;32mInstallation finished successfully! Enjoy bash-it!\033[0m" echo ""
echo -e "\033[0;32mEnabling sane defaults\033[0m"
load_one completion bash-it.completion.bash
fi fi
echo ""
echo -e "\033[0;32mInstallation finished successfully! Enjoy bash-it!\033[0m"
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."

View File

@ -1,21 +0,0 @@
# This is a space-delimited list of your Jekyll project paths
SITES="$HOME/sites/project_1 $HOME/sites/project_2"
# This is another space-delimited list.
# This one is of the remote user@host:path location of your jekyll site
# NOTE: The locations of these must correspond to the locations
# of the sites in the first list
# For instance, the host for the first Jekyll site
# must be first in this list, the second second, etc.
REMOTES="user@host_1:path user@host_2:path"
# list of markup syntaxes to use for the sites,
# Same rules as above. Can be HTML, textile, or markdown
MARKUPS="markdown textile"
# If you want to use a different editor for Jekyll, change the value of this variable
JEKYLL_EDITOR="$EDITOR"