Added rbash_list

This commit is contained in:
斟酌 鵬兄 2022-08-11 21:04:52 +08:00
parent 3574300184
commit b5ada9cb6c

View File

@ -8,6 +8,9 @@ __SCRIPT=$BASH_SOURCE
RBASH_HOME="$HOME/.rbash" RBASH_HOME="$HOME/.rbash"
RBASH_SOURCES="$RBASH_HOME/sources" RBASH_SOURCES="$RBASH_HOME/sources"
RBASH_CONFIG="$RBASH_HOME/config" RBASH_CONFIG="$RBASH_HOME/config"
RBASH_REMOTE="https://git.k8s.astropenguin.net"
RBASH_REPO="penguin/utils"
RBASH_PATH="bash/bashrc"
# Source global definitions # Source global definitions
if [ -f /etc/bashrc ]; then if [ -f /etc/bashrc ]; then
@ -107,7 +110,7 @@ function rbash_upgrade {
local TMPFILE local TMPFILE
TMPFILE=$( mktemp ) 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 if [ -z "$1" ]; then
MC_NAME="<MACHINE_NAME>" MC_NAME="<MACHINE_NAME>"
@ -142,7 +145,7 @@ function rbash_run {
local f local f
echo "Getting: $1" 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 shift
"$f" "$@" "$f" "$@"
@ -152,10 +155,20 @@ function rbash_run {
function rbash_load { function rbash_load {
local f path local f path
echo " $1" 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" 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 PS1='This is <MACHINE_NAME>\e[1;3<COLOR_CODE>m<MACHINE_COLORED_NAME>\e[0m: \w\n\$ '
export EDITOR=vim export EDITOR=vim