Rename my-scripts folder to scripts

This commit is contained in:
Matheus Albino
2023-11-06 03:16:17 -03:00
parent 09ea15eed7
commit abd9414b9f
21 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
#!/bin/bash
my_timers_dir=${HOME}/repos/personal-devboot/my-scripts/arch/timers
system_timers_dir=/etc/systemd/system/
createSymLink() {
link_from=$1
link_to=$2
sudo ln --symbolic --force ${link_from} ${link_to}
}
startTimer() {
timer_name=$1
sudo systemctl enable ${timer_name}
sudo systemctl start ${timer_name}
}
timers_files=($(find ~+ -type f -name '*.timer'))
services_files=($(find ~+ -type f -name '*.service'))
for timer_file in ${timers_files[@]}; do
createSymLink ${timer_file} ${system_timers_dir}
# startTimer "$(basename ${timer_file})"
done
for service_file in ${services_files[@]}; do
createSymLink ${service_file} ${system_timers_dir}
# startTimer "$(basename ${service_file})"
done

View File

@@ -0,0 +1,6 @@
[Unit]
Description=Run rclone-syncs.sh
[Service]
ExecStart=rclone-syncs.sh

View File

@@ -0,0 +1,10 @@
[Unit]
Description=Run rclone-syncs.sh every 10 minutes
[Timer]
OnBootSec=5min
OnUnitActiveSec=10min
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,30 @@
#!/bin/bash
# Output file to store the results
output_file="grep_results.txt"
# Initialize or clear the output file
> $output_file
# Get the list of remote branches
git fetch --all
branches=$(git ls-remote --heads origin | awk -F/ '{for(i=3; i<=NF; i++) printf "%s%s", $i, (i<NF ? "/" : ORS)}')
# Iterate over the branches and grep for "_ID_BUILD_TYPE" in "Jenkinsfile"
for branch in $branches; do
git checkout "$branch"
if [ -f "Jenkinsfile" ]; then
if grep -q "_ID_BUILD_TYPE" "Jenkinsfile"; then
echo "Branch: $branch - Found '_ID_BUILD_TYPE'" >> $output_file
fi
fi
done
# Switch back to the original branch
git checkout -
# Display the results
cat $output_file
# Clean up the output file
rm $output_file

View File

@@ -0,0 +1,3 @@
# https://github.com/lextm/windowsterminal-shell.git
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; .\install.ps1 mini

View File

@@ -0,0 +1,12 @@
Windows Registry Editor Version 5.00
; Remove Create a new video
[HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellCreateVideo]
"ProgrammaticAccessOnly"=""
[HKEY_CLASSES_ROOT\AppXk0g4vb8gvt7b93tg50ybcy892pge6jmt\Shell\ShellCreateVideo]
"ProgrammaticAccessOnly"=""
; Remove Edit with Photos
[HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellEdit]
"ProgrammaticAccessOnly"=""

View File

@@ -0,0 +1,14 @@
Windows Registry Editor Version 5.00
; Remove Edit with Paint 3D
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.3mf\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.bmp\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.fbx\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.gif\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.jfif\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.jpe\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.jpeg\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.jpg\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.png\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.tif\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.tiff\Shell\3D Edit]

View File

@@ -0,0 +1,4 @@
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit\command]
@="\"%systemroot%\\system32\\mspaint.exe\" \"%1\""

View File

@@ -0,0 +1,4 @@
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit\command]
@="\"C:\\Program Files\\paint.net\\PaintDotNet.exe\" \"%1\""

View File

@@ -0,0 +1,107 @@
https://forums.mydigitallife.net/threads/windows-11-tweaks-fixes-and-modifications-overview.83744/page-44
Windows Registry Editor Version 5.00
; Remove Turn on BitLocker
[HKEY_CLASSES_ROOT\Drive\shell\encrypt-bde]
"LegacyDisable"=""
[HKEY_CLASSES_ROOT\Drive\shell\encrypt-bde-elev]
"LegacyDisable"=""
; Remove Give access to
[-HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\Sharing]
[-HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers\Sharing]
[-HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\Sharing]
[-HKEY_CLASSES_ROOT\Directory\shellex\CopyHookHandlers\Sharing]
[-HKEY_CLASSES_ROOT\Directory\shellex\PropertySheetHandlers\Sharing]
[-HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers\Sharing]
[-HKEY_CLASSES_ROOT\Drive\shellex\PropertySheetHandlers\Sharing]
[-HKEY_CLASSES_ROOT\LibraryFolder\background\shellex\ContextMenuHandlers\Sharing]
[-HKEY_CLASSES_ROOT\UserLibraryFolder\shellex\ContextMenuHandlers\Sharing]
; Remove Pin to Start
[-HKEY_CLASSES_ROOT\Folder\shellex\ContextMenuHandlers\PintoStartScreen]
[-HKEY_CLASSES_ROOT\exefile\shellex\ContextMenuHandlers\PintoStartScreen]
[-HKEY_CLASSES_ROOT\Microsoft.Website\ShellEx\ContextMenuHandlers\PintoStartScreen]
[-HKEY_CLASSES_ROOT\mscfile\shellex\ContextMenuHandlers\PintoStartScreen]
[-HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\{a2a9545d-a0c2-42b4-9708-a0b2badd77c8}]
; Remove Pin to Quick access
[-HKEY_CLASSES_ROOT\Folder\shell\pintohome]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\pintohome]
; Remove Include in library
[-HKEY_CLASSES_ROOT\Folder\ShellEx\ContextMenuHandlers\Library Location]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\ShellEx\ContextMenuHandlers\Library Location]
; Remove Share
[-HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\ModernSharing]
[-HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\ModernSharing]
; Remove Restore previous versions from Properties tab
[-HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\PropertySheetHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}]
[-HKEY_CLASSES_ROOT\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}\shellex\PropertySheetHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}]
[-HKEY_CLASSES_ROOT\Directory\shellex\PropertySheetHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}]
[-HKEY_CLASSES_ROOT\Drive\shellex\PropertySheetHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}]
; Remove Restore previous versions from context menu
[-HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}]
[-HKEY_CLASSES_ROOT\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}]
[-HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}]
[-HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}]
; Remove Restore previous versions from any policies
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
"NoPreviousVersionsPage"=-
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer]
"NoPreviousVersionsPage"=-
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\PreviousVersions]
"DisableLocalPage"=-
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
"NoPreviousVersionsPage"=-
[HKEY_CURRENT_USER\Software\Policies\Microsoft\PreviousVersions]
"DisableLocalPage"=-
; Remove Cast to Device
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked]
"{7AD84985-87B4-4a16-BE58-8B72A5B390F7}"="Play to Menu"
; Remove New .rtf .zip
[-HKEY_CLASSES_ROOT\.rtf\ShellNew]
[-HKEY_CLASSES_ROOT\.zip\CompressedFolder\ShellNew]
; Remove Troubleshoot Compatibility
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked]
"{1d27f844-3a1f-4410-85ac-14651078412d}"=""
; Remove Edit with Paint 3D
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.3mf\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.bmp\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.fbx\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.gif\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.jfif\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.jpe\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.jpeg\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.jpg\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.png\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.tif\Shell\3D Edit]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.tiff\Shell\3D Edit]
; Remove Create a new video
[HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellCreateVideo]
"ProgrammaticAccessOnly"=""
[HKEY_CLASSES_ROOT\AppXk0g4vb8gvt7b93tg50ybcy892pge6jmt\Shell\ShellCreateVideo]
"ProgrammaticAccessOnly"=""
; Remove Edit with Photos
[HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellEdit]
"ProgrammaticAccessOnly"=""
; Remove Burn disc image
[-HKEY_CLASSES_ROOT\Windows.IsoFile\shell\burn]

View File

@@ -0,0 +1,48 @@
#!/bin/bash
check_command_availability() {
if ! command -v "$1" &> /dev/null; then
echo "Error: '$1' command not found. Please install $1."
exit 1
fi
}
if [ -z "$1" ]; then
echo "Usage: $0 <image> [-s] [-o <output_file>]"
exit 1
fi
IMAGE="$1"
SORT_FLAG=""
OUTPUT_FILE=""
while [ "$#" -gt 0 ]; do
case "$1" in
-s) SORT_FLAG="-s"; shift ;;
-o) OUTPUT_FILE="$2"; shift 2 ;;
*) shift ;;
esac
done
# Check command availability
check_command_availability skopeo
check_command_availability jq
# Store the result of skopeo command
skopeo_result=$(skopeo inspect docker://docker.io/${IMAGE} | jq -r '.RepoTags[]')
# Determine if sorting is needed
sort_command="cat"
if [ "$SORT_FLAG" = "-s" ]; then
sort_command="sort"
fi
# Pipe the result through the sort command (conditionally)
sorted_result=$(echo "$skopeo_result" | $sort_command)
# Determine if output file is needed
if [ -z "$OUTPUT_FILE" ]; then
echo "$sorted_result"
else
echo "$sorted_result" > "$OUTPUT_FILE"
fi

View File

@@ -0,0 +1,10 @@
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <input_file>"
exit 1
fi
input_file="$1"
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 "$input_file"

128
scripts/shell/ffmpeg-helper.sh Executable file
View File

@@ -0,0 +1,128 @@
#!/bin/bash
show_help() {
echo "Usage: $0 [--input|-i input_file] [--crop|-c width:height] [--trim-start start] [--trim-end end] [--crf crf_value] [--fps new_fps] [--scale640] [--merge-audio] [--remove-audio] --output|-o output_file"
echo "Options:"
echo " --input|-i Specify the input video file (required)."
echo " --crop|-c Specify the width:height for video cropping."
echo " --trim-start Specify the start timestamp for video trimming."
echo " --trim-end Specify the end timestamp for video trimming."
echo " --crf Specify the CRF value for video compressing."
echo " --fps Specify the new frames per second for the video."
echo " --scale640 Scale the video to 640x320."
echo " --merge-audio Merge all audio tracks into the main track."
echo " --remove-audio Suppress all audio and remove audio tracks."
echo " --output|-o Specify the output filename (required)."
}
remove_audio() {
input_file="$1"
output_file="$2"
ffmpeg -i "$input_file" -an "$output_file"
}
if ! command -v ffmpeg &> /dev/null; then
echo "Error: 'ffmpeg' command not found. Please install ffmpeg."
exit 1
fi
input_file=""
crop=""
trim_start=""
trim_end=""
crf=""
new_fps=""
scale640=false
merge_audio=false
remove_audio=false
output_file=""
while [ "$#" -gt 0 ]; do
case "$1" in
--help|-h) show_help; exit ;;
--input|-i) input_file="$2"; shift 2 ;;
--crop|-c) crop="$2"; shift 2 ;;
--trim-start) trim_start="$2"; shift 2 ;;
--trim-end) trim_end="$2"; shift 2 ;;
--crf) crf="$2"; shift 2 ;;
--fps) new_fps="$2"; shift 2 ;;
--scale640) scale640=true; shift ;;
--merge-audio) merge_audio=true; shift ;;
--remove-audio) remove_audio=true; shift;;
--output|-o) output_file="$2"; shift 2 ;;
*) shift ;;
esac
done
if [ -z "$input_file" ]; then
echo "Error: Input filename (--input or -i) is required."
exit 1
fi
if [ -z "$output_file" ]; then
echo "Error: Output filename (--output or -o) is required."
exit 1
fi
if [ -z "$crop" ] && [ -z "$trim_start" ] && [ -z "$trim_end" ] && [ -z "$crf" ] && [ -z "$new_fps" ] && [ "$merge_audio" = false ] && [ "$scale640" = false ] && [ "$remove_audio" = false ]; then
echo "Error: At least one optional parameter is required."
exit 1
fi
if [ -n "$trim_start" ] && [ -z "$trim_end" ]; then
echo "Error: If using --trim-start, you must also specify --trim-end."
exit 1
fi
if [ -n "$trim_end" ] && [ -z "$trim_start" ]; then
echo "Error: If using --trim-end, you must also specify --trim-start."
exit 1
fi
if [ -n "$crop" ] && [ "$scale640" = true ]; then
echo "Error: Cannot use both --crop and --scale640 together."
exit 1
fi
if [ "$merge_audio" = true ] && [ "$remove_audio" = true ]; then
echo "Error: Cannot use both --merge-audio and --remove-audio together."
exit 1
fi
ffmpeg_command="ffmpeg -i \"$input_file\""
if [ "$remove_audio" = true ]; then
ffmpeg_command+=" -an"
fi
if [ -n "$crop" ]; then
ffmpeg_command+=" -vf crop=$crop"
fi
if [ -n "$trim_start" ] && [ -n "$trim_end" ]; then
ffmpeg_command+=" -ss $trim_start -to $trim_end"
fi
if [ -n "$crf" ]; then
ffmpeg_command+=" -c:v libx264 -crf $crf"
fi
if [ -n "$new_fps" ]; then
ffmpeg_command+=" -r $new_fps"
fi
if [ "$scale640" = true ]; then
ffmpeg_command+=" -vf scale=640:320"
fi
if [ "$merge_audio" = true ]; then
num_audio_streams=$(ffprobe -loglevel error -select_streams a -show_entries stream=codec_type -of csv=p=0 "$input_file" | wc -l)
ffmpeg_command+=" -filter_complex amerge=inputs=$num_audio_streams"
fi
ffmpeg_command+=" \"$output_file\""
echo "Running ffmpeg command:"
echo "$ffmpeg_command"
eval "$ffmpeg_command"

View File

@@ -0,0 +1,47 @@
#!/bin/bash
# Initialize variables for output files
success_log="success_log.txt"
failure_log="failure_log.txt"
# Parse command line arguments
while getopts "f:c:" opt; do
case $opt in
f)
queue_file="$OPTARG"
;;
c)
command="$OPTARG"
;;
\?)
echo "Usage: $0 -f <queue_file> -c <command>"
exit 1
;;
esac
done
# Check if both parameters are provided
if [ -z "$queue_file" ] || [ -z "$command" ]; then
echo "Usage: $0 -f <queue_file> -c <command>"
exit 1
fi
# Check if the queue file exists
if [ ! -f "$queue_file" ]; then
echo "Queue file not found: $queue_file"
exit 1
fi
# Process the queue
while IFS= read -r line; do
# Execute the command with the line as an argument
$command "$line"
# Check the exit status of the command
if [ $? -eq 0 ]; then
echo "Command: $command $line - SUCCESS" >> "$success_log"
else
echo "Command: $command $line - FAILURE" >> "$failure_log"
fi
done < "$queue_file"
echo "Script completed. Successful commands logged in $success_log. Failed commands logged in $failure_log."

View File

@@ -0,0 +1 @@
gallery-dl -o conversations=1 --filter "author['name']==locals().get('reply_to')" $1

View File

@@ -0,0 +1,76 @@
#!/bin/bash
# Step 1: Get HTML content of the page
html_content=$(curl -s https://zaiste.net/posts/shell-commands-rust/)
# Step 2: Extract href attribute values of "GitHub" links
github_links=$(echo "$html_content" | grep -oE '<a [^>]+>GitHub<\/a>' | grep -oE 'href="[^"]+"' | sed 's/href="//;s/"$//')
# Step 3: Transform URLs
transformed_urls=()
for link in $github_links; do
if [[ "$link" != *"github"* ]]; then
continue
fi
transformed_url=$(echo "$link" | sed 's/github.com/raw.githubusercontent.com/;s#/$##')
transformed_urls+=("$transformed_url/master/Cargo.toml")
done
echo "Transformed URLs:"
for url in "${transformed_urls[@]}"; do
echo "$url"
done
# Step 4: Test URLs and gather results
existing_urls=()
non_existing_urls=()
for url in "${transformed_urls[@]}"; do
response=$(curl -s --head -w %{http_code} "$url" -o /dev/null)
if [ "$response" -eq 200 ]; then
existing_urls+=("$url")
else
non_existing_urls+=("$url")
fi
done
# Step 5 and 6: Search for "name" property and categorize URLs
successful_search=()
unsuccessful_search=()
for url in "${existing_urls[@]}"; do
html_content=$(curl -s "$url")
if grep -qE "\[package\]" <<< "$html_content"; then
# name_line=$(grep -A 1 "\[package\]" <<< "$html_content" | grep -E '^name = "[^"]+"' | sed 's/name = "//;s/"$//')
name_line=$(awk -F'"' '/^\[package\]/ { in_package = 1 } in_package && /name =/ { print $2; exit }' <<< "$html_content")
echo "name_line: ${name_line}"
if [[ "$name_line" != "[package]" ]]; then
successful_search+=("$url $name_line")
else
unsuccessful_search+=("$url")
fi
fi
done
# Step 7: Print results
echo -e "\n\n\nExisting URLs:"
for url in "${existing_urls[@]}"; do
echo "$url"
done
echo -e "\n\n\nNon-existing URLs:"
for url in "${non_existing_urls[@]}"; do
echo "$url"
done
# echo -e "\n\n\nSuccessful search for 'name' property:"
echo -ne "\n\n\ncargo install"
for result in "${successful_search[@]}"; do
# url=$(echo "$result" | cut -d' ' -f1)
name=$(echo "$result" | cut -d' ' -f2)
echo -n " $name"
done
# echo -e "\n\n\nUnsuccessful search for 'name' property:"
# for url in "${unsuccessful_search[@]}"; do
# echo "$url"
# done

13
scripts/shell/klogs.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
#
# Check if an argument was provided
if [ $# -eq 0 ]; then
echo "Usage: ./script.sh <deployment-name>"
exit 1
fi
# Get the deployment name from the first argument
deployment_name=$1
# Run the kubectl command
kubectl -n$K_DEFAULT_NAMESPACE logs --selector app.kubernetes.io/instance=$deployment_name --follow

9
scripts/shell/rclone-syncs.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
SYNCS_PATH=/mnt/e/Windows/Documents/Sync
rclone sync -P google-drive-zakdragonbites: $SYNCS_PATH/google-drive
rclone sync -P $SYNCS_PATH/google-drive google-drive-zakdragonbites:
# rclone sync -P $SYNCS_PATH/nextcloud-renner nextcloud-renner:
# rclone sync -P nextcloud-renner: $SYNCS_PATH/nextcloud-renner

12
scripts/shell/run-docker-wsl.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
# docker
DOCKER_DISTRO="Arch"
DOCKER_DIR=/mnt/wsl/shared-docker
DOCKER_SOCK="$DOCKER_DIR/docker.sock"
export DOCKER_HOST="unix://$DOCKER_SOCK"
# if [ ! -S "$DOCKER_SOCK" ]; then
# mkdir -pm o=,ug=rwx "$DOCKER_DIR"
# chgrp docker "$DOCKER_DIR"
# /mnt/c/Windows/System32/wsl.exe -d $DOCKER_DISTRO sh -c "nohup sudo -b dockerd < /dev/null > $DOCKER_DIR/dockerd.log 2>&1"
# fi

40
scripts/shell/swatch.sh Executable file
View File

@@ -0,0 +1,40 @@
# https://gist.github.com/ablacklama/550420c597f9599cf804d57dd6aad131
swatch_usage() {
cat <<EOF >&2
NAME
swatch - execute a program periodically with "watch". Supports aliases.
SYNOPSIS
swatch [options] command
OPTIONS
-n, --interval seconds (default: 1)
Specify update interval. The command will not allow quicker than
0.1 second interval.
EOF
}
if [ $# -eq 0 ]; then
swatch_usage
return 1
fi
seconds=1
case "$1" in
-n)
seconds="$2"
args=${*:3}
;;
-h)
swatch_usage
return 1
;;
*)
seconds=1
args=${*:1}
;;
esac
watch --color -n "$seconds" --exec bash -ic "$args || true"

46
scripts/shell/swatchz.sh Executable file
View File

@@ -0,0 +1,46 @@
swatch_usage() {
cat <<EOF >&2
NAME
swatch - execute a program periodically with "watch". Supports aliases.
SYNOPSIS
swatch [options] command
OPTIONS
-n, --interval seconds (default: 1)
Specify update interval. The command will not allow quicker than
0.1 second interval.
EOF
}
if [ $# -eq 0 ]; then
swatch_usage
exit 1
fi
seconds=1
shell="$SHELL"
while [ $# -gt 0 ]; do
case "$1" in
-n)
seconds="$2"
args="${@:3}"
shift 3
;;
-h)
swatch_usage
exit 1
;;
*)
args="${@:1}"
break
;;
esac
done
# Get the base name of the shell executable
shell_basename=$(basename "$shell")
watch --color -n "$seconds" --exec "$shell" -ic "$args || true"