mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 08:46:59 +08:00
[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:
parent
c354f980bb
commit
f39193f28f
8
.zshrc2
8
.zshrc2
|
@ -88,14 +88,14 @@ alias "se"='sudo -sE'
|
|||
alias "pbd"='ping baidu.com'
|
||||
alias "p114"='ping 114.114.114.114'
|
||||
alias "p666"='ping6 2001:da8::666'
|
||||
alias "git-branches"='git for-each-ref --sort=-committerdate refs/heads refs/remotes --format="%(authordate:short) %(color:red)%(objectname:short) %(color:yellow)%(refname:short)%(color:reset) (%(color:green)%(committerdate:relative)%(color:reset)) %(authorname)"'
|
||||
sibd() { ssh -p 12022 root@$1${1:+.}ibd.ink }
|
||||
sob() { ssh -p 24022 root@$1${1:+.}ob.ac.cn }
|
||||
snasp() { ssh -o ProxyJump="ssh@nasp.ob.ac.cn:36022" dictxiong@$1 }
|
||||
case $(bash "$DOTFILES/tools/common.sh" 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
|
||||
sibd() { ssh -p 12022 root@$1${1:+.}ibd.ink }
|
||||
sob() { ssh -p 24022 root@$1${1:+.}ob.ac.cn }
|
||||
snasp() { ssh -o ProxyJump="ssh@nasp.ob.ac.cn:36022" dictxiong@$1 }
|
||||
gbes() { git for-each-ref --sort=-committerdate refs/heads refs/remotes --format="%(authordate:format:%y-%m-%d.%a %H:%M %z)|%(color:red)%(objectname:short)|%(color:yellow)%(refname:short)%(color:reset)|%(color:reset)%(authorname): %(color:green)%(subject)" --color=always | column -ts"|" | less -FX }
|
||||
piv-agent()
|
||||
{
|
||||
eval $(ssh-agent -k)
|
||||
|
|
35
install.sh
35
install.sh
|
@ -34,18 +34,18 @@ install_dependencies()
|
|||
case $(get_linux_dist) in
|
||||
"ubuntu"|"debian" )
|
||||
$SUDO apt-get update
|
||||
$SUDO apt-get install -y git zsh bash tmux vim python3 python3-pip curl inetutils-ping cmake less
|
||||
$SUDO apt-get install -y git zsh bash tmux vim python3 python3-pip curl inetutils-ping cmake less bsdmainutils
|
||||
;;
|
||||
"alpine" )
|
||||
$SUDO apk update
|
||||
$SUDO apk add zsh bash git tmux vim curl python3 py3-pip fzf iputils coreutils
|
||||
$SUDO apk add zsh bash git tmux vim curl python3 py3-pip fzf iputils coreutils util-linux
|
||||
;;
|
||||
* ) fmt_error "dfs auto-install is not implemented on linux distribution: $(get_linux_dist)"
|
||||
esac
|
||||
;;
|
||||
"macos" )
|
||||
$SUDO brew update
|
||||
$SUDO brew install git python3 zsh curl tmux vim
|
||||
$SUDO brew install git python3 zsh curl tmux vim util-linux
|
||||
;;
|
||||
"msys" )
|
||||
pacman -Syu
|
||||
|
@ -256,23 +256,16 @@ uninstall(){
|
|||
fmt_note "done uninstalling!"
|
||||
}
|
||||
|
||||
BIN=install
|
||||
ARG=""
|
||||
while [[ $# > 0 || -n "$ARG" ]]; do
|
||||
if [[ -z "$ARG" ]]; then ARG=$1 ORIGIN_ARG=$1; shift; fi
|
||||
case $ARG in
|
||||
-i* ) BIN=install ;;
|
||||
-r* ) BIN=uninstall ;;
|
||||
-q*|--quite ) export DFS_QUIET=1 ;;
|
||||
-d*|--dev ) export DFS_DEV=1 ;;
|
||||
-l*|--lite ) export DFS_LITE=1 ;;
|
||||
-a*|--auto ) install_dependencies ;;
|
||||
* ) fmt_warning "unknown command \"$ORIGIN_ARG\". available: -i, -r, -q, -d, -l, -a"; exit 1 ;;
|
||||
parse_arg "$@"
|
||||
FUNC=install
|
||||
for i in ${PARSE_ARG_RET[@]}; do
|
||||
case $i in
|
||||
-i ) FUNC=install ;;
|
||||
-r ) FUNC=uninstall ;;
|
||||
-d|--dev ) export DFS_DEV=1 ;;
|
||||
-l|--lite ) export DFS_LITE=1 ;;
|
||||
-a|--auto ) install_dependencies ;;
|
||||
* ) fmt_fatal "unknown option \"$i\". available: -i, -r, -q, -d, -l, -a" ;;
|
||||
esac
|
||||
if [[ "$ARG" == "--"* || ${#ARG} == 2 ]]; then
|
||||
ARG=""
|
||||
else
|
||||
ARG=-${ARG:2}
|
||||
fi
|
||||
done
|
||||
$BIN
|
||||
$FUNC
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user