Compare commits

2 Commits

Author SHA1 Message Date
1be4719212 Update aliases 2025-12-29 22:40:08 -05:00
28b3c390f5 Improve the aws deep glacier restore scripts 2025-12-29 22:39:57 -05:00
23 changed files with 96 additions and 240 deletions

View File

@@ -41,7 +41,7 @@ reload() {
} }
update-shell() { update-shell() {
if [[ ${platform,,} == *'ming'* ]]; then if [[ '${platform,,}' == *'ming'* ]]; then
pacman -Syu pacman -Syu
printf "\n${BOLD}${YELLOW}Close this shell, open a new one, and then run 'pacman -Su'${NORMAL}\n" printf "\n${BOLD}${YELLOW}Close this shell, open a new one, and then run 'pacman -Su'${NORMAL}\n"
fi fi
@@ -148,30 +148,6 @@ remove_extra_spaces() {
echo "$ret" echo "$ret"
} }
flash_taskbar() {
if [[ ${platform,,} == *'ming'* ]]; then
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "
\$h = (Get-Process mintty -EA SilentlyContinue | ? MainWindowHandle | select -First 1).MainWindowHandle
if (-not \$h) { exit }
Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices;
public static class F {
[StructLayout(LayoutKind.Sequential)] public struct I { public uint cb; public IntPtr h; public uint f; public uint c; public uint t; }
[DllImport(\"user32.dll\")] public static extern bool FlashWindowEx(ref I i);
}'
\$i = New-Object F+I
\$i.cb = [Runtime.InteropServices.Marshal]::SizeOf(\$i)
\$i.h = [IntPtr]\$h
\$i.f = 2 -bor 12
\$i.c = 0
\$i.t = 0
[F]::FlashWindowEx([ref]\$i) | Out-Null
"
else
echo "flash_taskbar not implemented for this platform"
fi
}
################## ##################
# Building code # Building code
################## ##################
@@ -222,7 +198,7 @@ if [[ $platform == 'Darwin' ]]; then
alias trash='rmtrash' alias trash='rmtrash'
alias tt='rmtrash' alias tt='rmtrash'
elif [[ ${platform,,} == *'ming'* ]]; then # convert to lowercase then compare with wildcard elif [[ "${platform,,}" == *'ming'* ]]; then # convert to lowercase then compare with wildcard
#alias rm='echo "use trash command instead!"' #alias rm='echo "use trash command instead!"'
#alias rmr='echo "use trash command instead!"' #alias rmr='echo "use trash command instead!"'
alias trash='remove_windows_file' alias trash='remove_windows_file'
@@ -250,19 +226,17 @@ mkcd() {
alias aliases='vim ~/.aliases' alias aliases='vim ~/.aliases'
alias al='aliases' alias al='aliases'
if [[ ${platform,,} == *'ming'* ]]; then if [[ "${platform,,}" == *'ming'* ]]; then
_checksum() { _checksum() {
local algo="$1" local algo="$1"
local file="$2" local file="$2"
certutil -hashfile "$file" $algo certutil -hashfile $file $algo
} }
alias checksum='certutil -hashfile' alias checksum='certutil -hashfile'
alias checksum-md5='_checksum MD5'
# I use delegating to certutil via _checksum() but these programs are faster. alias checksum-sha1='_checksum SHA1'
alias checksum-md5='md5sum.exe' alias checksum-sha256='_checksum SHA256'
alias checksum-sha1='sha1sum.exe' alias checksum-sha512='_checksum SHA512'
alias checksum-sha256='sha256sum.exe'
alias checksum-sha512='sha512sum.exe'
fi fi
check_signature() { check_signature() {
@@ -303,7 +277,7 @@ dos2unix_all() {
} }
alias d2u='dos2unix_all' alias d2u='dos2unix_all'
alias e='open_explorer' alias e='open_filepilot'
alias f='fg' alias f='fg'
alias hist='history' alias hist='history'
alias histroy='history' alias histroy='history'
@@ -436,7 +410,6 @@ function my_transcribe_video() {
else else
transcribe-video "$file" "$output" $start_time $end_time tiny base transcribe-video "$file" "$output" $start_time $end_time tiny base
fi fi
flash_taskbar
} }
function my_transcribe_video_all_models() { function my_transcribe_video_all_models() {
@@ -458,7 +431,6 @@ function my_transcribe_video_all_models() {
if [[ $end_time == "" ]]; then end_time="0"; fi if [[ $end_time == "" ]]; then end_time="0"; fi
transcribe-video "$file" "$output" $start_time $end_time tiny base small medium transcribe-video "$file" "$output" $start_time $end_time tiny base small medium
flash_taskbar
} }
@@ -535,7 +507,6 @@ download_youtube_vid() {
if [[ $make_folder == "1" ]]; then cd ..; fi if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
@@ -582,7 +553,6 @@ download_youtube_playlist() {
cd .. cd ..
printf "${BOLD}Finished downloading the playlist\n${NORMAL}" printf "${BOLD}Finished downloading the playlist\n${NORMAL}"
flash_taskbar
} }
download_youtube_playlist_list() { download_youtube_playlist_list() {
@@ -602,7 +572,6 @@ download_youtube_playlist_list() {
eval $cmd 1>"${output_name}.txt" # Need to eval in order to preserve the quotes wrapping the filename format string. eval $cmd 1>"${output_name}.txt" # Need to eval in order to preserve the quotes wrapping the filename format string.
printf "${BOLD}Finished downloading the playlist video list\n${NORMAL}" printf "${BOLD}Finished downloading the playlist video list\n${NORMAL}"
flash_taskbar
} }
download_youtube_uploads_list() { download_youtube_uploads_list() {
@@ -631,7 +600,6 @@ download_youtube_uploads_list() {
eval $cmd 1>"${output_name}.txt" # Need to eval in order to preserve the quotes wrapping the filename format string. eval $cmd 1>"${output_name}.txt" # Need to eval in order to preserve the quotes wrapping the filename format string.
printf "${BOLD}Finished downloading the upload list\n${NORMAL}" printf "${BOLD}Finished downloading the upload list\n${NORMAL}"
flash_taskbar
} }
function download_youtube_audio() { function download_youtube_audio() {
@@ -676,7 +644,6 @@ function download_youtube_audio() {
if [[ $make_folder == "1" ]]; then cd ..; fi if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
# Download Twitch chat transcript # Download Twitch chat transcript
@@ -730,13 +697,9 @@ download_twitch_chat() {
# To extract a portion of a video, you have to first download the entire file and then use the # To extract a portion of a video, you have to first download the entire file and then use the
# `trim-video` or `compress-video' with a time range. # `trim-video` or `compress-video' with a time range.
# #
# To download a partial stream use one of these commands. We need to reencode to remove extra frames from the start/end with a negative timeline. # To download a portion of a stream:
# #
# This reencodes during the download, slightly faster than the next option: # yt-dlp -f "b" --external-downloader ffmpeg --external-downloader-args "ffmpeg_i:-ss 5:25:38.00 -to 5:56:50.00" URL
# yt-dlp -f "b" --external-downloader ffmpeg --external-downloader-args "ffmpeg_i:-ss 0:7:10.00 -to 0:8:06.00" --external-downloader-args "ffmpeg_o:-c:v libx264 -c:a aac" URL
#
# Download then re-encode:
# yt-dlp -f "b" --external-downloader ffmpeg --external-downloader-args "ffmpeg_i:-ss 5:25:38.00 -to 5:56:50.00" URL -o temp.mp4 ; trim-video-cpu temp.mp4 "FINAL_NAME" 0
# #
download_twitch_vid() { download_twitch_vid() {
local format="$1" local format="$1"
@@ -847,7 +810,6 @@ download_twitch_vid() {
if [[ $make_folder == "1" ]]; then cd ..; fi if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
# Download Vimeo videos. # Download Vimeo videos.
@@ -934,7 +896,6 @@ download_vimeo_vid() {
if [[ $make_folder == "1" ]]; then cd ..; fi if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
# Download Twitter videos. # Download Twitter videos.
@@ -1003,12 +964,9 @@ download_twitter_vid() {
if [[ $make_folder == "1" ]]; then cd ..; fi if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
# Download Instagram videos. # Download Instagram videos.
# If the download fails because you need to be authenticated then don't use the cookies arg because IG will flag your
# account as a bot and might ban you. Instead, use the instagram download code from private dotfiles.
download_instagram_vid() { download_instagram_vid() {
local transcribe="$1" local transcribe="$1"
local make_folder="$2" local make_folder="$2"
@@ -1077,7 +1035,6 @@ download_instagram_vid() {
if [[ $make_folder == "1" ]]; then cd ..; fi if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
# Download MP4 video. # Download MP4 video.
@@ -1101,7 +1058,6 @@ download_mp4() {
fi fi
mv $temp_name "$filename.mp4" mv $temp_name "$filename.mp4"
flash_taskbar
} }
# Download a stream to mp4. Can be from an m3u8 file, an mpd, etc. Whatever the # Download a stream to mp4. Can be from an m3u8 file, an mpd, etc. Whatever the
@@ -1138,7 +1094,6 @@ download_mp4_from_stream() {
fi fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
# Same notes from above regarding cookies/headers. # Same notes from above regarding cookies/headers.
@@ -1160,7 +1115,6 @@ download_aac_from_stream() {
fi fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
@@ -1184,8 +1138,8 @@ alias yt-1440-shortname='download_youtube_vid "620+234" $SHORTNAME_OFF $TRANSC
alias yt-1080p='download_youtube_vid "616+234" $SHORTNAME_OFF $TRANSCRIBE_OFF' alias yt-1080p='download_youtube_vid "616+234" $SHORTNAME_OFF $TRANSCRIBE_OFF'
alias yt-1080p-shortname='download_youtube_vid "616+234" $SHORTNAME_ON $TRANSCRIBE_OFF' alias yt-1080p-shortname='download_youtube_vid "616+234" $SHORTNAME_ON $TRANSCRIBE_OFF'
# Normal # Normal
alias yt-1080='download_youtube_vid "137+ba[ext=m4a]" $SHORTNAME_OFF $TRANSCRIBE_OFF' alias yt-1080='download_youtube_vid "270+234" $SHORTNAME_OFF $TRANSCRIBE_OFF'
alias yt-1080-shortname='download_youtube_vid "137+ba[ext=m4a]" $SHORTNAME_ON $TRANSCRIBE_OFF' alias yt-1080-shortname='download_youtube_vid "270+234" $SHORTNAME_ON $TRANSCRIBE_OFF'
alias yt-720='download_youtube_vid "136+234" $SHORTNAME_OFF $TRANSCRIBE_OFF' alias yt-720='download_youtube_vid "136+234" $SHORTNAME_OFF $TRANSCRIBE_OFF'
alias yt-720-shortname='download_youtube_vid "136+234" $SHORTNAME_ON $TRANSCRIBE_OFF' alias yt-720-shortname='download_youtube_vid "136+234" $SHORTNAME_ON $TRANSCRIBE_OFF'
@@ -1331,13 +1285,11 @@ alias tv='echo can just do a cv with a time range...' #trim-video-vbr'
function compress_and_normalize_volume() { function compress_and_normalize_volume() {
local final_name="$1" local final_name="$1"
shift 1
local opts="$@"
if [[ $final_name == "" ]]; then if [[ $final_name == "" ]]; then
error "Provide a final file name and optional args for compress-video" error "Provide a final file name"
return return
fi fi
compress-video f.mp4 ff $opts ; normalize-volume ff.mp4 "$final_name" ; flash_taskbar compress-video f.mp4 ff ; normalize-volume ff.mp4 "$final_name"
} }
alias cvn='compress_and_normalize_volume' alias cvn='compress_and_normalize_volume'
@@ -1346,7 +1298,7 @@ alias cvn='compress_and_normalize_volume'
# Git # Git
#################################################################################################### ####################################################################################################
if [[ ${platform,,} == *'ming'* ]]; then if [[ '${platform,,}' == *'ming'* ]]; then
# Fix a weird mingw 'not a valid identifierline' error. # Fix a weird mingw 'not a valid identifierline' error.
# Got the fix from https://github.com/Alexpux/MSYS2-packages/issues/735#issuecomment-328938800 # Got the fix from https://github.com/Alexpux/MSYS2-packages/issues/735#issuecomment-328938800
alias git="PATH=/usr/bin git" alias git="PATH=/usr/bin git"

View File

@@ -1,15 +1,12 @@
[include] [include]
# Shared config from private dotfiles path = ~/.gitconfig.private
path = ~/.private-dotfiles.common/gitconfig
# Computer-specific config from private dotfiles (might not exist)
path = ~/.private-dotfiles/gitconfig
[init] [init]
defaultBranch = master defaultBranch = master
[merge] [merge]
summary = true summary = true
tool = vimdiff tool = vimdiff
[core] [core]
excludesfile = ~/.private-dotfiles.common/gitignore excludesfile = ~/.gitignore.global
hookspath = ~/.git_hooks hookspath = ~/.git_hooks
preloadindex = true preloadindex = true
fscache = true fscache = true

6
.vimrc
View File

@@ -1555,9 +1555,11 @@ fu! Search(path, search_args, case_insensitive=0, token="")
" Some characters need to be escaped. " Some characters need to be escaped.
let l:escaped_term = substitute(l:term, '[#%]', '\\\\\\&', 'g') let l:escaped_term = substitute(l:term, '[#%]', '\\\\\\&', 'g')
let l:escaped_path = substitute(a:path, '[#%]', '\\\\\\&', 'g')
exec printf("Rg " . l:rg_args . " %s -e %s", shellescape(l:escaped_path), shellescape(l:escaped_term)) let l:format = 'Rg ' . l:rg_args . ' ' . a:path . ' -e %s'
let l:cmd = printf(l:format, shellescape(l:escaped_term))
exec l:cmd
call ConvertQuickfixPathsToUnixSlashes() call ConvertQuickfixPathsToUnixSlashes()
endfu endfu

View File

@@ -10,8 +10,6 @@
# #
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885 # Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@@ -52,4 +50,3 @@ eval $cmd
printf "\n${GREEN}${BOLD}Done analyzing audio in $filename\n${NORMAL}" printf "\n${GREEN}${BOLD}Done analyzing audio in $filename\n${NORMAL}"
printf "\n${YELLOW}${BOLD}Look at the reported max_volume value. If != 0 then call the change-volume script, passing it the filename, an output name and the delta to bring the volume to 0.\ne.g. if the max_volume is -5 db, then you would pass 5.${NORMAL}\n\n" printf "\n${YELLOW}${BOLD}Look at the reported max_volume value. If != 0 then call the change-volume script, passing it the filename, an output name and the delta to bring the volume to 0.\ne.g. if the max_volume is -5 db, then you would pass 5.${NORMAL}\n\n"
flash_taskbar

View File

@@ -1,32 +1,22 @@
@setlocal enableextensions enabledelayedexpansion
@echo off @echo off
setlocal enableextensions enabledelayedexpansion
rem NOTE: Defender may see this file as malware, so you might need to exclude this before things can be disabled. rem Make sure we're running as admin. Got this garbage from https://stackoverflow.com/a/40388766
if not "%1"=="am_admin" (
rem Modified version of: powershell -Command "Start-Process -Verb RunAs -FilePath '%0' -ArgumentList 'am_admin'"
rem https://github.com/ggannann/win10_disable_defender
rem https://gist.github.com/xezrunner/a7a42dbc1096a40b0c78f09488fe5a2b (as of Jan 2026 this seems to have been deleted or made private)
rem ============================
rem Self-elevate via UAC if needed
rem - Detect admin by checking membership in Administrators (SID S-1-5-32-544)
rem - Relaunch this script elevated using PowerShell Start-Process -Verb RunAs
rem ============================
rem Test for membership in Administrators group
whoami /groups | find "S-1-5-32-544" >nul
if errorlevel 1 (
echo Requesting administrative privileges...
rem Relaunch the same script elevated, preserving args and working directory
powershell -NoProfile -Command ^
"Start-Process -FilePath '%~f0' -ArgumentList '%*' -Verb RunAs -WorkingDirectory (Get-Location).Path"
exit /b exit /b
) )
echo Running with administrative privileges.
echo. rem NOTE: Defender may see this file as malware, so you might need to exclude this before things can be disabled.
rem
rem Modified version of
rem https://raw.githubusercontent.com/mattreecebentley/win10_disable_defender/main/win10_enable_defender.bat
rem https://gist.github.com/xezrunner/a7a42dbc1096a40b0c78f09488fe5a2b
reg query HKLM\SYSTEM\Setup /v DisabledDefenderServices | find "0x1" reg query HKLM\SYSTEM\Setup /v DisabledDefenderServices | find "0x1"
if %errorlevel% == 0 goto already_patched if %errorlevel% == 0 goto already_patched
echo.
echo Please note that Defender can only be disabled in Win10 v2004 and upwards if Tamper Protection is disabled. echo Please note that Defender can only be disabled in Win10 v2004 and upwards if Tamper Protection is disabled.
echo This setting can be found in Window settings (hint: search for 'tamper'). Please do this now and then, echo This setting can be found in Window settings (hint: search for 'tamper'). Please do this now and then,
pause pause
@@ -114,4 +104,3 @@ echo Defender has already been disabled by this script.
:eof :eof
echo. echo.
pause pause

View File

@@ -1,11 +1,17 @@
@setlocal enableextensions enabledelayedexpansion
@echo off @echo off
setlocal enableextensions enabledelayedexpansion
rem NOTE: Defender may see this file as malware, so you might need to exclude this before things can be disabled. rem Make sure we're running as admin. Got this garbage from https://stackoverflow.com/a/40388766
if not "%1"=="am_admin" (
powershell -Command "Start-Process -Verb RunAs -FilePath '%0' -ArgumentList 'am_admin'"
exit /b
)
rem Modified version of: rem USE AT OWN RISK AS IS WITHOUT WARRANTY OF ANY KIND !!!!!
rem https://github.com/ggannann/win10_disable_defender rem
rem https://gist.github.com/xezrunner/a7a42dbc1096a40b0c78f09488fe5a2b (as of Jan 2026 this seems to have been deleted or made private) rem Modified version of
rem https://raw.githubusercontent.com/mattreecebentley/win10_disable_defender/main/win10_enable_defender.bat
rem https://gist.github.com/xezrunner/a7a42dbc1096a40b0c78f09488fe5a2b
rem rem
rem Resources: rem Resources:
rem https://docs.microsoft.com/en-us/powershell/module/defender/set-mppreference?view=win10-ps rem https://docs.microsoft.com/en-us/powershell/module/defender/set-mppreference?view=win10-ps
@@ -13,23 +19,7 @@ rem https://docs.microsoft.com/en-us/windows/threat-protection/windows-defender-
rem https://github.com/AndyFul/ConfigureDefender rem https://github.com/AndyFul/ConfigureDefender
rem https://github.com/AndyFul/Hard_Configurator rem https://github.com/AndyFul/Hard_Configurator
rem ============================
rem Self-elevate via UAC if needed
rem - Detect admin by checking membership in Administrators (SID S-1-5-32-544)
rem - Relaunch this script elevated using PowerShell Start-Process -Verb RunAs
rem ============================
rem Test for membership in Administrators group
whoami /groups | find "S-1-5-32-544" >nul
if errorlevel 1 (
echo Requesting administrative privileges...
rem Relaunch the same script elevated, preserving args and working directory
powershell -NoProfile -Command ^
"Start-Process -FilePath '%~f0' -ArgumentList '%*' -Verb RunAs -WorkingDirectory (Get-Location).Path"
exit /b
)
echo Running with administrative privileges.
echo. echo.
echo Enabling Windows Defender echo Enabling Windows Defender
reg query HKLM\SYSTEM\Setup /v DisabledDefenderServices | find "0x0" reg query HKLM\SYSTEM\Setup /v DisabledDefenderServices | find "0x0"
if %errorlevel% == 0 goto already_patched if %errorlevel% == 0 goto already_patched
@@ -116,4 +106,3 @@ echo Defender has already been enabled by this script.
:eof :eof
echo. echo.
pause pause

View File

@@ -52,6 +52,11 @@ error() {
printf "${BOLD}${RED}$1${NORMAL}\n" printf "${BOLD}${RED}$1${NORMAL}\n"
} }
abort() {
error "\nAborting...\n"
exit 1
}
set -e set -e
bucket="$1" bucket="$1"
@@ -65,22 +70,9 @@ fi
# .Key gives us just the object paths. If you want the other metadata then remove that from the query. # .Key gives us just the object paths. If you want the other metadata then remove that from the query.
items="$(aws s3api list-objects-v2 --bucket $bucket --prefix "$path" --query "Contents[?StorageClass=='DEEP_ARCHIVE'].Key" --output text | tr '\t' '\n' | tr -d '\r')" item_count=$(aws s3api list-objects-v2 --bucket $bucket --prefix "$path" --query "length(Contents[?StorageClass=='DEEP_ARCHIVE'].Key)")
error=$?
if [[ ! $error -eq 0 ]]; then
error "Error: failed to run the aws command. Aborting."
exit 1
fi
if [[ $items == "None" ]]; then
error "Didn't find any files. Check that your bucket name and path is correct."
exit 1
fi
mapfile -t lines_array <<< "$items"
item_count="${#lines_array[@]}"
echo "$items" > "$output_file"
printf "Number of items: ${BOLD}${YELLOW}$item_count${NORMAL}\n" printf "Number of items: ${BOLD}${YELLOW}$item_count${NORMAL}\n"
aws s3api list-objects-v2 --bucket $bucket --prefix "$path" --query "Contents[?StorageClass=='DEEP_ARCHIVE'].Key" --output text | tr '\t' '\n' | tr -d '\r' > "$output_file"
printf "Wrote file list to ${BOLD}${YELLOW}$output_file${NORMAL}\n" printf "Wrote file list to ${BOLD}${YELLOW}$output_file${NORMAL}\n"

View File

@@ -32,7 +32,7 @@
# #
# (obviously change the bucket and path to suit your needs). # (obviously change the bucket and path to suit your needs).
# #
# Or use the aws-check-restore-status script. # Or use the aws-see-restore-status script.
# You know it's ready when ongoing-request is false and there's a date. If that # You know it's ready when ongoing-request is false and there's a date. If that
# field is null then the file isn't being restored. # field is null then the file isn't being restored.
# #
@@ -187,6 +187,24 @@ mkdir -p "$temp_dir"
pushd "$temp_dir" &>/dev/null pushd "$temp_dir" &>/dev/null
# .Key gives us just the object paths. If you want the other metadata then remove that from the query. # .Key gives us just the object paths. If you want the other metadata then remove that from the query.
item_count=$(aws s3api list-objects-v2 --bucket $bucket --prefix "$path" --query "length(Contents[?StorageClass=='DEEP_ARCHIVE'].Key)")
error=$?
if [[ ! $error -eq 0 ]]; then
error "Error: failed to run the aws command. Aborting."
exit 1
fi
if [[ $item_count == 0 ]]; then
error "Didn't find any files. Check that your bucket name and path is correct."
exit 1
fi
printf "Number of items to restore: ${BOLD}${YELLOW}$item_count${NORMAL}\n"
printf "${BOLD}${RED}Create the restore script?\n> ${NORMAL}"
read -e proceed
if [[ $proceed == "1" || $proceed == "y" || $proceed == "Y" || $proceed == "yes" || $proceed == "YES" ]]; then
items="$(aws s3api list-objects-v2 --bucket $bucket --prefix "$path" --query "Contents[?StorageClass=='DEEP_ARCHIVE'].Key" --output text | tr '\t' '\n' | tr -d '\r')" items="$(aws s3api list-objects-v2 --bucket $bucket --prefix "$path" --query "Contents[?StorageClass=='DEEP_ARCHIVE'].Key" --output text | tr '\t' '\n' | tr -d '\r')"
error=$? error=$?
@@ -199,16 +217,9 @@ if [[ $items == "None" ]]; then
exit 1 exit 1
fi fi
mapfile -t lines_array <<< "$items" echo "$items" > all_objects_list.txt
item_count="${#lines_array[@]}"
# Generate the main script that will kick off the restoration. # Generate the main script that will kick off the restoration.
printf "Number of items to restore: ${BOLD}${YELLOW}$item_count${NORMAL}\n"
printf "${BOLD}${RED}Create the restore script?\n> ${NORMAL}"
read -e proceed
if [[ $proceed == "1" || $proceed == "y" || $proceed == "Y" || $proceed == "yes" || $proceed == "YES" ]]; then
echo "$items" > all_objects_list.txt
RUN_TEMPLATE=$(cat <<EOF RUN_TEMPLATE=$(cat <<EOF
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
@@ -234,26 +245,16 @@ else
NORMAL="" NORMAL=""
fi fi
# Open an output file. failed=()
exec 3>>output.txt
fail_count=0
failed_filename="failed_keys_\$(printf '%%04x' \$((RANDOM * RANDOM))).txt"
before_sleep_count=0 before_sleep_count=0
sleep_every_n_requests=25 sleep_every_n_requests=25
sleep_duration=0.2 sleep_duration=0.2
printf "Files are being restored for $days_available days using the $restore_tier tier\\\n\\\n" printf "Files are being restored for $days_available days using the $restore_tier tier\\\n\\\n"
printf "Files are being restored for $days_available days using the $restore_tier tier\\\n\\\n" >&3
printf "\${BOLD}NOTE: Request failures will be saved to \${YELLOW}\$failed_filename\${NORMAL}\${BOLD} as they happen. If this script terminates prematurely then check this file for failures.\\\n\\\n"
printf "NOTE: Request failures will be saved to \$failed_filename as they happen. If this script terminates prematurely then check this file for failures.\\\n\\\n" >&3
index=1 index=1
while read key; do while read key; do
printf "* [\$index/$item_count] \${BOLD}\$key\${NORMAL}\\\n" printf "* [\$index/$item_count] \${BOLD}\$key\${NORMAL}\\\n"
printf "* [\$index/$item_count] \$key\\\n" >&3
err=\$( err=\$(
aws s3api restore-object \\ aws s3api restore-object \\
--bucket mcampagnaro-deep-glacier \\ --bucket mcampagnaro-deep-glacier \\
@@ -269,31 +270,22 @@ while read key; do
if [[ \$err != "" ]]; then if [[ \$err != "" ]]; then
if ! grep -qE 'RestoreAlreadyInProgress|ObjectAlreadyInActiveTierError' <<<"\$err"; then if ! grep -qE 'RestoreAlreadyInProgress|ObjectAlreadyInActiveTierError' <<<"\$err"; then
failed+=("\$key")
printf "\${BOLD}\${RED}FAILED! \$err\${NORMAL}" printf "\${BOLD}\${RED}FAILED! \$err\${NORMAL}"
printf "FAILED! \$err\" >&3
# Save the failure to a file now in case the script exits prematurely.
fail_count=\$((fail_count + 1))
printf "%%s\\\n" "\$key" >> \$failed_filename
else else
if grep -qE 'RestoreAlreadyInProgress' <<<"\$err"; then if grep -qE 'RestoreAlreadyInProgress' <<<"\$err"; then
printf "\${BOLD}\${YELLOW}SKIPPING! File restore is already in progress.\${NORMAL}" printf "\${BOLD}\${YELLOW}SKIPPING! File restore is already in progress.\${NORMAL}"
printf "SKIPPING! File restore is already in progress." >&3
else else
printf "\${BOLD}\${YELLOW}SKIPPING! File is already restored. You can now download it.\${NORMAL}" printf \${BOLD}"\${YELLOW}SKIPPING! File is already restored. You can now download it.\${NORMAL}"
printf "SKIPPING! File is already restored. You can now download it." >&3
fi fi
fi fi
else else
printf "\${BOLD}\${GREEN}SUCCESS!\${NORMAL}" printf "\${BOLD}\${GREEN}SUCCESS!\${NORMAL}"
printf "SUCCESS!" >&3
fi fi
printf "\\\n\\\n" printf "\\\n\\\n"
printf "\\\n\\\n" >&3
if [[ \$before_sleep_count -eq sleep_every_n_requests ]]; then if [[ \$before_sleep_count -eq sleep_every_n_requests ]]; then
printf "SLEEPING...\\\n\\\n" printf "SLEEPING...\\\n\\\n"
printf "SLEEPING...\\\n\\\n" >&3
sleep \$sleep_duration sleep \$sleep_duration
before_sleep_count=0 before_sleep_count=0
fi fi
@@ -301,21 +293,22 @@ while read key; do
done < all_objects_list.txt done < all_objects_list.txt
printf "\${BOLD}\${GREEN}Done!\${NORMAL}\\\n\\\n" printf "\${BOLD}\${GREEN}Done!\${NORMAL}\\\n\\\n"
printf "Done!\\\n\\\n" >&3
fail_count=\${#failed[@]}
if [[ \$fail_count > 0 ]]; then if [[ \$fail_count > 0 ]]; then
rand=\$(printf '%%04x' \$((RANDOM * RANDOM)))
filename="failed_keys_\$rand.txt"
printf "\${BOLD}\${RED}There were \$fail_count failures!\\\nSee \${NORMAL}\${BOLD}\$filename\${RED} for the list. You can replace the contents of \${NORMAL}\${BOLD}all_objects_list.txt\${RED} with the list of failures and re-run this script to process them.\${NORMAL}\\\n\\\n" printf "\${BOLD}\${RED}There were \$fail_count failures!\\\nSee \${NORMAL}\${BOLD}\$filename\${RED} for the list. You can replace the contents of \${NORMAL}\${BOLD}all_objects_list.txt\${RED} with the list of failures and re-run this script to process them.\${NORMAL}\\\n\\\n"
printf "There were \$fail_count failures!\\\nSee \$filename for the list. You can replace the contents of all_objects_list.txt with the list of failures and re-run this script to process them.\\\n\\\n" >&3
printf "%%s\\\n" "\${failed[@]}" > \$filename
else else
printf "There were no failures. All the files are being restored. You can now delete this folder.\\\n\\\n" printf "There were no failures. All the files are being restored. You can now delete this folder.\\\n\\\n"
printf "There were no failures. All the files are being restored. You can now delete this folder.\\\n\\\n" >&3
fi fi
printf "(Note: the time it takes to restore an object can be found in the AWS docs - just look for the $restore_tier restore tier, which is what you used.\\\nOnce restored, download the files from the S3 site or better yet use RCloneBrowser.\\\n" printf "(Note: the time it takes to restore an object can be found in the AWS docs - just look for the $restore_tier restore tier, which is what you used.\\\nOnce restored, download the files from the S3 site or better yet use RCloneBrowser.\\\n"
printf "You can check the status of a file using the aws-check-restore-status script)\\\n" printf "You can check the status of a file using the aws-see-restore-status script)\\\n"
exec 3>&-
EOF EOF
) )

View File

@@ -2,7 +2,7 @@
# Shows you the status of an object restore job. # Shows you the status of an object restore job.
# #
# e.g. aws-check-restore-status my-deep-glacier-bucket object/path.png # e.g. aws-see-restore-status my-deep-glacier-bucket object/path.png
# #
# You know it's ready when ongoing-request is false and there's a date. If that field is null then the file isn't being restored. # You know it's ready when ongoing-request is false and there's a date. If that field is null then the file isn't being restored.
# #
@@ -65,7 +65,7 @@ bucket="$1"
path="$2" path="$2"
if [[ $bucket == "" || $path == "" ]]; then if [[ $bucket == "" || $path == "" ]]; then
error "Usage: aws-check-restore-status <bucket-name> <path-in-bucket>" error "Usage: aws-see-restore-status <bucket-name> <path-in-bucket>"
exit 1 exit 1
fi fi

View File

@@ -7,8 +7,6 @@
# #
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885 # Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@@ -59,4 +57,3 @@ eval $cmd
printf "\n${GREEN}${BOLD}Done modifying volume in $filename.$extension | output: $output | delta: $delta_db${NORMAL}\n" printf "\n${GREEN}${BOLD}Done modifying volume in $filename.$extension | output: $output | delta: $delta_db${NORMAL}\n"
flash_taskbar

View File

@@ -1,9 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Bigger crf values == bigger compression.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@@ -28,12 +24,9 @@ else
fi fi
use_gpu=1 use_gpu=1
# Found the following to work best with vids containing text (e.g. programming vids). These give similar bitrates.
cpu_crf=20
gpu_crf=33
if [[ $# < 2 || $# > 5 ]]; then if [[ $# < 2 || $# > 5 ]]; then
printf "${BOLD}${RED}Usage: compress-video <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> <optional: start time HH:MM:SS> <optional: end time HH:MM:SS> (NOTE: gpu crf is $gpu_crf and cpu crf is $cpu_crf - change it by calling compress-video-with-crf)${NORMAL}\n" printf "${BOLD}${RED}Usage: compress-video <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> <optional: start time HH:MM:SS> <optional: end time HH:MM:SS> ${NORMAL}\n"
exit 1 exit 1
fi fi
@@ -44,12 +37,11 @@ if [[ $# > 2 ]]; then
use_gpu=$3 use_gpu=$3
fi fi
use_crf=$cpu_crf # Found the following to work best with vids containing text (e.g. programming vid): 21 for CPU encoding and 28 for GPU (similar bitrates).
use_crf=21
if [[ $use_gpu -eq 1 ]]; then if [[ $use_gpu -eq 1 ]]; then
use_crf=$gpu_crf use_crf=33
fi fi
compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu $4 $5 compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu $4 $5
flash_taskbar

View File

@@ -1,9 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Bigger crf values == bigger compression.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@@ -97,5 +93,3 @@ else
encode $crf encode $crf
done done
fi fi
flash_taskbar

View File

@@ -3,8 +3,6 @@
# This is for reencoding a non-mp4 video to mp4 using an mpeg4 encoder. # This is for reencoding a non-mp4 video to mp4 using an mpeg4 encoder.
# Can optionally compress the video. # Can optionally compress the video.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@@ -96,5 +94,3 @@ else
fi fi
printf "${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output'${NORMAL}\n\n" printf "${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output'${NORMAL}\n\n"
flash_taskbar

View File

@@ -3,8 +3,6 @@
# Re-encodes the video to get a more accurate timeline. Same settings as trim-video-vbr. # Re-encodes the video to get a more accurate timeline. Same settings as trim-video-vbr.
# If you want fast video joining at the expense of accuracy then use join-video-fast. # If you want fast video joining at the expense of accuracy then use join-video-fast.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@@ -33,17 +31,17 @@ output="$2"
target_crf="$3" target_crf="$3"
max_bitrate_mb="$4" max_bitrate_mb="$4"
default_crf="33" # if you want to compress then use the same gpu compression level from compress-video (i.e. 33, but verify it's still set to this) default_crf="20"
default_max_bitrate="6" default_max_bitrate="6"
if [[ $filename == "" || $output == "" ]]; then if [[ $filename == "" || $output == "" ]]; then
printf "${BOLD}${RED}Usage: create a text file that lists the input video paths on separate lines using the format: file '/path/to/video'. Then call:\n\njoin-video <list filename> <output name> <optional: crf (quality, value = compression level) - defaults to $default_crf, use 0 for no value> <optional: max bitrate in MB - defaults to ${default_max_bitrate}M>${NORMAL}\n" printf "${BOLD}${RED}Usage: create a text file that lists the input video paths on separate lines using the format: file '/path/to/video'. Then call:\n\njoin-video <list filename> <output name> <optional: crf (quality, w/ lower = more compression) - defaults to $default_crf, use 0 for no value> <optional: max bitrate in MB - defaults to ${default_max_bitrate}M><${NORMAL}\n"
exit 1 exit 1
fi fi
extension="${output##*.}" extension="${output##*.}"
if [[ $extension == $output ]]; then if [[ $extension == $output ]]; then
printf "${BOLD}${RED}output arg should have an extension!\n\nUsage: join-video <list filename> <output name> <optional: crf (quality, value = compression level) - defaults to $default_crf, use 0 for no value> <optional: max bitrate in MB - defaults to ${default_max_bitrate}M>${NORMAL}\n" printf "${BOLD}${RED}output arg should have an extension!\n\nUsage: join-video <list filename> <output name> <optional: crf (quality, w/ lower = more compression) - defaults to $default_crf, use 0 for no value> <optional: max bitrate in MB - defaults to ${default_max_bitrate}M><${NORMAL}\n"
exit 1 exit 1
fi fi
@@ -66,4 +64,3 @@ time ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format
printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n"
flash_taskbar

View File

@@ -5,8 +5,6 @@
# playback time might oscillate a bit. Use join-video for accurate joining at # playback time might oscillate a bit. Use join-video for accurate joining at
# the cost of a much slower processing time. # the cost of a much slower processing time.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@@ -46,4 +44,3 @@ ffmpeg -y -stats -loglevel level+error -f concat -safe 0 -i "$filename" -c copy
printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n"
flash_taskbar

View File

@@ -10,8 +10,6 @@
# #
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885 # Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@@ -80,4 +78,3 @@ eval "$cmd"
printf "\n${GREEN}${BOLD}Done normalizing volume in $filename.$extension | output: $output${NORMAL}\n" printf "\n${GREEN}${BOLD}Done normalizing volume in $filename.$extension | output: $output${NORMAL}\n"
rm $temp_file rm $temp_file
flash_taskbar

View File

@@ -2,8 +2,6 @@
# Re-encodes the audio to get a more accurate seek time. # Re-encodes the audio to get a more accurate seek time.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@@ -60,4 +58,3 @@ ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
flash_taskbar

View File

@@ -2,8 +2,6 @@
# Re-encodes the video to get a more accurate seek time. If you want fast trimming at the expense of accuracy then use trim-video-fast. # Re-encodes the video to get a more accurate seek time. If you want fast trimming at the expense of accuracy then use trim-video-fast.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@@ -64,4 +62,3 @@ ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -async 1 -i "
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
flash_taskbar

View File

@@ -5,8 +5,6 @@
# time might oscillate a bit. Use trim-video for accurate trimming at the cost # time might oscillate a bit. Use trim-video for accurate trimming at the cost
# of a much slower processing time. # of a much slower processing time.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@@ -66,4 +64,3 @@ ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
flash_taskbar

View File

@@ -1,9 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Re-encodes the video using a constrained bitrate/output size. If you want to # Re-encodes the video using a constrained bitrate/output size. If you want to
# control the visual quality with a variable bitrate then use trim-video-vbr # To target the visual quality with a variable bitrate, use trim-video-vbr
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
@@ -92,4 +90,3 @@ ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
flash_taskbar

View File

@@ -4,10 +4,6 @@
# To have a mostly fixed bitrate with no variable quality, use trim-video-target-rate # To have a mostly fixed bitrate with no variable quality, use trim-video-target-rate
# Just note that it'll result in larger files for a similar max bitrate target and the # Just note that it'll result in larger files for a similar max bitrate target and the
# quality won't really be noticeably better. # quality won't really be noticeably better.
#
# The higher the CRF value, the higher the compression.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
@@ -39,11 +35,11 @@ end_time="$4"
target_crf="$5" target_crf="$5"
max_bitrate_mb="$6" max_bitrate_mb="$6"
default_crf="33" # if you want to compress then use the same gpu compression level from compress-video (i.e. 33, but verify it's still set to this) default_crf="20"
default_max_bitrate="6" default_max_bitrate="6"
if [[ $filename == "" || $output_name == "" || $start_time == "" ]]; then if [[ $filename == "" || $output_name == "" || $start_time == "" ]]; then
printf "${BOLD}${RED}Usage: trim-video-vbr <filename> <output name> <start time HH:MM:SS> <optional: end time HH:MM:SS, use empty string or 0 for no value> <optional: crf (quality, value = compression level) - defaults to $default_crf, use 0 for no value> <optional: max bitrate in MB - defaults to ${default_max_bitrate}M>${NORMAL}\n" printf "${BOLD}${RED}Usage: trim-video <filename> <output name> <start time HH:MM:SS> <optional: end time HH:MM:SS, use empty string or 0 for no value> <optional: crf (quality, w/ lower = more compression) - defaults to $default_crf, use 0 for no value> <optional: max bitrate in MB - defaults to ${default_max_bitrate}M>${NORMAL}\n"
exit 1 exit 1
fi fi
@@ -126,4 +122,3 @@ time ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
flash_taskbar

View File

@@ -1,5 +1,3 @@
NOTE: Best option is to create/store private keys in Bitwarden.
# Creating an elliptic curve keypair (ed25519) # Creating an elliptic curve keypair (ed25519)
* Create: `ssh-keygen -a 100 -t ed25519 -f ~/.ssh/filename` * Create: `ssh-keygen -a 100 -t ed25519 -f ~/.ssh/filename`

View File

@@ -60,12 +60,6 @@
* Desktop: turn off hibernation * Desktop: turn off hibernation
* Open admin cmd prompt: `powercfg.exe /hibernate off` * Open admin cmd prompt: `powercfg.exe /hibernate off`
* Enable long paths:
* winkey+r -> `gpedit.msc`.
* Computer Configuration > Administrative Templates > System > Filesystem
* Double-click the `Enable Win32 long paths` policy.
* Select Enabled.
* Disable power throttling: * Disable power throttling:
* winkey+r -> `gpedit.msc`. * winkey+r -> `gpedit.msc`.
* Computer Configuration > Administrative Templates > System > Power Management > Power Throttling Settings * Computer Configuration > Administrative Templates > System > Power Management > Power Throttling Settings