install.fairie/home/.chezmoiscripts/universal/run_onchange_after_94-bash-it.sh.tmpl
Brian Zalewski a3004df675 Latest
2023-07-12 04:32:13 +00:00

60 lines
2.5 KiB
Cheetah

{{- if (ne .host.distro.family "windows") -}}
#!/usr/bin/env -S bash -i
# @file Bash It!
# @brief Ensures Bash is configured to use Bash It!
# @description
# This script ensures Bash is configured to use Bash It! It ensures dependencies are installed, installs completions,
# and enables Bash It! plugins. The completions and plugins are hardcoded in this script.
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
### Ensure Powerline is installed
if ! command -v powerline > /dev/null; then
logg info 'Installing powerline via install-software'
install-software powerline > /dev/null
fi
### Bash-it completions / plugins
if command -v powerline > /dev/null && [ -f "$HOME/.bashrc" ]; then
# These three lines are probably not needed:
# logg info 'Running `source ~/.bashrc`'
# source ~/.bashrc
# logg success 'Imported the `~/.bashrc` profile'
if [ -d "$BASH_IT" ]; then
### Ensure bash-it is installed
if ! command -v bash-it > /dev/null; then
logg info 'Installing `bash-it` since it is not available yet as a command'
bash "$BASH_IT/install.sh" --silent --no-modify-config
fi
### Ensure completions are enabled
cd "$BASH_IT/enabled"
logg info 'Enabling bash-it completions'
# TODO: Move these plugins to the .chezmoidata.yaml
for COMPLETION in defaults dirs docker docker-compose export git makefile ng npm ssh system vagrant; do
if ! ls "$BASH_IT/enabled" | grep "$COMPLETION" > /dev/null; then
echo y | bash-it enable completion dirs > /dev/null && logg info "Enabled the bash-it $COMPLETION completion plugin" || logg error "Failed to install the $COMPLETION bash-it completion plugin"
fi
done
### Ensure plugins are enabled
logg info 'Enabling bash-it plugins'
# TODO: Move these plugins to the .chezmoidata.yaml
for PLUGIN in base blesh browser cht-sh dirs gitstatus powerline sudo xterm; do
if ls "$BASH_IT/enabled" | grep "$PLUGIN" > /dev/null; then
echo y | bash-it enable plugin "$PLUGIN" > /dev/null && logg info "Enabled the bash-it $PLUGIN plugin" || logg error "Failed to install the $PLUGIN bash-it plugin"
fi
done
else
logg warn 'The path specified by BASH_IT does not exist yet'
fi
else
if ! command -v powerline > /dev/null; then
logg warn '`powerline` is not available'
else
logg warn '`~/.bashrc` is missing'
fi
fi
{{ end -}}