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

7
env.sh
View File

@ -107,6 +107,13 @@ case "$PM" in
openssh-client \ openssh-client \
curl wget \ curl wget \
man sudo 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) pacman)
sudo pacman -S --noconfirm --needed \ sudo pacman -S --noconfirm --needed \