[feature] make dash/bat optional

This commit is contained in:
Klesh Wong 2020-12-17 16:08:47 +08:00
parent 9a34e1a21d
commit 226ab0f31d
2 changed files with 26 additions and 12 deletions

View File

@ -5,12 +5,14 @@ DIR=$(dirname "$(readlink -f "$0")")
. "$DIR/../env.sh"
log 'Setting up shell'
case "$PM" in
apt)
sudo add-apt-repository ppa:fish-shell/release-3 -y
sudo apt update
sudo apt install fish silversearcher-ag dash bat -y
sudo apt install fish silversearcher-ag -y
if [ "$DISTRIB_RELEASE_MAJOR" -gt 19 ] || [ "$DISTRIB_RELEASE" = "19.10" ]; then
sudo apt install dash bat -y
fi
lnsf /usr/bin/batcat "$HOME/.local/bin/bat"
intorepo https://github.com/junegunn/fzf.git "$HOME/.fzf"
./install --all
@ -36,19 +38,24 @@ case "$PM" in
;;
esac
log 'Setting up bat'
BAT_THEMES="$(bat --config-dir)/themes"
BAT_GRUVBOX="$BAT_THEMES/gruvbox"
if [ ! -d "$BAT_GRUVBOX" ]; then
mkdir -p "$BAT_THEMES"
git_clone https://github.com/peaceant/gruvbox.git "$BAT_GRUVBOX"
if has_cmd bat; then
log 'Setting up bat'
BAT_THEMES="$(bat --config-dir)/themes"
BAT_GRUVBOX="$BAT_THEMES/gruvbox"
if [ ! -d "$BAT_GRUVBOX" ]; then
mkdir -p "$BAT_THEMES"
git_clone https://github.com/peaceant/gruvbox.git "$BAT_GRUVBOX"
fi
fi
log 'Setting up dash as default shell'
sudo /usr/bin/ln -sfT dash /usr/bin/sh
if has_cmd dash; then
log 'Setting up dash as default shell'
sudo /usr/bin/ln -sfT dash /usr/bin/sh
if [ "$(awk -F':' '/^'"$USER"'/{print $7}' /etc/passwd)" != "/bin/sh" ]; then
chsh -s /bin/sh
if [ "$(awk -F':' '/^'"$USER"'/{print $7}' /etc/passwd)" != "/bin/sh" ]; then
chsh -s /bin/sh
fi
fi

7
env.sh
View File

@ -107,6 +107,13 @@ case "$PM" in
openssh-client \
curl wget \
man sudo
if [ -f /etc/lsb-release ]; then
set -a
. /etc/lsb-release
set +a
export DISTRIB_RELEASE_MAJOR=${DISTRIB_RELEASE%.*}
export DISTRIB_RELEASE_MINOR=${DISTRIB_RELEASE#.*}
fi
;;
pacman)
sudo pacman -S --noconfirm --needed \