install.fairie/home/.chezmoiscripts/universal/run_onchange_after_94-bash-it.sh.tmpl

83 lines
3.7 KiB
Cheetah
Raw Normal View History

{{- if (ne .host.distro.family "windows") -}}
2023-07-17 13:40:40 -07:00
#!/usr/bin/env -S bash -i
Update 21 files - /home/.chezmoiscripts/universal/run_onchange_after_85-remove-shortcuts.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_94-bash-it.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_95-bootstrap-zsh-plugins.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_98-cleanup.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_99-restart-gnome.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_08-install-zx.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_09-node-version.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_10-remove-bloatware.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_11-install-docker.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_91-configure-gpg.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_85-remove-shortcuts.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_94-bash-it.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_95-bootstrap-zsh-plugins.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_98-cleanup.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_99-restart-gnome.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_08-install-zx.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_09-install-go.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_09-node-version.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_10-remove-bloatware.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_11-install-docker.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_91-configure-gpg.sh.tmpl
2023-04-11 20:57:02 -07:00
# @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
2023-08-30 12:58:51 -07:00
logg info 'Installing powerline via install-program'
install-program powerline > /dev/null
fi
2023-07-17 10:41:49 -07:00
### Include Bash It
export BASH_IT="${XDG_DATA_HOME:-$HOME/.local/share}/bash_it"
export BASH_IT_THEME="powerline"
if command -v powerline-daemon > /dev/null && [ -f "$BASH_IT/bash_it.sh" ] && ! command -v bash-it; then
logg info "Sourcing the bash_it.sh script"
2023-07-17 10:41:49 -07:00
. "$BASH_IT/bash_it.sh"
fi
2023-07-14 22:28:48 -07:00
### Ensure ble.sh installed
2023-08-03 23:17:37 -07:00
if [ -d "${XDG_DATA_HOME:-$HOME/.local/share}/blesh/src" ]; then
2023-08-03 23:18:00 -07:00
logg info 'Make installing blesh'
2023-08-03 23:17:37 -07:00
make -C "${XDG_DATA_HOME:-$HOME/.local/share}/blesh/src" install > /dev/null && logg success "Installed ble.sh"
2023-07-14 22:28:48 -07:00
fi
### Bash-it completions / plugins
if command -v powerline > /dev/null && [ -f "$HOME/.bashrc" ]; then
2023-07-10 23:18:04 -07:00
# These three lines are probably not needed:
2023-11-04 18:46:18 -07:00
# logg info 'Running source ~/.bashrc'
2023-07-10 23:18:04 -07:00
# source ~/.bashrc
2023-11-04 18:46:18 -07:00
# logg success 'Imported the ~/.bashrc profile'
2023-07-11 21:32:13 -07:00
if [ -d "$BASH_IT" ]; then
### Ensure bash-it is installed
if ! command -v bash-it > /dev/null; then
2023-11-04 18:46:18 -07:00
logg info 'Installing bash-it since it is not available yet as a command'
2023-07-11 21:32:13 -07:00
bash "$BASH_IT/install.sh" --silent --no-modify-config
2023-07-14 22:28:48 -07:00
else
2023-11-04 18:46:18 -07:00
logg info 'bash-it already available'
fi
2023-07-11 21:32:13 -07:00
### Ensure completions are enabled
if [ -d "$BASH_IT/enabled" ]; then
logg info "Changing directory to $BASH_IT/enabled" && cd "$BASH_IT/enabled"
else
logg info "$BASH_IT/enabled not a directory yet"
fi
2023-07-11 21:32:13 -07:00
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 ssh system vagrant; do
2023-07-14 22:28:48 -07:00
if ls "$BASH_IT/enabled" | grep "$COMPLETION" > /dev/null; then
rm -f "$BASH_IT/enabled/"*"$COMPLETION"* > /dev/null && logg info "Removed old $COMPLETION bash-it completion symlink" || logg error "Failed to remove $COMPLETION bash-it completion symlink"
2023-07-11 21:32:13 -07:00
fi
2023-08-08 22:46:26 -07:00
yes | bash-it enable completion "$COMPLETION" > /dev/null && logg info "Enabled the bash-it $COMPLETION completion plugin" || logg error "Failed to install the $COMPLETION bash-it completion plugin"
2023-07-11 21:32:13 -07:00
done
### Ensure plugins are enabled
logg info 'Enabling bash-it plugins'
# TODO: Move these plugins to the .chezmoidata.yaml
2023-07-17 15:06:36 -07:00
for PLUGIN in base blesh browser cht-sh dirs gitstatus powerline sudo xterm; do
2023-07-11 21:32:13 -07:00
if ls "$BASH_IT/enabled" | grep "$PLUGIN" > /dev/null; then
2023-07-14 22:28:48 -07:00
rm -f "$BASH_IT/enabled/"*"$PLUGIN"* > /dev/null && logg info "Removed old $PLUGIN bash-it plugin symlink" || logg error "Failed to remove $PLUGIN bash-it plugin symlink"
2023-07-11 21:32:13 -07:00
fi
2023-08-08 22:46:26 -07:00
yes | 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"
2023-07-11 21:32:13 -07:00
done
else
2023-07-11 21:32:13 -07:00
logg warn 'The path specified by BASH_IT does not exist yet'
fi
else
if ! command -v powerline > /dev/null; then
2023-11-04 18:46:18 -07:00
logg warn 'powerline is not available'
else
2023-11-04 18:46:18 -07:00
logg warn '~/.bashrc is missing'
fi
fi
{{ end -}}