From b5ada9cb6c84b1c1aadfffdf173697824adf1535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Thu, 11 Aug 2022 21:04:52 +0800 Subject: [PATCH] Added rbash_list --- bash/bashrc/rbashrc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/bash/bashrc/rbashrc b/bash/bashrc/rbashrc index 132fd99..2fe2b5e 100644 --- a/bash/bashrc/rbashrc +++ b/bash/bashrc/rbashrc @@ -8,6 +8,9 @@ __SCRIPT=$BASH_SOURCE RBASH_HOME="$HOME/.rbash" RBASH_SOURCES="$RBASH_HOME/sources" RBASH_CONFIG="$RBASH_HOME/config" +RBASH_REMOTE="https://git.k8s.astropenguin.net" +RBASH_REPO="penguin/utils" +RBASH_PATH="bash/bashrc" # Source global definitions if [ -f /etc/bashrc ]; then @@ -107,7 +110,7 @@ function rbash_upgrade { local TMPFILE TMPFILE=$( mktemp ) - __download "https://git.k8s.astropenguin.net/penguin/utils/raw/branch/master/bash/bashrc/rbashrc" > $TMPFILE + __download "$RBASH_REMOTE/$RBASH_REPO/raw/branch/master/$RBASH_PATH/rbashrc" > $TMPFILE if [ -z "$1" ]; then MC_NAME="" @@ -142,7 +145,7 @@ function rbash_run { local f echo "Getting: $1" - f=`rbash_cache "https://git.k8s.astropenguin.net/penguin/utils/raw/branch/master/$1"` + f=`rbash_cache "$RBASH_REMOTE/$RBASH_REPO/raw/branch/master/$1"` shift "$f" "$@" @@ -152,10 +155,20 @@ function rbash_run { function rbash_load { local f path echo " $1" - f=`rbash_cache "https://git.k8s.astropenguin.net/penguin/utils/raw/branch/master/bash/bashrc/$1"` + f=`rbash_cache "$RBASH_REMOTE/$RBASH_REPO/raw/branch/master/$RBASH_PATH/$1"` source "$f" } +function rbash_list { + which jq 2>&1 > /dev/null + if [ $? -eq 0 ]; then + echo This command requires jq. + return 1 + fi + + __download "$RBASH_REMOTE/api/v1/repos/$RBASH_REPO/$RBASH_PATH/sources/" | jq -r '.[].name' +} + export PS1='This is \e[1;3m\e[0m: \w\n\$ ' export EDITOR=vim