Configs/Lib.sh

53 lines
720 B
Bash
Raw Normal View History

2023-04-14 18:47:33 +02:00
#!/bin/sh
2023-05-19 19:54:24 +02:00
ScopePath=""
SetScope(){
[ "$1" = "Root" ] && ScopePath="/"
[ "$1" = "Home" ] && ScopePath="${HOME}/"
}
2023-04-14 18:47:33 +02:00
mkcd(){
2023-05-19 19:54:24 +02:00
mkdir -vp "./$1" && \
2023-04-14 18:47:33 +02:00
cd "$1"
}
2023-04-14 22:15:31 +02:00
2023-05-21 18:54:02 +02:00
CpItem(){
[ -f "${ScopePath}$1" ] && cpfile "$1"
[ -d "${ScopePath}$1" ] && cpdir "$1"
}
CpItems(){
for p in $@
do
CpItem "$p"
done
}
CpSub(){
LBase="$1"; shift
RBase="$1"; shift
for s in $@
do
CpItems ${LBase}${s}${RBase}
done
}
CpSufx(){
Base="$1"; shift
CpSub "$Base" "" $@
}
2023-05-19 19:54:24 +02:00
cpfile(){
echo "$1"
rm -rf "./$1" && \
mkdir -p "./$1" && \
rm -rf "./$1" && \
cp --no-target-directory "${ScopePath}$1" "./$1"
}
2023-04-14 22:15:31 +02:00
cpdir(){
2023-05-19 19:54:24 +02:00
echo "$1"
mkdir -p "./$1" && \
cp --recursive --no-target-directory "${ScopePath}$1" "./$1"
2023-04-14 22:15:31 +02:00
}