mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 09:07:04 +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 "pbd"='ping baidu.com'
|
||||||
alias "p114"='ping 114.114.114.114'
|
alias "p114"='ping 114.114.114.114'
|
||||||
alias "p666"='ping6 2001:da8::666'
|
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
|
case $(bash "$DOTFILES/tools/common.sh" get_os_type) in
|
||||||
macos ) alias l='ls -lAGh -D "%y-%m-%d %H:%M"' ;;
|
macos ) alias l='ls -lAGh -D "%y-%m-%d %H:%M"' ;;
|
||||||
* ) alias l='ls -lAGh --time-style="+%y-%m-%d %H:%M"' ;;
|
* ) alias l='ls -lAGh --time-style="+%y-%m-%d %H:%M"' ;;
|
||||||
esac
|
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()
|
piv-agent()
|
||||||
{
|
{
|
||||||
eval $(ssh-agent -k)
|
eval $(ssh-agent -k)
|
||||||
|
|
35
install.sh
35
install.sh
|
@ -34,18 +34,18 @@ install_dependencies()
|
||||||
case $(get_linux_dist) in
|
case $(get_linux_dist) in
|
||||||
"ubuntu"|"debian" )
|
"ubuntu"|"debian" )
|
||||||
$SUDO apt-get update
|
$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" )
|
"alpine" )
|
||||||
$SUDO apk update
|
$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)"
|
* ) fmt_error "dfs auto-install is not implemented on linux distribution: $(get_linux_dist)"
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
"macos" )
|
"macos" )
|
||||||
$SUDO brew update
|
$SUDO brew update
|
||||||
$SUDO brew install git python3 zsh curl tmux vim
|
$SUDO brew install git python3 zsh curl tmux vim util-linux
|
||||||
;;
|
;;
|
||||||
"msys" )
|
"msys" )
|
||||||
pacman -Syu
|
pacman -Syu
|
||||||
|
@ -256,23 +256,16 @@ uninstall(){
|
||||||
fmt_note "done uninstalling!"
|
fmt_note "done uninstalling!"
|
||||||
}
|
}
|
||||||
|
|
||||||
BIN=install
|
parse_arg "$@"
|
||||||
ARG=""
|
FUNC=install
|
||||||
while [[ $# > 0 || -n "$ARG" ]]; do
|
for i in ${PARSE_ARG_RET[@]}; do
|
||||||
if [[ -z "$ARG" ]]; then ARG=$1 ORIGIN_ARG=$1; shift; fi
|
case $i in
|
||||||
case $ARG in
|
-i ) FUNC=install ;;
|
||||||
-i* ) BIN=install ;;
|
-r ) FUNC=uninstall ;;
|
||||||
-r* ) BIN=uninstall ;;
|
-d|--dev ) export DFS_DEV=1 ;;
|
||||||
-q*|--quite ) export DFS_QUIET=1 ;;
|
-l|--lite ) export DFS_LITE=1 ;;
|
||||||
-d*|--dev ) export DFS_DEV=1 ;;
|
-a|--auto ) install_dependencies ;;
|
||||||
-l*|--lite ) export DFS_LITE=1 ;;
|
* ) fmt_fatal "unknown option \"$i\". available: -i, -r, -q, -d, -l, -a" ;;
|
||||||
-a*|--auto ) install_dependencies ;;
|
|
||||||
* ) fmt_warning "unknown command \"$ORIGIN_ARG\". available: -i, -r, -q, -d, -l, -a"; exit 1 ;;
|
|
||||||
esac
|
esac
|
||||||
if [[ "$ARG" == "--"* || ${#ARG} == 2 ]]; then
|
|
||||||
ARG=""
|
|
||||||
else
|
|
||||||
ARG=-${ARG:2}
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
$BIN
|
$FUNC
|
||||||
|
|
|
@ -14,7 +14,7 @@ apk_add()
|
||||||
apk update
|
apk update
|
||||||
|
|
||||||
# mass installation
|
# 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
|
#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 )
|
THIS_DIR_COMMON_SH=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
||||||
export DOTFILES=$( cd "$THIS_DIR_COMMON_SH/.." && pwd )
|
export DOTFILES=$( cd "$THIS_DIR_COMMON_SH/.." && pwd )
|
||||||
|
if [[ -f ~/.config/dotfiles/env ]]; then source ~/.config/dotfiles/env; fi
|
||||||
SUDO=''
|
|
||||||
if [[ "$EUID" != "0" && -x $(command -v sudo) ]]; then
|
|
||||||
SUDO='sudo'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Color settings
|
# Color settings
|
||||||
# Source: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
# Source: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
||||||
|
@ -101,6 +97,31 @@ setup_color() {
|
||||||
}
|
}
|
||||||
# END of color settings
|
# 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()
|
ask_for_yN()
|
||||||
{
|
{
|
||||||
while [[ -z "$DFS_QUIET" || "$DFS_QUIET" == "0" ]]; do
|
while [[ -z "$DFS_QUIET" || "$DFS_QUIET" == "0" ]]; do
|
||||||
|
@ -170,3 +191,5 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||||
else
|
else
|
||||||
setup_color
|
setup_color
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
unset THIS_DIR_COMMON_SH
|
||||||
|
|
|
@ -27,9 +27,9 @@ tools/common.sh get_linux_dist
|
||||||
|
|
||||||
# check alias
|
# check alias
|
||||||
alias p114
|
alias p114
|
||||||
sibd || which sibd
|
which sibd
|
||||||
piv-agent || which piv-agent
|
piv-agent || which piv-agent
|
||||||
git-branches || which git-branches
|
gbes || which gbes
|
||||||
|
|
||||||
# check update
|
# check update
|
||||||
DFS_VERSION=`dfs version`
|
DFS_VERSION=`dfs version`
|
||||||
|
|
|
@ -13,12 +13,12 @@ set_mirror()
|
||||||
apt_install()
|
apt_install()
|
||||||
{
|
{
|
||||||
# basic packages
|
# basic packages
|
||||||
apt update
|
apt-get update
|
||||||
for i in {man-db,vim,ca-certificates}; do apt install $i -y; done
|
for i in {man-db,vim,ca-certificates}; do apt-get install $i -y; done
|
||||||
|
|
||||||
# mass installation
|
# 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
|
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 install $i -y; done
|
for i in {fzf,ripgrep}; do apt-get install $i -y; done
|
||||||
}
|
}
|
||||||
|
|
||||||
set_timezone()
|
set_timezone()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user