generated from me/template-mit
Compare commits
25 Commits
7a53a8ced6
..
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 77300f3b82 | |||
| 8041037eda | |||
| 1ea50e600e | |||
| a1898c03b5 | |||
| 2564be90a4 | |||
| e38e602d83 | |||
| 5cdb426167 | |||
| 5309a4d863 | |||
| 38d8c1fd4d | |||
| 380e64aa57 | |||
| 6f0189fd90 | |||
| 35d21e4b7a | |||
| 0473f784ce | |||
| c7099e632c | |||
| 55fa6357b3 | |||
| 4a6de24d26 | |||
| d523ae939a | |||
| 0fccd614e7 | |||
| 35a64c49a3 | |||
| af9009f1e4 | |||
| 40d6450428 | |||
| 18b4ef7a8a | |||
| c0762fb23e | |||
| 672d8d424a | |||
| b3bc6984cb |
+363
-35
@@ -9,6 +9,8 @@ export PATH="$PATH:~/bin-shared:~/.bin-shared"
|
|||||||
|
|
||||||
# PS1 Colors #
|
# PS1 Colors #
|
||||||
|
|
||||||
|
colors=`tput colors`
|
||||||
|
if (( colors >= 256 )); then
|
||||||
export PURPLE="`tput setaf 55`"
|
export PURPLE="`tput setaf 55`"
|
||||||
export ORANGE="`tput setaf 208`"
|
export ORANGE="`tput setaf 208`"
|
||||||
export GREEN="`tput setaf 34`"
|
export GREEN="`tput setaf 34`"
|
||||||
@@ -18,6 +20,28 @@ export SCARLET="`tput setaf 160`"
|
|||||||
export YELLOW="`tput setaf 226`"
|
export YELLOW="`tput setaf 226`"
|
||||||
|
|
||||||
export GRAY="`tput setaf 243`"
|
export GRAY="`tput setaf 243`"
|
||||||
|
elif (( colors == 16 )); then
|
||||||
|
export PURPLE="`tput setaf 13`"
|
||||||
|
export ORANGE="`tput setaf 11`"
|
||||||
|
export GREEN="`tput setaf 02`"
|
||||||
|
|
||||||
|
export RED="`tput setaf 09`"
|
||||||
|
export SCARLET="`tput setaf 01`"
|
||||||
|
export YELLOW="`tput setaf 11`"
|
||||||
|
|
||||||
|
export GRAY="`tput setaf 08`"
|
||||||
|
else
|
||||||
|
export PURPLE="`tput setaf 05`"
|
||||||
|
export ORANGE="`tput setaf 03`"
|
||||||
|
export GREEN="`tput setaf 02`"
|
||||||
|
|
||||||
|
export RED="`tput setaf 05`"
|
||||||
|
export SCARLET="`tput setaf 01`"
|
||||||
|
export YELLOW="`tput setaf 03`"
|
||||||
|
|
||||||
|
export GRAY="`tput setaf 07`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
export RESET="`tput sgr0`"
|
export RESET="`tput sgr0`"
|
||||||
export BOLD="`tput bold`"
|
export BOLD="`tput bold`"
|
||||||
@@ -37,14 +61,15 @@ alias l='ls '
|
|||||||
alias ll='ls -alh '
|
alias ll='ls -alh '
|
||||||
alias lh='ls -ash '
|
alias lh='ls -ash '
|
||||||
|
|
||||||
function cl {
|
function clones {
|
||||||
|
export CLONES_PATH="$HOME/Clones"
|
||||||
if [[ -d /sdcard ]]; then
|
if [[ -d /sdcard ]]; then
|
||||||
cd /sdcard/Library/Clones
|
export CLONES_PATH="/sdcard/Library/Clones"
|
||||||
else
|
|
||||||
cd $HOME/Clones
|
|
||||||
fi
|
fi
|
||||||
|
mkdir -pv "$CLONES_PATH"
|
||||||
|
cd "$CLONES_PATH"
|
||||||
}
|
}
|
||||||
alias clones="cl"
|
alias cl="clones"
|
||||||
alias cdl="cl"
|
alias cdl="cl"
|
||||||
alias cdc="cl"
|
alias cdc="cl"
|
||||||
|
|
||||||
@@ -55,6 +80,29 @@ alias lib="library"
|
|||||||
|
|
||||||
alias scan="nmap -A -p- --script=vuln "
|
alias scan="nmap -A -p- --script=vuln "
|
||||||
|
|
||||||
|
# Trash Related #
|
||||||
|
|
||||||
|
export TRASH_ROOT="/"
|
||||||
|
if [[ -d "/sdcard" ]]; then
|
||||||
|
# Android / Termux
|
||||||
|
export TRASH_ROOT="/sdcard"
|
||||||
|
else
|
||||||
|
# Desktop
|
||||||
|
export TRASH_ROOT="$HOME"
|
||||||
|
fi
|
||||||
|
export TRASH="$TRASH_ROOT/TRASH"
|
||||||
|
|
||||||
|
alias trash="cd $TRASH"
|
||||||
|
|
||||||
|
alias clean-trash="bash -c 'rm -rfv "$TRASH"/*'; clean-trashed"
|
||||||
|
alias trash-clean="clean-trash"
|
||||||
|
|
||||||
|
alias check-trash='du -h $TRASH | sort -h; find "$TRASH_ROOT" -name .Trash"*" -exec du -h {} \; -exec mv -v {} "$TRASH"/ \;'
|
||||||
|
alias trash-check="check-trash"
|
||||||
|
|
||||||
|
alias check-trashed='find "$TRASH_ROOT" -name ".trashed*" -exec du -h {} \; -exec mv -v {} "$TRASH"/ \; | sort -h'
|
||||||
|
alias clean-trashed='find "$TRASH_ROOT" -name ".trashed*" -exec du -h {} \; -delete | sort -h'
|
||||||
|
|
||||||
|
|
||||||
## Functions ##
|
## Functions ##
|
||||||
|
|
||||||
@@ -104,7 +152,7 @@ function update-shared-old {
|
|||||||
log "\n`date` - Complete!"
|
log "\n`date` - Complete!"
|
||||||
}
|
}
|
||||||
|
|
||||||
PROJECT_SHARED="$HOME/.git-env-shared"
|
export PROJECT_SHARED="$HOME/.git-env-shared"
|
||||||
function update-shared2 {
|
function update-shared2 {
|
||||||
# Refresh the local env-shared repo.
|
# Refresh the local env-shared repo.
|
||||||
if [[ -d $PROJECT_SHARED ]]; then
|
if [[ -d $PROJECT_SHARED ]]; then
|
||||||
@@ -226,20 +274,42 @@ function blog { echo -e "\n\n$1\n\n"; }
|
|||||||
|
|
||||||
function pull {
|
function pull {
|
||||||
if [[ -d .git ]]; then
|
if [[ -d .git ]]; then
|
||||||
|
echo "Recognized git project, pulling latest changes."
|
||||||
git pull --recurse-submodules
|
git pull --recurse-submodules
|
||||||
else
|
else
|
||||||
|
echo "Not a git repo, attempting to sync with SFTP server."
|
||||||
pull-clone
|
pull-clone
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function push {
|
function push {
|
||||||
if [[ -d .git ]]; then
|
if [[ -d .git ]]; then
|
||||||
git push && load-stage && load-prod
|
echo "Recognized git project, promoting branch to stage and prod."
|
||||||
|
git push && eval load-stage && eval load-prod
|
||||||
else
|
else
|
||||||
|
echo "Not a git repo, attempting to sync with SFTP server."
|
||||||
send-master
|
send-master
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function set-variable {
|
||||||
|
var="$1"
|
||||||
|
val="$2"
|
||||||
|
echo -n "export $var=\"$val\" - "
|
||||||
|
|
||||||
|
export $var="$val"
|
||||||
|
status="$?"
|
||||||
|
|
||||||
|
if [[ "$val" == "${!var}" ]]; then
|
||||||
|
echo "Success!"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Failed with status '$status', $var is '${!var}'."
|
||||||
|
return $status
|
||||||
|
}
|
||||||
|
alias set-var="set-variable "
|
||||||
|
|
||||||
# Enhance Bin Scripts #
|
# Enhance Bin Scripts #
|
||||||
|
|
||||||
# MASTER and CLONE folders.
|
# MASTER and CLONE folders.
|
||||||
@@ -283,7 +353,7 @@ function sync-all {
|
|||||||
echo -e "`date` - Done.\n"
|
echo -e "`date` - Done.\n"
|
||||||
}
|
}
|
||||||
function sync-all-loop {
|
function sync-all-loop {
|
||||||
typeset -i sleep_time
|
typeset -i sleep_time count
|
||||||
if [[ "$1" ]]; then
|
if [[ "$1" ]]; then
|
||||||
sleep_time="$1"
|
sleep_time="$1"
|
||||||
fi
|
fi
|
||||||
@@ -291,10 +361,12 @@ function sync-all-loop {
|
|||||||
sleep_time="300"
|
sleep_time="300"
|
||||||
fi
|
fi
|
||||||
log "`date` - Sleep timer set for '$sleep_time' seconds."
|
log "`date` - Sleep timer set for '$sleep_time' seconds."
|
||||||
|
count=0
|
||||||
while true; do
|
while true; do
|
||||||
sync-all
|
sync-all
|
||||||
echo -e "\n\n*** Sleeping... ***\n\n"
|
count=$(( count + 1 ))
|
||||||
sleep 300
|
echo -e "\n\n*** Sleeping for '$sleep_time' after run# '$count'! ***\n\n"
|
||||||
|
sleep $sleep_time
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,7 +404,6 @@ function sync-syncs {
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Audio #
|
# Audio #
|
||||||
|
|
||||||
# Video #
|
# Video #
|
||||||
@@ -396,26 +467,51 @@ function process-video {
|
|||||||
if [[ -z $size ]]; then
|
if [[ -z $size ]]; then
|
||||||
size="720"
|
size="720"
|
||||||
fi
|
fi
|
||||||
size="-filter:v scale=-1:$size"
|
# Lanczos is good for upscaling, but this is usually used for downscaling.
|
||||||
|
if [[ ! -z "$PV_VERTICAL_ASPECT_RATIO" ]]; then
|
||||||
|
size="-filter:v scale=$size:-1" #:flags=lanczos"
|
||||||
|
else
|
||||||
|
size="-filter:v scale=-1:$size" #:flags=lanczos"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z $passes ]]; then
|
if [[ -z $passes ]]; then
|
||||||
passes=1
|
passes=1
|
||||||
fi
|
fi
|
||||||
pass=""
|
pass=""
|
||||||
if [[ $passes != 1 ]]; then
|
if [[ $passes != 1 || ! -z "$PV_2PASS" ]]; then
|
||||||
passes=2
|
passes=2
|
||||||
pass="-pass 2"
|
pass="-pass 2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
v2=""
|
||||||
|
if [[ ! -z "$PV_V2" ]]; then
|
||||||
|
v2="-crf 18 -preset veryslow -c:a aac -ar 48000"
|
||||||
|
#-profile:v high - Letting ffmpeg use the default profile.
|
||||||
|
fi
|
||||||
|
|
||||||
|
time=""
|
||||||
|
if [[ ! -z "$PV_TIME" ]]; then
|
||||||
|
time="`which time`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
quiet="-hide_banner -loglevel level+warning"
|
||||||
|
if [[ ! -z "$PV_PROGRESS" ]]; then
|
||||||
|
quiet="-hide_banner -loglevel level+info"
|
||||||
|
fi
|
||||||
|
if [[ ! -z "$PV_VERBOSE" ]]; then
|
||||||
|
quiet="-loglevel level+verbose"
|
||||||
|
fi
|
||||||
|
|
||||||
## Main ##
|
## Main ##
|
||||||
# More information on two-pass processing with ffmpeg
|
# More information on two-pass processing with ffmpeg
|
||||||
# https://cinelerra-gg.org/download/CinelerraGG_Manual/Two_pass_Encoding_with_FFmp.html
|
# https://cinelerra-gg.org/download/CinelerraGG_Manual/Two_pass_Encoding_with_FFmp.html
|
||||||
if [[ $passes == 2 ]]; then
|
if [[ $passes == 2 ]]; then
|
||||||
set -x
|
set -x
|
||||||
ffmpeg -nostdin -hide_banner -loglevel quiet \
|
$time ffmpeg -nostdin $quiet \
|
||||||
-i "$file" $size $video $audio \
|
-i "$file" $size $video $audio \
|
||||||
-filter:a "dynaudnorm=f=33:g=65:p=0.66:m=33.3" \
|
-filter:a "dynaudnorm=f=33:g=65:p=0.66:m=33.3" \
|
||||||
-vcodec libx264 -movflags +faststart \
|
-vcodec libx264 -movflags +faststart \
|
||||||
|
$v2 \
|
||||||
-pass 1 -f mp4 /dev/null -y
|
-pass 1 -f mp4 /dev/null -y
|
||||||
status=$?
|
status=$?
|
||||||
set +x
|
set +x
|
||||||
@@ -427,10 +523,11 @@ function process-video {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
set -x &&
|
set -x &&
|
||||||
ffmpeg -nostdin -hide_banner -loglevel quiet \
|
$time ffmpeg -nostdin $quiet \
|
||||||
-i "$file" $size $video $audio \
|
-i "$file" $size $video $audio \
|
||||||
-filter:a "dynaudnorm=f=33:g=65:p=0.66:m=33.3" \
|
-filter:a "dynaudnorm=f=33:g=65:p=0.66:m=33.3" \
|
||||||
-vcodec libx264 -movflags +faststart \
|
-vcodec libx264 -movflags +faststart \
|
||||||
|
$v2 \
|
||||||
$pass "$newfile"
|
$pass "$newfile"
|
||||||
status="$?"
|
status="$?"
|
||||||
set +x
|
set +x
|
||||||
@@ -453,11 +550,127 @@ function process-video {
|
|||||||
echo "ERROR: New file not created or has a 0 size." >&2
|
echo "ERROR: New file not created or has a 0 size." >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
unset PV_VERTICAL_ASPECT_RATIO
|
||||||
|
unset PV_V2
|
||||||
|
unset PV_TIME
|
||||||
|
unset PV_PROGRESS
|
||||||
|
unset PV_VERBOSE
|
||||||
|
unset PV_2PASS
|
||||||
|
|
||||||
echo -e "\n`date` - Finished with status '$status'."
|
echo -e "\n`date` - Finished with status '$status'."
|
||||||
return $status
|
return $status
|
||||||
}
|
}
|
||||||
alias pv="process-video"
|
alias pv="process-video"
|
||||||
alias qpv="pv ./raw/YouCut*.mp4 $(basename `pwd`).mp4"
|
alias fn='basename `pwd`' # Folder Name
|
||||||
|
alias qpv='pv ./raw/YouCut*.mp4 `fn`.mp4' # Quick Process Video
|
||||||
|
|
||||||
|
alias set-pv-vertical='set-var PV_VERTICAL_ASPECT_RATIO "y" '
|
||||||
|
alias set-pv-time='set-var PV_TIME "y" '
|
||||||
|
alias set-pv-progress='set-var PV_PROGRESS "y" '
|
||||||
|
alias set-pv-verbose='set-var PV_VERBOSE "y" '
|
||||||
|
alias set-pv-2pass='set-var PV_2PASS "y" '
|
||||||
|
alias set-pv-v2='set-var PV_V2 "y" '
|
||||||
|
alias set-pv-v2='set-var PV_YIFY "y" '
|
||||||
|
|
||||||
|
alias set-pv-vert='set-pv-vertical '
|
||||||
|
alias set-pv2='set-pv-v2; set-pv-2pass; set-pv-progress '
|
||||||
|
|
||||||
|
alias pvs='set-pv-vert; pv '
|
||||||
|
alias pv2='set-pv2; pv '
|
||||||
|
|
||||||
|
alias pv2s='set-pv2; set-pv-vert; pv '
|
||||||
|
alias pvs2='pv2s '
|
||||||
|
|
||||||
|
alias qpv2='set-pv2; qpv '
|
||||||
|
|
||||||
|
# 20260713 - Attempt at compressing videos as well as done for torrented movies.
|
||||||
|
function pv-yify {
|
||||||
|
# ffmpeg -i input.mkv -c:v libx264 -crf 27 -x264-params cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all -c:a aac -ar 44100 -b:a 128k -map 0 output.mp4
|
||||||
|
input="$1"
|
||||||
|
output="$2"
|
||||||
|
ratio="$3"
|
||||||
|
audio="$4"
|
||||||
|
|
||||||
|
if [[ -z "$input" ]]; then
|
||||||
|
cat <<- EOF
|
||||||
|
Usage: pv-yify INPUT_FILE [OUTPUT_FILE] [ASPECT_RATIO]
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
- Create file raw.mp4.pv-yify.mp4 without changing aspect ratio:
|
||||||
|
$ pv-yify raw.mp4
|
||||||
|
|
||||||
|
- Compress a video and ensures it is 720p:
|
||||||
|
$ pv-yify raw.mp4 compressed.mp4 1280:720
|
||||||
|
|
||||||
|
- Compress a video ensuring that it is 720 pixels tall:
|
||||||
|
$ pv-yify raw.mp4 vertical.mp4 720:-1
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$output" ]]; then
|
||||||
|
output="$input.pv-yify.mp4"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\n`date` - Converting '$input' with YIFY-like compression to '$output'."
|
||||||
|
|
||||||
|
if [[ -f "$output" ]]; then
|
||||||
|
echo -e "\n`date` - Moving '$output' to TRASH."
|
||||||
|
mv -v "$output" ~/TRASH/
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$ratio" ]]; then
|
||||||
|
if [[ "$ratio" != *":"* ]]; then
|
||||||
|
echo "ERROR: Optional ratio parameter needs to be like '-1:720' (horizontal) or '720:-1' (vertical)".
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
size="-filter:v scale=$ratio"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$audio" ]]; then
|
||||||
|
audio="128k"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\n`date` - Starting FFMPEG...\n"
|
||||||
|
set -x
|
||||||
|
ffmpeg -i "$input" \
|
||||||
|
-hide_banner -loglevel level+warning \
|
||||||
|
-c:v libx264 -crf 27 -c:a aac -ar 44100 -b:a "$audio" -map 0 \
|
||||||
|
-x264-params cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all \
|
||||||
|
$ratio \
|
||||||
|
"$output"
|
||||||
|
set +x
|
||||||
|
echo -e "\n`date` - Finished FFMPEG."
|
||||||
|
|
||||||
|
echo -e "\n`date` - Syncing and checking file sizes."
|
||||||
|
sync
|
||||||
|
sleep 5
|
||||||
|
ls -lh "$input" "$output"
|
||||||
|
|
||||||
|
echo -e "\n`date` - Done!"
|
||||||
|
}
|
||||||
|
alias yify="pv-yify "
|
||||||
|
alias yify-pv="pv-yify "
|
||||||
|
|
||||||
|
function set-pv-all {
|
||||||
|
#set-var PV_VERTICAL_ASPECT_RATIO "y"
|
||||||
|
set-var PV_V2 "y"
|
||||||
|
set-var PV_TIME "y"
|
||||||
|
set-var PV_PROGRESS "y"
|
||||||
|
set-var PV_VERBOSE "y"
|
||||||
|
set-var PV_2PASS "y"
|
||||||
|
}
|
||||||
|
alias set-pv-everything='set-pv-all '
|
||||||
|
|
||||||
|
function unset-pv-all {
|
||||||
|
unset PV_VERTICAL_ASPECT_RATIO
|
||||||
|
unset PV_V2
|
||||||
|
unset PV_TIME
|
||||||
|
unset PV_PROGRESS
|
||||||
|
unset PV_VERBOSE
|
||||||
|
unset PV_2PASS
|
||||||
|
}
|
||||||
|
alias unset-pv-everything='unset-pv-all '
|
||||||
|
|
||||||
# Allow converting video to audio and other smaller
|
# Allow converting video to audio and other smaller
|
||||||
# tasks than what process-video is intended to do.
|
# tasks than what process-video is intended to do.
|
||||||
@@ -559,28 +772,141 @@ alias pull-audio="v2a"
|
|||||||
alias pa="v2a"
|
alias pa="v2a"
|
||||||
|
|
||||||
|
|
||||||
## Trash Related ##
|
### Web ###
|
||||||
|
|
||||||
TRASH_ROOT="/"
|
function download-website {
|
||||||
if [[ -d "/sdcard" ]]; then
|
website="$1"
|
||||||
# Android / Termux
|
if [[ -z "$website" ]]; then
|
||||||
TRASH_ROOT="/sdcard"
|
echo "ERROR: Website not provided. $website"
|
||||||
else
|
return
|
||||||
# Desktop
|
|
||||||
TRASH_ROOT="$HOME"
|
|
||||||
fi
|
fi
|
||||||
TRASH="$TRASH_ROOT/TRASH"
|
if [[ "$website" != "http"* ]]; then
|
||||||
|
website="http://$website"
|
||||||
|
fi
|
||||||
|
# https://simpleit.rocks/linux/how-to-download-a-website-with-wget-the-right-way/
|
||||||
|
# Does not simplify the links for offline usage.
|
||||||
|
# wget --wait=2 \
|
||||||
|
# --level=inf \
|
||||||
|
# --limit-rate=20K \
|
||||||
|
# --recursive \
|
||||||
|
# --page-requisites \
|
||||||
|
# --user-agent=Mozilla \
|
||||||
|
# --no-parent \
|
||||||
|
# --convert-links \
|
||||||
|
# --adjust-extension \
|
||||||
|
# --no-clobber \
|
||||||
|
# -e robots=off \
|
||||||
|
# $website &&
|
||||||
|
|
||||||
alias trash="cd $TRASH"
|
# https://www.digitalcitizen.life/how-to-download-entire-website-for-offline-viewing/
|
||||||
|
# This one is supposed to work too and is much smaller.
|
||||||
|
# wget --mirror \
|
||||||
|
# --convert-links \
|
||||||
|
# --adjust-extension \
|
||||||
|
# --page-requisites \
|
||||||
|
# --no-parent \
|
||||||
|
# $website &&
|
||||||
|
|
||||||
alias clean-trash="bash -c 'rm -rfv "$TRASH"/*'; clean-trashed"
|
# Combine the two by using mirow and removing the rate limit.
|
||||||
alias trash-clean="clean-trash"
|
wget --mirror \
|
||||||
|
--wait=2 \
|
||||||
|
--level=inf \
|
||||||
|
--recursive \
|
||||||
|
--page-requisites \
|
||||||
|
--user-agent=Mozilla \
|
||||||
|
--no-parent \
|
||||||
|
--convert-links \
|
||||||
|
--adjust-extension \
|
||||||
|
--no-clobber \
|
||||||
|
-e robots=off \
|
||||||
|
--timeout=15 \
|
||||||
|
--tries=0 \
|
||||||
|
--continue \
|
||||||
|
--waitretry=5 \
|
||||||
|
--random-wait \
|
||||||
|
$website &&
|
||||||
|
{
|
||||||
|
echo -e "\nSuccess!"
|
||||||
|
} || {
|
||||||
|
echo -e "\nERROR: Command reported a failure. (Error code '$?')"
|
||||||
|
echo "This may mean that the URL was not converted to local links."
|
||||||
|
echo "Please check the error and contents and try again if needed."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
alias website-download="download-website"
|
||||||
|
alias curl-site="download-website"
|
||||||
|
alias pull-site="download-website"
|
||||||
|
alias site-pull="download-website"
|
||||||
|
alias curl-www="download-website"
|
||||||
|
alias pull-www="download-website"
|
||||||
|
alias www-pull="download-website"
|
||||||
|
|
||||||
alias check-trash='du -h $TRASH | sort -h; find "$TRASH_ROOT" -name .Trash"*" -exec du -h {} \; -exec mv -v {} "$TRASH"/ \;'
|
function run-site {
|
||||||
alias trash-check="check-trash"
|
python3 -m http.server
|
||||||
|
}
|
||||||
|
alias run-html="run-site"
|
||||||
|
alias exec-site="run-site"
|
||||||
|
alias exec-html="run-site"
|
||||||
|
alias site-host="run-site"
|
||||||
|
alias host-site="run-site"
|
||||||
|
|
||||||
alias check-trashed='find "$TRASH_ROOT" -name ".trashed*" -exec du -h {} \; -exec mv -v {} "$TRASH"/ \; | sort -h'
|
# TBD: Move this to a different section?
|
||||||
alias clean-trashed='find "$TRASH_ROOT" -name ".trashed*" -exec du -h {} \; -delete | sort -h'
|
function git-check {
|
||||||
|
dir="`pwd`"
|
||||||
|
if [[ -n "$1" ]]; then
|
||||||
|
dir="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Checking '$dir' for git changes."
|
||||||
|
ls -d "$dir"/* | while read project; do
|
||||||
|
if [[ ! -d $project ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo -e "\n*** `basename $project` ***"
|
||||||
|
cd $project
|
||||||
|
if [[ -d .git ]]; then
|
||||||
|
git ls-remote --exit-code --heads origin dev
|
||||||
|
dev_exists="$?"
|
||||||
|
if [[ "$dev_exists" == 0 ]]; then
|
||||||
|
git switch dev
|
||||||
|
elif [[ "$dev_exists" == 2 ]]; then
|
||||||
|
git switch main
|
||||||
|
else
|
||||||
|
echo "ERROR: Unknown status for dev_exists, '$dev_exists'."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
git pull
|
||||||
|
git push
|
||||||
|
else
|
||||||
|
echo "Not a Git project, skipping!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo -e "\nDone!"
|
||||||
|
}
|
||||||
|
|
||||||
|
# TBD: Move this to a different section?
|
||||||
|
function check-colors {
|
||||||
|
min=0
|
||||||
|
max=256
|
||||||
|
unset i
|
||||||
|
echo "Current terminal supports '`tput colors`' colors."
|
||||||
|
echo "Displaying examples..."
|
||||||
|
for (( i = min; i <= max; i++ )); do
|
||||||
|
tput setaf $i
|
||||||
|
printf "%03d" "$i"
|
||||||
|
tput sgr0
|
||||||
|
if (( i < max )); then
|
||||||
|
printf " "
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
printf "\n"
|
||||||
|
}
|
||||||
|
alias color-check="check-colors"
|
||||||
|
alias show-colors="check-colors"
|
||||||
|
alias test-colors="check-colors"
|
||||||
|
alias colors="check-colors"
|
||||||
|
alias term-colors="check-colors"
|
||||||
|
alias display-colors="check-colors"
|
||||||
|
|
||||||
|
|
||||||
## Finalize ##
|
## Finalize ##
|
||||||
@@ -589,7 +915,7 @@ alias clean-trashed='find "$TRASH_ROOT" -name ".trashed*" -exec du -h {} \; -del
|
|||||||
eval "$(declare -F | grep -v _ | sed 's/-f /-fx /')"
|
eval "$(declare -F | grep -v _ | sed 's/-f /-fx /')"
|
||||||
|
|
||||||
# Run update checker in background.
|
# Run update checker in background.
|
||||||
(
|
if [[ "$USER" != "root" ]]; then
|
||||||
(
|
(
|
||||||
if [[ -d "$PROJECT_SHARED" ]]; then
|
if [[ -d "$PROJECT_SHARED" ]]; then
|
||||||
git -C "$PROJECT_SHARED" fetch >/dev/null 2>&1 \
|
git -C "$PROJECT_SHARED" fetch >/dev/null 2>&1 \
|
||||||
@@ -615,12 +941,14 @@ eval "$(declare -F | grep -v _ | sed 's/-f /-fx /')"
|
|||||||
notify-send "$title" "$message"
|
notify-send "$title" "$message"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi >> "$HOME"/Reports/env-shared.log.txt 2>&1 &
|
||||||
) >> "$HOME"/Reports/env-shared.log.txt 2>&1 &
|
|
||||||
)
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
## Complete! ##
|
## Complete! ##
|
||||||
|
|
||||||
[[ $(whoami) != "root" ]] &&
|
[[ $(whoami) != "root" ]] &&
|
||||||
echo "`date` - Shared RC Config - Complete!"
|
echo "`date` - Shared RC Config - Complete!"
|
||||||
|
|
||||||
|
export _LOADED_SHARED_RC=true
|
||||||
|
|||||||
Reference in New Issue
Block a user