improve gbes; PARSE_ARG_RET

This commit is contained in:
xiongdian.me 2022-11-17 12:06:30 +08:00
parent e95509208e
commit eabd6ac1aa
3 changed files with 9 additions and 7 deletions

View File

@ -95,7 +95,7 @@ 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 }
git-branches() { 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 --count=${1:-10} | column -ts"|" }
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)

View File

@ -258,7 +258,7 @@ uninstall(){
parse_arg "$@"
FUNC=install
for i in ${ARG_PARSED[@]}; do
for i in ${PARSE_ARG_RET[@]}; do
case $i in
-i ) FUNC=install ;;
-r ) FUNC=uninstall ;;

View File

@ -105,14 +105,14 @@ fi
parse_arg()
{
local ARG=""
ARG_PARSED=()
PARSE_ARG_RET=()
while [[ $# > 0 || -n "$ARG" ]]; do
if [[ -z "$ARG" ]]; then ARG=$1; shift; fi
case $ARG in
-q*|--quite ) export DFS_QUIET=1 ;;
--* ) ARG_PARSED+=("$ARG") ;;
-* ) ARG_PARSED+=("${ARG:0:2}") ;;
* ) ARG_PARSED+=("$ARG") ;;
-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=""
@ -191,3 +191,5 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
else
setup_color
fi
unset THIS_DIR_COMMON_SH