diff --git a/cli/fish.sh b/cli/fish.sh index d8d4c47..15573d2 100755 --- a/cli/fish.sh +++ b/cli/fish.sh @@ -8,7 +8,7 @@ log 'Setting up shell' case "$PM" in apt) sudo add-apt-repository ppa:fish-shell/release-3 -y - sudo apt update + pm_update sudo apt install fish silversearcher-ag -y if [ "$DISTRIB_RELEASE_MAJOR" -gt 19 ] || [ "$DISTRIB_RELEASE" = "19.10" ]; then sudo apt install dash bat -y @@ -49,7 +49,8 @@ if has_cmd bat; then fi fi -if has_cmd dash; then +# only for local machine with gui +if [ -z "$SSH_CLIENT" ] && [ -n "$DISPLAY" ] && has_cmd dash; then log 'Setting up dash as default shell' sudo /usr/bin/ln -sfT dash /usr/bin/sh diff --git a/cli/install.sh b/cli/install.sh index edbb0b4..36efd24 100755 --- a/cli/install.sh +++ b/cli/install.sh @@ -4,10 +4,10 @@ set -e DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" -timedatectl set-ntp on +sudo timedatectl set-ntp on . "$DIR/mirrors.sh" . "$DIR/basic.sh" . "$DIR/fish.sh" . "$DIR/vim.sh" -. "$DIR/ranger.sh" . "$DIR/tmux.sh" +. "$DIR/ranger.sh" diff --git a/cli/vim.sh b/cli/vim.sh index 98a49b5..65d2d79 100755 --- a/cli/vim.sh +++ b/cli/vim.sh @@ -30,7 +30,7 @@ if ! has_cmd "$VIM"; then # gui-common is required for clipboard integration sudo add-apt-repository ppa:jonathonf/vim -y - sudo apt-get update + pm_update sudo apt install -y vim vim-gui-common if enhance_vim; then sudo pip3 install pyvim diff --git a/env.sh b/env.sh index 350f5f4..b7af577 100755 --- a/env.sh +++ b/env.sh @@ -77,6 +77,23 @@ enhance_vim() { [ "$VIM_MODE" = "enhanced" ] && has_cmd nvim } +pm_update() { + # skip updation on daily basis + TSFILE=/tmp/apt_updated_at_$(date +%Y%m%d) + CHECKSUM=$(md5sum $(find /etc/apt -type f | sort)) + grep -qF "$CHECKSUM" "$TSFILE" && return + case "$PM" in + apt) + sudo apt update + ;; + *) + echo "unsupported os" + exit 1 + ;; + esac + echo "$CHECKSUM" > "$TSFILE" +} + sudo mkdir -p $PREFIX @@ -91,10 +108,10 @@ if [ "$PM" = "n/a" ]; then exit 1 fi - log "Environments" echo " PM : $PM" echo " DIR : $DIR" echo " PDIR : $PDIR" echo " PREFIX : $PREFIX" echo " GITHUB_PROXY : $GITHUB_PROXY" +