From 74e440bb70b1af7709574d20bc9f0b9db44bfe3f Mon Sep 17 00:00:00 2001 From: Dict Xiong Date: Sat, 29 Oct 2022 01:06:48 +0800 Subject: [PATCH] staged --- .zshrc2 | 8 ++++---- scripts/dogo | 3 +-- tools/alpine.sh | 9 ++++----- tools/common.sh | 20 ++++++++++---------- tools/test.zsh | 1 + tools/ubuntu.sh | 2 +- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/.zshrc2 b/.zshrc2 index d71d211..14c685c 100644 --- a/.zshrc2 +++ b/.zshrc2 @@ -1,6 +1,10 @@ +# env export TERM="xterm-256color" export LC_ALL=C.UTF-8 export LANG=C.UTF-8 +export DOTFILES=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) +export PATH="$PATH:$DOTFILES/scripts" +export LESS="-N" # antigen if [[ -z "$DFS_NO_WALL" ]]; then @@ -75,10 +79,6 @@ antigen theme ${ZSH_THEME:-$TMP_THEME} antigen apply # end of antigen config -# env -export DOTFILES=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) -export PATH=$PATH:$DOTFILES/scripts - # alias alias "pls"='sudo $(fc -ln -1)' alias "se"='sudo -sE' diff --git a/scripts/dogo b/scripts/dogo index fb071f6..0da9957 100755 --- a/scripts/dogo +++ b/scripts/dogo @@ -1,8 +1,7 @@ #!/bin/bash THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) -DOTFILES=${DOTFILES:-$( cd "$THIS_DIR/.." && pwd )} -source "$DOTFILES/tools/common.sh" +source "$THIS_DIR/../tools/common.sh" if [[ -z "$1" || "$1" =~ "-h|--help" ]]; then fmt_info "usage: dogo " diff --git a/tools/alpine.sh b/tools/alpine.sh index b2b6aa3..0a99dd5 100755 --- a/tools/alpine.sh +++ b/tools/alpine.sh @@ -4,10 +4,9 @@ set -e set_mirror() { - #MIRROR=${1:="mirrors.tuna.tsinghua.edu.cn"} - #MIRROR=${MIRROR//\//\\\/} - #sed -i 's/(archive|security).ubuntu.com/${MIRROR}/g' /etc/apt/sources.list - echo "to-do ..." + MIRROR=${1:-"mirrors.tuna.tsinghua.edu.cn"} + MIRROR=${MIRROR//\//\\\/} + sed -i "s/dl-cdn.alpinelinux.org/$MIRROR/g" /etc/apk/repositories } apk_add() @@ -32,7 +31,7 @@ router() case $1 in apk-add ) apk_add ;; set-timezone | set-tz ) set_timezone ;; - #set-mirror ) set_mirror $2 ;; + set-mirror ) set_mirror $2 ;; * ) echo unknown command "$1". available: apk-add, set-timezone;; esac } diff --git a/tools/common.sh b/tools/common.sh index 468f24f..44c9691 100755 --- a/tools/common.sh +++ b/tools/common.sh @@ -1,7 +1,7 @@ #!/bin/bash -THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) -export DOTFILES=$( cd "$THIS_DIR/.." && pwd ) +THIS_DIR_COMMON_SH=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) +export DOTFILES=$( cd "$THIS_DIR_COMMON_SH/.." && pwd ) SUDO='' if (( $EUID != 0 )); then @@ -107,7 +107,6 @@ ask_for_yN() read -p "${FMT_YELLOW}$1${FMT_RESET} [yN]: " yn case $yn in [Yy]* ) return 1;; - [Nn]* ) return 0;; * ) return 0;; esac done @@ -132,24 +131,25 @@ get_os_type() { get_linux_dist() { if [ -f /etc/os-release ]; then . /etc/os-release - ans=$ID + ans="$ID" elif type lsb_release >/dev/null 2>&1; then - ans=$(lsb_release -si) + ans="$(lsb_release -si)" elif [ -f /etc/lsb-release ]; then . /etc/lsb-release - ans=$DISTRIB_ID + ans="$DISTRIB_ID" elif [ -f /etc/debian_version ]; then - ans=Debian + ans="Debian" elif [ -f /etc/SuSe-release ]; then - ans=SUSE + ans="SUSE" elif [ -f /etc/redhat-release ]; then - ans=RedHat + ans="RedHat" else - ans=unknown + ans="unknown" fi echo $ans | tr '[:upper:]' '[:lower:]' } +# if bash-ed, else source-d if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then $1 "${@:2}" else diff --git a/tools/test.zsh b/tools/test.zsh index 7920e2e..31f6c0d 100644 --- a/tools/test.zsh +++ b/tools/test.zsh @@ -15,6 +15,7 @@ l ~ dfs version dfs log 1 l +z dogo tools/common.sh get_os_type tools/common.sh get_linux_dist diff --git a/tools/ubuntu.sh b/tools/ubuntu.sh index c3d1b92..2d75ecc 100755 --- a/tools/ubuntu.sh +++ b/tools/ubuntu.sh @@ -6,7 +6,7 @@ set_mirror() { MIRROR=${1:-"mirrors.tuna.tsinghua.edu.cn"} MIRROR=${MIRROR//\//\\\/} - sed -i 's/(archive|security).ubuntu.com/${MIRROR}/g' /etc/apt/sources.list + sed -i "s/(archive|security).ubuntu.com/${MIRROR}/g" /etc/apt/sources.list } apt_install()