From 3a46ca0e6787f2507f0265638f6cf7dea67f450c Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Sun, 17 Jan 2021 15:30:01 +0800 Subject: [PATCH] [bugfix] ubuntu release env-var / bat not working --- cli/basic.sh | 7 ------- cli/fish.sh | 16 ++++------------ cli/fish/config.fish | 2 +- cli/vim.sh | 2 +- devel/deeplearning.sh | 6 +++--- env.sh | 10 ++++++++-- gui/office.sh | 8 ++++---- 7 files changed, 21 insertions(+), 30 deletions(-) diff --git a/cli/basic.sh b/cli/basic.sh index 531364a..73b81f3 100755 --- a/cli/basic.sh +++ b/cli/basic.sh @@ -14,13 +14,6 @@ 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 \ diff --git a/cli/fish.sh b/cli/fish.sh index 0f5352b..c4138ea 100755 --- a/cli/fish.sh +++ b/cli/fish.sh @@ -7,13 +7,15 @@ DIR=$(dirname "$(readlink -f "$0")") log 'Setting up shell' case "$PM" in apt) - sudo add-apt-repository ppa:fish-shell/release-3 -y + sudo add-apt-repository ppa:fish-shell/release-3 -y -n pm_update sudo apt install fish silversearcher-ag -y + echo DISTRIB_RELEASE_MAJOR: $DISTRIB_RELEASE_MAJOR + echo DISTRIB_RELEASE: $DISTRIB_RELEASE if [ "$DISTRIB_RELEASE_MAJOR" -gt 19 ] || [ "$DISTRIB_RELEASE" = "19.10" ]; then sudo apt install dash bat -y fi - lnsf /usr/bin/batcat /usr/bin/bat + sudo ln -sf /usr/bin/batcat /usr/bin/bat intorepo https://github.com/junegunn/fzf.git "$HOME/.fzf" ./install --all exitrepo @@ -39,16 +41,6 @@ case "$PM" in esac -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 - # only for local machine with gui if [ -z "$SSH_CLIENT" ] && [ -n "$DISPLAY" ] && has_cmd dash; then log 'Setting up dash as default shell' diff --git a/cli/fish/config.fish b/cli/fish/config.fish index 2f1fbd9..9dbb831 100644 --- a/cli/fish/config.fish +++ b/cli/fish/config.fish @@ -23,7 +23,7 @@ if status is-interactive set -gx LS_COLORS 'ow=34;42;40' # === bat configuration - set -gx BAT_THEME 'gruvbox' + set -gx BAT_THEME 'OneHalfDark' set -gx MANPAGER "sh -c 'col -bx | bat -l man -p'" # === dict.sh configuration diff --git a/cli/vim.sh b/cli/vim.sh index 65d2d79..eb9acc7 100755 --- a/cli/vim.sh +++ b/cli/vim.sh @@ -29,7 +29,7 @@ if ! has_cmd "$VIM"; then #fi # gui-common is required for clipboard integration - sudo add-apt-repository ppa:jonathonf/vim -y + sudo add-apt-repository ppa:jonathonf/vim -y -n pm_update sudo apt install -y vim vim-gui-common if enhance_vim; then diff --git a/devel/deeplearning.sh b/devel/deeplearning.sh index e7b64b4..5f491ae 100755 --- a/devel/deeplearning.sh +++ b/devel/deeplearning.sh @@ -19,9 +19,9 @@ case "$PM" in sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 sudo apt-key adv --fetch-keys \ https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub - sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /" - sudo apt-get update - sudo apt-get -y install cuda + sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /" -y -n + pm_update + sudo apt -y install cuda elif [ "$DISTRIB_RELEASE" = "20.04" ]; then sudo apt install nvidia-cuda-toolkit else diff --git a/env.sh b/env.sh index 372d601..e2aafc6 100755 --- a/env.sh +++ b/env.sh @@ -80,7 +80,7 @@ enhance_vim() { pm_update() { # skip updation on daily basis TSFILE=/tmp/apt_updated_at_$(date +%Y%m%d) - CHECKSUM=$(md5sum $(find /etc/apt -type f | sort)) + CHECKSUM=$(md5sum /etc/apt/sources.list /etc/apt/sources.list.d/*.list | sort | md5sum) grep -qF "$CHECKSUM" "$TSFILE" && return case "$PM" in apt) @@ -107,6 +107,13 @@ if [ "$PM" = "n/a" ]; then echo "Unsupported Package Manager" exit 1 fi +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 log "Environments" echo " PM : $PM" @@ -114,4 +121,3 @@ echo " DIR : $DIR" echo " PDIR : $PDIR" echo " PREFIX : $PREFIX" echo " GITHUB_PROXY : $GITHUB_PROXY" - diff --git a/gui/office.sh b/gui/office.sh index b9f49c8..a979a5c 100755 --- a/gui/office.sh +++ b/gui/office.sh @@ -8,10 +8,10 @@ log 'Settingup office tools: libreoffice keepassxc nextcloud chrome zathura gimp case "$PM" in apt) - sudo add-apt-repository -y ppa:libreoffice/libreoffice-7-0 - sudo add-apt-repository -y ppa:phoerious/keepassxc - sudo add-apt-repository -y ppa:nextcloud-devs/client - sudo apt update + sudo add-apt-repository -y -n ppa:libreoffice/libreoffice-7-0 + sudo add-apt-repository -y -n ppa:phoerious/keepassxc + sudo add-apt-repository -y -n ppa:nextcloud-devs/client + pm_update sudo apt install -y \ google-chrome-stable \ zathura zathura-pdf-poppler sxiv \