From f313a6887e6e9ee80da32216a424aca2a5a99bb8 Mon Sep 17 00:00:00 2001 From: Dict Xiong Date: Thu, 25 Aug 2022 00:23:29 +0800 Subject: [PATCH] zshrc: ls multisystem fix (#10) 1. alias l according to the local os type 2. ci sync triggered by all branches --- .github/workflows/gitee_sync.yml | 5 +---- .zshrc2 | 37 +++++++++++++++++++++++++++++++- tools/alpine.sh | 6 +----- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/.github/workflows/gitee_sync.yml b/.github/workflows/gitee_sync.yml index 3c8d757..c7e0ade 100644 --- a/.github/workflows/gitee_sync.yml +++ b/.github/workflows/gitee_sync.yml @@ -1,9 +1,6 @@ name: sync repos to gitee on: - push: - branches: - - main - - dev + push: ~ schedule: - cron: 10 4 * * * workflow_dispatch: ~ diff --git a/.zshrc2 b/.zshrc2 index 22511ce..c7e852d 100644 --- a/.zshrc2 +++ b/.zshrc2 @@ -76,6 +76,38 @@ if (( $EUID != 0 )); then SUDO='sudo' fi +get_os_type() { + case "$(uname -s)" in + Darwin*) ans="MacOS";; + CYGWIN*) ans="Cygwin";; + MSYS* ) ans="MSYS";; + Linux* ) ans="Linux";; + *) ans="unknown";; + esac + echo $ans | tr '[:upper:]' '[:lower:]' +} + +get_linux_dist() { + if [ -f /etc/os-release ]; then + . /etc/os-release + ans=$ID + elif type lsb_release >/dev/null 2>&1; then + ans=$(lsb_release -si) + elif [ -f /etc/lsb-release ]; then + . /etc/lsb-release + ans=$DISTRIB_ID + elif [ -f /etc/debian_version ]; then + ans=Debian + elif [ -f /etc/SuSe-release ]; then + ans=SUSE + elif [ -f /etc/redhat-release ]; then + ans=RedHat + else + ans=unknown + fi + echo $ans | tr '[:upper:]' '[:lower:]' +} + dfs() { case $1 in @@ -117,7 +149,10 @@ alias "se"='sudo -sE' alias "pbd"='ping baidu.com' alias "p114"='ping 114.114.114.114' alias "p666"='ping6 2001:da8::666' -alias l='ls -lAGh --time-style="+%y-%m-%d %H:%M"' +case $(get_os_type) in + macos ) alias l='ls -lAGh -D "%y-%m-%d %H:%M"' ;; + * ) alias l='ls -lAGh --time-style="+%y-%m-%d %H:%M"' ;; +esac # key bindings bindkey "^b" beginning-of-line diff --git a/tools/alpine.sh b/tools/alpine.sh index 031b9bb..960abfb 100755 --- a/tools/alpine.sh +++ b/tools/alpine.sh @@ -18,12 +18,8 @@ apk_add() apk update # mass installation - apk add zsh git tmux vim curl wget bash python3 htop gcc g++ cmake make fzf perl linux-headers bind-tools iputils man-db + apk add zsh git tmux vim curl wget bash python3 htop gcc g++ cmake make fzf perl linux-headers bind-tools iputils man-db coreutils #for i in {fzf,ripgrep}; do apk add $i -y; done - - # who am i - git config --global user.email "me@beardic.cn" - git config --global user.name "Dict Xiong" } set_timezone()