[core] parse func; gbes; .config/dotfiles/env (#29)

* common.sh: arg parse init

* bug fix

* bug fix

* bug fix. now common.sh won't parse arg autoly

* improve git-branches

* improve git-branches; util-linux

* accelerate ci

* improve gbes; PARSE_ARG_RET

* ci: fix gbes

* ssh: add key ltp1.bd

* Revert "ssh: add key ltp1.bd"

This reverts commit c2433a0549.

* install column; apt -> apt-get

Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
This commit is contained in:
2022-11-17 20:02:35 +08:00
committed by GitHub
parent c354f980bb
commit f39193f28f
6 changed files with 53 additions and 37 deletions

View File

@@ -14,7 +14,7 @@ apk_add()
apk update
# mass installation
apk add zsh git tmux vim curl wget bash python3 py3-pip htop gcc g++ cmake make fzf perl linux-headers bind-tools iputils man-db coreutils
apk add zsh git tmux vim curl wget bash python3 py3-pip htop gcc g++ cmake make fzf perl linux-headers bind-tools iputils man-db coreutils util-linux
#for i in {fzf,ripgrep}; do apk add $i -y; done
}

View File

@@ -2,11 +2,7 @@
THIS_DIR_COMMON_SH=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
export DOTFILES=$( cd "$THIS_DIR_COMMON_SH/.." && pwd )
SUDO=''
if [[ "$EUID" != "0" && -x $(command -v sudo) ]]; then
SUDO='sudo'
fi
if [[ -f ~/.config/dotfiles/env ]]; then source ~/.config/dotfiles/env; fi
# Color settings
# Source: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
@@ -101,6 +97,31 @@ setup_color() {
}
# END of color settings
SUDO=''
if [[ "$EUID" != "0" && -x $(command -v sudo) ]]; then
SUDO='sudo'
fi
parse_arg()
{
local ARG=""
PARSE_ARG_RET=()
while [[ $# > 0 || -n "$ARG" ]]; do
if [[ -z "$ARG" ]]; then ARG=$1; shift; fi
case $ARG in
-q*|--quite ) DFS_QUIET=1 ;;
--* ) PARSE_ARG_RET+=("$ARG") ;;
-* ) PARSE_ARG_RET+=("${ARG:0:2}") ;;
* ) PARSE_ARG_RET+=("$ARG") ;;
esac
if [[ "$ARG" == "--"* || ! "$ARG" == "-"* || ${#ARG} -le 2 ]]; then
ARG=""
else
ARG=-${ARG:2}
fi
done
}
ask_for_yN()
{
while [[ -z "$DFS_QUIET" || "$DFS_QUIET" == "0" ]]; do
@@ -170,3 +191,5 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
else
setup_color
fi
unset THIS_DIR_COMMON_SH

View File

@@ -27,9 +27,9 @@ tools/common.sh get_linux_dist
# check alias
alias p114
sibd || which sibd
which sibd
piv-agent || which piv-agent
git-branches || which git-branches
gbes || which gbes
# check update
DFS_VERSION=`dfs version`

View File

@@ -13,12 +13,12 @@ set_mirror()
apt_install()
{
# basic packages
apt update
for i in {man-db,vim,ca-certificates}; do apt install $i -y; done
apt-get update
for i in {man-db,vim,ca-certificates}; do apt-get install $i -y; done
# mass installation
apt install git tmux zsh curl wget dialog net-tools dnsutils netcat traceroute sudo python3 python3-pip cron inetutils-ping openssh-client openssh-server htop gcc g++ cmake make zip less
for i in {fzf,ripgrep}; do apt install $i -y; done
apt-get install git tmux zsh curl wget dialog net-tools dnsutils netcat traceroute sudo python3 python3-pip cron inetutils-ping openssh-client openssh-server htop gcc g++ cmake make zip less bsdmainutils
for i in {fzf,ripgrep}; do apt-get install $i -y; done
}
set_timezone()