commit b5ada9cb6c84b1c1aadfffdf173697824adf1535
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2022-08-11T13:04:52Z |
| subject | Added rbash_list |
commit b5ada9cb6c84b1c1aadfffdf173697824adf1535
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2022-08-11T13:04:52Z
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="<MACHINE_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 <MACHINE_NAME>\e[1;3<COLOR_CODE>m<MACHINE_COLORED_NAME>\e[0m: \w\n\$ '
export EDITOR=vim