Fix code style
At least a general conformance to the same style if nothing else Based on what appeared to be the most used or most sensible conventions which lead to the following Braces around variables Preserve quotes and quote paths statements begin on the same line No trailing white space Respect 120 chars page width at least Use brackets instead of back-ticks Two space indent 4 space continuation No logic was harmed in the making of this commit.pull/174/head
parent
447c89aa0e
commit
6f0a147c01
73
install.sh
73
install.sh
|
|
@ -1,5 +1,26 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# bash-it installer
|
# bash-it installer
|
||||||
|
BASH_IT="${HOME}/.bash_it"
|
||||||
|
|
||||||
|
cp "${HOME}/.bash_profile" "${HOME}/.bash_profile.bak"
|
||||||
|
cp "${HOME}/.bash_it/template/bash_profile.template.bash" "${HOME}/.bash_profile"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
read -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 "Please enter Y or N"
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# Show how to use this installer
|
# Show how to use this installer
|
||||||
function _bash-it_show_usage() {
|
function _bash-it_show_usage() {
|
||||||
|
|
@ -17,25 +38,30 @@ function _bash-it_show_usage() {
|
||||||
|
|
||||||
# enable a thing
|
# enable a thing
|
||||||
function _bash-it_load_one() {
|
function _bash-it_load_one() {
|
||||||
file_type=$1
|
file_type="${1}"
|
||||||
file_to_enable=$2
|
[ ! -d "${BASH_IT}/${file_type}/enabled" ] && mkdir "${BASH_IT}/${file_type}/enabled"
|
||||||
mkdir -p "$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
|
||||||
if [ ! -e "${dest}" ]; then
|
dest="${BASH_IT}/${file_type}/enabled/${filename}"
|
||||||
ln -sf "../available/${file_to_enable}" "${dest}"
|
if [ ! -e "${dest}" ]; then
|
||||||
else
|
ln -s "${src}" "${dest}"
|
||||||
echo "File ${dest} exists, skipping"
|
else
|
||||||
fi
|
echo "File ${dest} exists, skipping"
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Interactively enable several things
|
# Interactively enable several things
|
||||||
function _bash-it_load_some() {
|
function _bash-it_load_some() {
|
||||||
file_type=$1
|
file_type="${1}"
|
||||||
single_type=$(echo "$file_type" | sed -e "s/aliases$/alias/g" | sed -e "s/plugins$/plugin/g")
|
single_type=$(echo "$file_type" | sed -e "s/aliases$/alias/g" | sed -e "s/plugins$/plugin/g")
|
||||||
enable_func="_enable-$single_type"
|
enable_func="_enable-$single_type"
|
||||||
[ -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 path in "$BASH_IT/${file_type}/available/"[^_]*; do
|
for path in "$BASH_IT/${file_type}/available/"[^_]*; do
|
||||||
|
if [ ! -d "${BASH_IT}/${file_type}/enabled" ]; then
|
||||||
|
mkdir "${BASH_IT}/${file_type}/enabled"
|
||||||
|
fi
|
||||||
file_name=$(basename "$path")
|
file_name=$(basename "$path")
|
||||||
while true; do
|
while true; do
|
||||||
just_the_name="${file_name%%.*}"
|
just_the_name="${file_name%%.*}"
|
||||||
|
|
@ -151,6 +177,31 @@ for param in "$@"; do
|
||||||
"--overwrite-backup") set -- "$@" "-f" ;;
|
"--overwrite-backup") set -- "$@" "-f" ;;
|
||||||
*) set -- "$@" "$param" ;;
|
*) set -- "$@" "$param" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
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
|
done
|
||||||
|
|
||||||
OPTIND=1
|
OPTIND=1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue