Compare commits

65 Commits

Author SHA1 Message Date
fe531b185f vimrc: escape text search path 2026-03-15 17:31:28 -04:00
e009688aa0 Flash windows icon when various scripts finish running 2026-02-24 18:06:49 -05:00
bade7f762a Some improvements to the defender disable/enable scripts 2026-02-01 18:36:52 -05:00
01edb8f277 Change how gitconfig files are loaded 2026-01-15 18:11:15 -05:00
1474e23aea Small tweaks 2026-01-09 12:09:56 -05:00
08ed0a411d Update windows setup readme 2026-01-09 10:46:58 -05:00
9fb52326f9 Update aliases 2025-12-30 19:30:20 -05:00
56e4ad3386 Improve the aws deep glacier restore scripts 2025-12-30 19:30:20 -05:00
0ecad79655 Tweakin da aliases 2025-11-14 17:17:34 -05:00
8c4fbcc4a8 Update aliases 2025-10-01 01:16:23 -04:00
dcf670070d Fix yt-dlp issues with youtube and embed thumbnails/metadata in video downloads 2025-08-19 18:59:36 -04:00
121d451982 Improve some video encoding scripts, making use of the GPU again 2025-08-19 18:58:57 -04:00
240d38eea0 Update aliases 2025-05-07 16:08:14 -04:00
37e6c770d7 Update some download aliases, vimrc search for cursor term, and some volume scripts 2025-05-07 16:08:13 -04:00
1db6c9e9b0 I can't believe I didn't know about vim's line breaks at word boundaries option 2025-05-07 16:08:13 -04:00
a25c209ddf Add vim search commands for personal projects 2025-05-07 16:08:13 -04:00
3b6daf46a1 Add a git alias to see size of tracked files 2025-05-07 16:08:13 -04:00
25b741d913 Improve AWS restore script 2025-05-07 16:08:13 -04:00
8a348ac299 Update aliases 2025-05-07 16:08:13 -04:00
aed6afbe38 Remove some aliases 2025-05-07 16:08:13 -04:00
6b879c4d66 Ignore build directory when generating ctags 2025-05-07 16:08:13 -04:00
aa948710a2 Update aliases 2025-05-07 16:08:13 -04:00
923f7fbcd6 Update Windows readme 2025-05-07 16:08:13 -04:00
80227c1d76 Fix twitch vid compression failing because of extra spaces in filename 2025-05-07 16:08:13 -04:00
2d0191c775 Update windows hosts file 2025-05-07 16:08:12 -04:00
079cec8402 Update linux notes 2024-07-03 14:22:16 -04:00
c1c6fec29c Update msys updater script 2024-07-03 14:22:01 -04:00
740fc319db Update windows readme 2024-07-03 14:21:21 -04:00
3bff9be48a Don't run ctags in vim if in home directory 2024-07-03 14:20:48 -04:00
172396583f Fix symlink command on Linux 2024-06-19 13:35:38 -04:00
cefab517a5 Improve yt-audio function 2024-05-20 14:25:46 -04:00
159c8cff90 Improve ffmpeg audio fix scripts 2024-05-19 17:28:41 -04:00
67bd7e4454 Update git aliases 2024-05-19 17:28:23 -04:00
606096c674 Update windows setup notes; moved things around and added steps to speed up explorer search 2024-05-19 17:28:08 -04:00
19f90233de Add a dos2unix alias for recursive application 2024-04-28 23:32:23 -04:00
5715367556 Do recursive ctags by default 2024-04-28 23:31:24 -04:00
9216d7cee5 Add a note on targeting specific Windows versions for updates 2024-04-26 15:14:32 -04:00
9876fcf4cd Add a vim plugin that significantly speeds up ctrlp's fuzzy matcher 2024-01-20 22:42:06 -05:00
e175fefa18 Alias and vid compression tweaks 2024-01-20 22:19:57 -05:00
2a6522b4b7 Use unix slashes in ripgrep search results 2024-01-20 22:19:32 -05:00
dc88f6cc36 Use unix slashes in the path of a possible exe to run 2024-01-20 22:18:57 -05:00
65500a66ea Improve jai build function 2024-01-20 22:16:52 -05:00
a2c5c8a4d6 Add leader motions for quickly opening jai files 2024-01-20 22:15:57 -05:00
7d928a25ea Use ctrlp fork 2024-01-20 22:15:21 -05:00
4b6d506d7b Try to execute run-cpp if editing a C/C++ file 2023-12-10 18:49:05 -05:00
05c46303c8 Improve the run program command in vim 2023-12-10 18:37:18 -05:00
bc21059ea6 Add a windows setup note on managing trust root cert authorities 2023-12-07 15:13:46 -05:00
3971799926 Lock vim plugins to stable commits 2023-12-06 18:45:02 -05:00
d7823294b5 Add an earth-tone vim color scheme 2023-12-06 16:52:20 -05:00
02593ec5f6 Change some vim syntax highlighting 2023-12-06 16:52:20 -05:00
928cc915dd Update git alias and improve vim windows detection 2023-12-01 23:48:11 -05:00
137efc71a6 Disable treating special characters are regex when doing a vim search 2023-11-24 19:48:11 -05:00
98c74416e8 Add youtube download aliases for 1440p vids 2023-11-20 20:11:59 -05:00
95b05d5944 Add some aliases 2023-11-02 12:14:48 -04:00
34d1a0ea04 Allow normalize-volume script to run on videos with embedded subtitles 2023-11-02 12:13:59 -04:00
e921e6b9eb Allow change-volume script to run on videos with embedded subtitles 2023-10-25 12:26:29 -04:00
b399a9e2c9 Add batch scripts for getting file checksum 2023-10-25 12:26:12 -04:00
6889755330 Fix sigcheck batch file not changing the working directory 2023-10-25 12:25:48 -04:00
2beccaeeb3 Fix some transcribe-video scripts 2023-10-05 16:18:47 -04:00
8ad4d67d84 Support binary payloads when downloading an m3u8 2023-10-05 16:18:38 -04:00
abbcd76178 Update video script 2023-09-20 14:00:57 -04:00
f9a06756ca vimrc improvements 2023-09-20 14:00:23 -04:00
851dc77481 Add a Windows setup note for disabling the garbage secure time seed feature 2023-08-23 13:34:18 -04:00
f0f2a0f38d Note on fixing cursor mapping between monitors with different resolutions 2023-08-19 14:14:35 -04:00
208ba7278a Add a note to disable the microsoft compatibility appraiser task 2023-08-19 14:12:01 -04:00
46 changed files with 2099 additions and 688 deletions

500
.aliases
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
@@ -63,6 +63,7 @@ expand_path() {
ret=$(readlink -m "$ret") ret=$(readlink -m "$ret")
echo $ret echo $ret
} }
is_absolute_unix_path() { is_absolute_unix_path() {
if [[ $1 =~ ^/ ]]; then echo 1; else echo 0; fi if [[ $1 =~ ^/ ]]; then echo 1; else echo 0; fi
} }
@@ -109,8 +110,12 @@ remove_windows_file() {
fi fi
} }
open_explorer_here() { open_explorer() {
local path_expanded=$(expand_path "$1") local target="$1"
if [[ $target == "" ]]; then
target="$PWD"
fi
local path_expanded=$(expand_path "$target")
if [[ -d $path_expanded ]]; then if [[ -d $path_expanded ]]; then
local path=$(unix_to_windows_path "$path_expanded") local path=$(unix_to_windows_path "$path_expanded")
explorer.exe "$path" explorer.exe "$path"
@@ -119,6 +124,54 @@ open_explorer_here() {
fi fi
} }
open_filepilot() {
local target="$1"
if [[ $target == "" ]]; then
target="$PWD"
fi
local path_expanded=$(expand_path "$target")
if [[ -d $path_expanded ]]; then
local path=$(unix_to_windows_path "$path_expanded")
start fpilot.exe "$path"
else
echo "Folder no longer exists"
fi
}
remove_extra_spaces() {
# Replace consecutive spaces with a single space.
#
# We're using this in the various vid/audio download functions because
# Windows seems to strip extra spaces when creating a file, so we need
# to match this behaviour in order to do post-processing after downloading.
ret=$(echo "$1" | tr -s ' ')
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
################## ##################
@@ -169,7 +222,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'
@@ -189,20 +242,27 @@ alias ls='ls -F --color'
alias l='ls -lh' alias l='ls -lh'
alias ll='ls -lha' alias ll='ls -lha'
mkcd() {
mkdir -p "${1}"
cd "${1}"
}
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'
alias checksum-sha1='_checksum SHA1' # I use delegating to certutil via _checksum() but these programs are faster.
alias checksum-sha256='_checksum SHA256' alias checksum-md5='md5sum.exe'
alias checksum-sha512='_checksum SHA512' alias checksum-sha1='sha1sum.exe'
alias checksum-sha256='sha256sum.exe'
alias checksum-sha512='sha512sum.exe'
fi fi
check_signature() { check_signature() {
@@ -233,22 +293,21 @@ alias cls=clear
alias cpr='cp -r' alias cpr='cp -r'
alias dc='gdc' alias dc='gdc'
alias duh='du -csh' alias duh='du -csh'
alias e='open_explorer_here "$PWD"'
alias exp='echo "Use e instead."' dos2unix_all() {
local path="$1"
if [[ $path == "" ]]; then
path="$PWD"
fi
find $path -type f -exec dos2unix '{}' '+'
}
alias d2u='dos2unix_all'
alias e='open_explorer'
alias f='fg' alias f='fg'
alias hist='history' alias hist='history'
alias histroy='history' alias histroy='history'
alias irb='irb --readline -r irb/completion'
alias lcc='lein clean'
alias lca='lein cljsbuild auto dev'
alias ldi='lein deps install'
alias lsd='lein start-dev'
alias moon='curl wttr.in/moon -A "curl"' alias moon='curl wttr.in/moon -A "curl"'
alias reguard='killall -9 ruby ; guard'
alias rb='rbenv'
alias rbg='rbenv gemset active'
alias rbp='cd $RBENV_PATH/versions/$(rbenv version | sed -e "s/ (set.*$//")'
alias rbl='cd $RBENV_PATH/versions/$(rbenv version | sed -e "s/ (set.*$//")/lib/ruby'
alias rc='rclone' alias rc='rclone'
alias rcc='rclone copy' alias rcc='rclone copy'
alias restart='sudo shutdown now -r' alias restart='sudo shutdown now -r'
@@ -262,9 +321,6 @@ alias t='tree'
alias tag='ctags -R .' alias tag='ctags -R .'
alias v='vim' alias v='vim'
alias vi='vim' alias vi='vim'
alias vh='vagrant halt'
alias vs='vagrant ssh'
alias vu='vagrant up'
alias vimrc='vim ~/.vimrc' alias vimrc='vim ~/.vimrc'
alias weather='curl wttr.in/toronto -A "curl"' alias weather='curl wttr.in/toronto -A "curl"'
@@ -337,7 +393,9 @@ make_vid_dir_and_cd_into() {
fi fi
fi fi
printf "${BOLD}Creating directory ${YELLOW}'$dir_name'${NORMAL}\n" dir_name=$(remove_extra_spaces "$dir_name")
printf "${BOLD}Creating directory ${YELLOW}\"$dir_name\"${NORMAL}\n"
mkdir "$dir_name" 2>/dev/null mkdir "$dir_name" 2>/dev/null
cd "$dir_name" cd "$dir_name"
@@ -378,6 +436,7 @@ 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() {
@@ -399,6 +458,7 @@ 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
} }
@@ -429,13 +489,10 @@ download_youtube_vid() {
if [[ $format == "" ]]; then if [[ $format == "" ]]; then
printf "${BOLD}No format given; using best available.${NORMAL}\n" printf "${BOLD}No format given; using best available.${NORMAL}\n"
# Download best mp4 video. # Download best mp4 video, best audio then merge.
format="bv*[ext=mp4]+ba[ext=m4a]" format="bv[ext=mp4]+ba[ext=m4a]"
fi fi
# We're assuming we'll always have an mp4 video only and audio track to merge.
opts+=" --merge-output-format mp4 --write-subs --sub-lang en --embed-subs"
if [[ $make_folder == "1" ]]; then if [[ $make_folder == "1" ]]; then
make_vid_dir_and_cd_into $url "" make_vid_dir_and_cd_into $url ""
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
@@ -451,9 +508,13 @@ download_youtube_vid() {
# Get the video filename. # Get the video filename.
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url) local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
filename=$(remove_extra_spaces "$filename")
printf "filename: $filename\n" printf "filename: $filename\n"
# Download # Download the video.
# We're assuming we'll always have an mp4 video only and audio track to merge.
opts+=" --merge-output-format mp4 --write-subs --sub-lang en --embed-subs --embed-thumbnail --embed-metadata"
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url" local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string. eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
error=$? error=$?
@@ -474,8 +535,16 @@ 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
} }
#
# You can control which videos are downloaded using the opts param:
# --playlist-start NUMBER (1-indexed)
# --playlist-end NUMBER
# --playlist-items ITEMS (Can be something like 1,2,5 or a range like 1-3,7,10-20)
#
download_youtube_playlist() { download_youtube_playlist() {
local format="$1" local format="$1"
local url="$2" local url="$2"
@@ -483,8 +552,8 @@ download_youtube_playlist() {
shift 3 shift 3
local opts="$@" local opts="$@"
if [[ $url == "" ]]; then if [[ $url == "" || $dir_name == "" ]]; then
error "Usage: <url> <directory name (optional)> <optional args>" error "Usage: <url> <directory name> <optional args>"
return return
fi fi
@@ -492,29 +561,28 @@ download_youtube_playlist() {
if [[ $format == "" ]]; then if [[ $format == "" ]]; then
printf "${BOLD}No format given; using best available.${NORMAL}\n" printf "${BOLD}No format given; using best available.${NORMAL}\n"
# Download best mp4 video and best m4a audio, then merge. # Download best mp4 video, best audio then merge.
format="bv*[ext=mp4]+ba[ext=m4a]" format="bv[ext=mp4]+ba[ext=m4a]"
opts+=" --merge-output-format mp4"
fi fi
opts+=" --write-sub --sub-lang en --embed-subs" make_vid_dir_and_cd_into $url "$dir_name"
if [[ $? -ne 0 ]]; then
if [[ $dir_name != "" ]]; then return
make_vid_dir_and_cd_into $url "$dir_name"
if [[ $? -ne 0 ]]; then
return
fi
fi fi
local cmd="yt-dlp.exe -f $format -o \"v%(playlist_index)03d--%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s.%(ext)s\" $opts $url" # We're assuming we'll always have an mp4 video only and audio track to merge.
opts+=" --merge-output-format mp4 --write-subs --sub-lang en --embed-subs --embed-thumbnail --embed-metadata"
local cmd="yt-dlp.exe -f $format -o \"%(playlist_index)03d--%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s.%(ext)s\" $opts $url"
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string. eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
# Removing any trailing subtitle files # Removing any trailing subtitle files
rm *.vtt *.srt 2>/dev/null rm *.vtt *.srt 2>/dev/null
if [[ $dir_name == "1" ]]; then cd ..; fi 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() {
@@ -534,6 +602,7 @@ 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() {
@@ -562,20 +631,59 @@ 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() {
if [[ $1 == "" ]]; then local make_folder="$1"
error "Usage: <url>" local url="$2"
shift 2
local opts="$@"
if [[ $url == "" ]]; then
error "Usage: <make folder?> <url> <optional args>"
return return
fi fi
yt-dlp.exe -f "140" "$1"
printf "${BOLD}Downloading Youtube audio\n\n${NORMAL}"
if [[ $make_folder == "1" ]]; then
make_vid_dir_and_cd_into $url ""
if [[ $? -ne 0 ]]; then
return
fi
fi
local format="140"
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s"
# Get the audio filename.
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
filename=$(remove_extra_spaces "$filename")
printf "filename: $filename\n"
# Download the audio.
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
error=$?
if [[ $error -ne 0 ]]; then
error "Error: Failed to download '$url'"
if [[ $make_folder == "1" ]]; then cd ..; fi
return
fi
if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
# Download Twitch chat transcript # Download Twitch chat transcript
actually_download_twitch_chat() { actually_download_twitch_chat() {
local url="$1" local url="$1"
local filename="$2" local filename="$2"
filename=$(remove_extra_spaces "$filename")
rechat.exe -d $url "$filename.json" rechat.exe -d $url "$filename.json"
if [[ -f "$filename.json" ]]; then if [[ -f "$filename.json" ]]; then
@@ -606,7 +714,7 @@ download_twitch_chat() {
fi fi
fi fi
actually_download_twitch_chat $url "$(yt-dlp.exe --get-filename -o "%(upload_date>%Y-%m-%d)s-%(title)s-tw-%(id)s.chat" $opts $url)" actually_download_twitch_chat $url "$(yt-dlp.exe --get-filename -o "%(upload_date>%Y-%m-%d)s-%(title)s-tw-%(id)s" $opts $url)"
if [[ $make_folder == "1" ]]; then cd ..; fi if [[ $make_folder == "1" ]]; then cd ..; fi
} }
@@ -620,7 +728,15 @@ download_twitch_chat() {
# `tw-1080p60 <url> --cookies /c/<cookie_path>/twitch_cookies.txt` # `tw-1080p60 <url> --cookies /c/<cookie_path>/twitch_cookies.txt`
# #
# 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-and-trim` scripts. # `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.
#
# This reencodes during the download, slightly faster than the next option:
# 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"
@@ -641,12 +757,15 @@ download_twitch_vid() {
# It's a two step process because streamlink cannot pass the formatted filename to ffmpeg. # It's a two step process because streamlink cannot pass the formatted filename to ffmpeg.
# We fallback to yt-dlp when it's a subscriber VOD because we don't have an easy way to access it with streamlink. # We fallback to yt-dlp when it's a subscriber VOD because we don't have an easy way to access it with streamlink.
local subscriber_vod=0 local use_ytdlp=0
local split_opts=($opts) local split_opts=($opts)
if [[ ${split_opts[0]} == "--cookies" ]]; then for i in "${split_opts[@]}"; do
subscriber_vod=1 if [[ $i == "--cookies" ]]; then
printf "${BOLD}Subscriber VOD. Will use yt-dlp to download.${NORMAL}\n" use_ytdlp=1
fi printf "${BOLD}Subscriber VOD. Will use yt-dlp to download.${NORMAL}\n"
fi
done
if [[ $shortname == "1" || $compress == "1" || $transcribe == "1" ]]; then if [[ $shortname == "1" || $compress == "1" || $transcribe == "1" ]]; then
printf "${BOLD}Downloading Twitch vid " printf "${BOLD}Downloading Twitch vid "
@@ -689,16 +808,19 @@ download_twitch_vid() {
# Get the video filename. # Get the video filename.
local filename=$(yt-dlp.exe --get-filename -f $yt_dlp_format -o "$name_format.%(ext)s" $opts $url) local filename=$(yt-dlp.exe --get-filename -f $yt_dlp_format -o "$name_format.%(ext)s" $opts $url)
filename=$(remove_extra_spaces "$filename")
printf "filename: $filename\n"
# Download # Download the video.
if [[ $subscriber_vod == "0" ]]; then if [[ $use_ytdlp == "1" ]]; then
local cmd="streamlink.exe --twitch-low-latency --twitch-disable-ads --twitch-disable-hosting --force --force-progress $opts $url $streamlink_format -O | ffmpeg -i pipe:0 -c copy \"$filename\"" printf "${YELLOW}${BOLD}\nUsing yt-dlp to download...${NORMAL}\n"
else opts+=" --embed-thumbnail --embed-metadata"
local cmd="yt-dlp.exe -f $yt_dlp_format -o \"$filename\" $opts $url" local cmd="yt-dlp.exe -f $yt_dlp_format -o \"$filename\" $opts $url"
else
printf "${YELLOW}${BOLD}\nUsing streamlink to download...${NORMAL}\n"
local cmd="streamlink.exe --twitch-low-latency --twitch-disable-ads --twitch-disable-hosting --force --progress=force $opts $url $streamlink_format -O | ffmpeg -i pipe:0 -c copy \"$filename\""
fi fi
printf "${YELLOW}${BOLD}Downloading video\n${NORMAL}"
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string. eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
error=$? error=$?
@@ -710,9 +832,9 @@ download_twitch_vid() {
if [[ $compress == "1" ]]; then if [[ $compress == "1" ]]; then
local temp_name="temp_${RANDOM}" local temp_name="temp_${RANDOM}"
# 0=cpu, 1=gpu
compress-video "$filename" "$temp_name" 0
extension="${filename##*.}" extension="${filename##*.}"
# 0=cpu, 1=gpu
compress-video "$filename" "$temp_name" 1
mv "$filename" "orig_$filename" mv "$filename" "orig_$filename"
mv $temp_name.$extension "$filename" mv $temp_name.$extension "$filename"
printf "${BOLD}Make sure to delete the original video file\n${NORMAL}" printf "${BOLD}Make sure to delete the original video file\n${NORMAL}"
@@ -725,6 +847,7 @@ 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.
@@ -732,20 +855,29 @@ download_twitch_vid() {
# e.g. --cookies cookies.txt --referer https://gillyandkeeves.tv https://player.vimeo.com/video/756941969 # e.g. --cookies cookies.txt --referer https://gillyandkeeves.tv https://player.vimeo.com/video/756941969
# The vid ID can be found by looking at the embed's iframe src attribute. # The vid ID can be found by looking at the embed's iframe src attribute.
download_vimeo_vid() { download_vimeo_vid() {
local shortname="$1" local format="$1"
local compress="$2" local shortname="$2"
local transcribe="$3" local compress="$3"
local format="$4" local transcribe="$4"
local make_folder="$5" local make_folder="$5"
local url="$6" local url="$6"
shift 5 shift 6
local opts="$@" local opts="$@"
if [[ $format == "" || $url == "" ]]; then if [[ $url == "" ]]; then
error "Usage: <format> <make folder?> <url> <optional args>" error "Usage: <make folder?> <url> <optional args>"
return return
fi fi
if [[ $format == "" ]]; then
printf "${BOLD}No format given; using best available.${NORMAL}\n"
# Download best mp4 video, best audio then merge.
format="bv[ext=mp4]+ba[ext=m4a]"
fi
# We're assuming we'll always have an mp4 video only and audio track to merge.
opts+=" --merge-output-format mp4 --write-subs --sub-lang en --embed-subs --embed-thumbnail --embed-metadata"
if [[ $shortname == "1" || $compress == "1" || $transcribe == "1" ]]; then if [[ $shortname == "1" || $compress == "1" || $transcribe == "1" ]]; then
printf "${BOLD}Downloading Vimeo vid " printf "${BOLD}Downloading Vimeo vid "
if [[ $shortname == "1" ]]; then printf "| ${YELLOW}using short name${NORMAL}${BOLD} "; fi if [[ $shortname == "1" ]]; then printf "| ${YELLOW}using short name${NORMAL}${BOLD} "; fi
@@ -769,9 +901,12 @@ download_vimeo_vid() {
local name_format="%(upload_date>%Y-%m-%d)s-shortname-vimeo-%(id)s" local name_format="%(upload_date>%Y-%m-%d)s-shortname-vimeo-%(id)s"
fi fi
# Download the video. # Get the video filename.
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url) local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
filename=$(remove_extra_spaces "$filename")
printf "filename: $filename\n"
# Download the video.
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url" local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string. eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
@@ -780,7 +915,7 @@ download_vimeo_vid() {
if [[ $compress == "1" ]]; then if [[ $compress == "1" ]]; then
local temp_name="temp_${RANDOM}" local temp_name="temp_${RANDOM}"
# 0=cpu, 1=gpu # 0=cpu, 1=gpu
compress-video "$filename" "$temp_name" 0 compress-video "$filename" "$temp_name" 1
extension="${filename##*.}" extension="${filename##*.}"
mv "$filename" "orig_$filename" mv "$filename" "orig_$filename"
mv $temp_name.$extension "$filename" mv $temp_name.$extension "$filename"
@@ -799,6 +934,7 @@ 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.
@@ -806,7 +942,7 @@ download_twitter_vid() {
local format="$1" local format="$1"
local make_folder="$2" local make_folder="$2"
local url="$3" local url="$3"
local vid_name="$4" local vid_name="$4" # optional
if [[ $url == "" ]]; then if [[ $url == "" ]]; then
error "Usage: <make folder?> <url> <optional filename> <optional args>" error "Usage: <make folder?> <url> <optional filename> <optional args>"
@@ -815,13 +951,26 @@ download_twitter_vid() {
printf "${BOLD}Downloading Twitter vid.${NORMAL}\n" printf "${BOLD}Downloading Twitter vid.${NORMAL}\n"
local opts=""
if [[ $# > 3 ]]; then
# Since the name is optional and we might pass options, like --cookie etc
# we need to check if the vid name is set to an option.
if [[ $vid_name == -* ]]; then
echo "vid name is an option"
shift 3
vid_name=""
opts="$@"
else
shift 4
opts="$@"
fi
fi
if [[ $vid_name == "" ]]; then if [[ $vid_name == "" ]]; then
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-twitter-%(id)s" local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-twitter-%(id)s"
local opts=""
else else
local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-twitter-%(id)s" local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-twitter-%(id)s"
shift 4
local opts="$@"
fi fi
if [[ $make_folder == "1" ]]; then if [[ $make_folder == "1" ]]; then
@@ -836,9 +985,13 @@ download_twitter_vid() {
format="b" format="b"
fi fi
# Download the video. # Get the video filename.
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url) local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
filename=$(remove_extra_spaces "$filename")
printf "filename: $filename\n"
# Download the video.
opts+=" --embed-thumbnail --embed-metadata"
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url" local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string. eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
@@ -850,15 +1003,17 @@ 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"
local url="$3" local url="$3"
local vid_name="$4" local vid_name="$4" # optional
if [[ $url == "" ]]; then if [[ $url == "" ]]; then
error "Usage: <make folder?> <url> <optional filename> <optional args>" error "Usage: <make folder?> <url> <optional filename> <optional args>"
@@ -867,13 +1022,26 @@ download_instagram_vid() {
printf "${BOLD}Downloading Instagram vid.${NORMAL}\n" printf "${BOLD}Downloading Instagram vid.${NORMAL}\n"
local opts=""
if [[ $# > 3 ]]; then
# Since the name is optional and we might pass options, like --cookie etc
# we need to check if the vid name is set to an option.
if [[ $vid_name == -* ]]; then
echo "vid name is an option"
shift 3
vid_name=""
opts="$@"
else
shift 4
opts="$@"
fi
fi
if [[ $vid_name == "" ]]; then if [[ $vid_name == "" ]]; then
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-ig-%(id)s" local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-ig-%(id)s"
local opts=""
else else
local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-ig-%(id)s" local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-ig-%(id)s"
shift 4
local opts="$@"
fi fi
if [[ $make_folder == "1" ]]; then if [[ $make_folder == "1" ]]; then
@@ -885,9 +1053,13 @@ download_instagram_vid() {
format="b" # best available format="b" # best available
# Download the video. # Get the video filename.
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url) local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
filename=$(remove_extra_spaces "$filename")
printf "filename: $filename\n"
# Download the video.
opts+=" --embed-thumbnail --embed-metadata"
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url" local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string. eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
@@ -905,6 +1077,7 @@ 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.
@@ -928,11 +1101,15 @@ download_mp4() {
fi fi
mv $temp_name "$filename.mp4" mv $temp_name "$filename.mp4"
flash_taskbar
} }
# Download from m3u8 stream to mp4. # Download a stream to mp4. Can be from an m3u8 file, an mpd, etc. Whatever the
# You can supply a local file or a URL to the m3u8 file. If the request requires cookies then the easiest way to do it is to # supported extensions are from ffmpeg.
# run the ffmpeg command yourself using this as the example format: #
# You can supply a local file or a URL to the stream file. If the request
# requires cookies then the easiest way to do it is to run the ffmpeg command
# yourself using this as the example format:
# #
# ffmpeg -protocol_whitelist file,https,crypto,tls,tcp -headers $'Cookie: CloudFront-Policy=ayJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly92aWRlby5zdGVsbGFydGlja2V0cy5jb20vb3JnYW5pemF0aW9ucy8yYWQ0YTBhYi1iZWM3LTQ4NjMtYTBmMS0zNjI0N2NjODNkMjMvdHJhbnNjb2RlZC85MWFmYjI4MS0wNy0yMC0yM19LcmF6YW1fUHJlc2VudHMqIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNjkwNDk4ODAwfSwiSXBBZGRyZXNzIjp7IkFXUzpTb3VyY2VJcCI6IjY0LjEzNy4xNDkuMTkzLzMyIn19LCJTdHJlYW1Ub2tlbklkIjoiOTJlMTg2ZjUtZWZiMS00ZDAzLWE0NGQtZTg3YzQ3NzFiODI2IiwiU3RyZWFtVG9rZW5WaWV3ZXJJZCI6Ijg3NzFlMTBhLTcxNjUtNDcxOS1iMjFiLTkwNjljZDgzNzdhYyIsIlN0cmVhbVRva2VuVmlld2VyVHlwZSI6IkN1c3RvbWVyIiwiU3RyZWFtVG9rZW5SZXNvdXJjZUlkIjoiZDY3Mzc4NWMtNDEzNy00MDRhLTkzZjctNjQxN2Q4MmY2NmUxIiwiU3RyZWFtVG9rZW5SZXNvdXJjZVR5cGUiOiJWaWRlb09uRGVtYW5kIn1dfQ__; CloudFront-Signature=H0RwSHRX9y4PIqbAmxtEoGEPbO5da%7EW764sbHBXcPwnSSuq5PcjPM2UuP1YKL%7E92WcRTEiJ9FMDVbxNtPDZea2lCk9txvpHdmn7BBy6JNwKd-%7ED9RKq3SSqB00O8P1VkztKtkALYgn8lq3ihk7Nss0wYE9WxgvNNU30umcP-wSHFtuiGsbArivbWvu639Ku5bkfwm8azXI9hvz5D7OtwSyo3z%7E8trw3rALDwCgHZiqQrEQtfN4NYAWZ%7EuzdcGRgdUVmMQotBHG0WpPDItqBR9RLVel%7EWB0mQOO3Dax9DnGHlBaBs5mdR28NqOj8XCY4pAhguJQlERcANIK2WXm56dA__; CloudFront-Key-Pair-Id=APK3IWIJLRLBNXI2PR4Q\r\n' -i https://video.stellartickets.com/organizations/2ad4a0ac-bec7-4863-a0f1-36247cc83d23/transcoded/91afb281-07-20-23_Krazam_Presents_index_1080p_20230721T024151_1.m3u8 -acodec copy -vcodec copy krazam.mp4 # ffmpeg -protocol_whitelist file,https,crypto,tls,tcp -headers $'Cookie: CloudFront-Policy=ayJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly92aWRlby5zdGVsbGFydGlja2V0cy5jb20vb3JnYW5pemF0aW9ucy8yYWQ0YTBhYi1iZWM3LTQ4NjMtYTBmMS0zNjI0N2NjODNkMjMvdHJhbnNjb2RlZC85MWFmYjI4MS0wNy0yMC0yM19LcmF6YW1fUHJlc2VudHMqIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNjkwNDk4ODAwfSwiSXBBZGRyZXNzIjp7IkFXUzpTb3VyY2VJcCI6IjY0LjEzNy4xNDkuMTkzLzMyIn19LCJTdHJlYW1Ub2tlbklkIjoiOTJlMTg2ZjUtZWZiMS00ZDAzLWE0NGQtZTg3YzQ3NzFiODI2IiwiU3RyZWFtVG9rZW5WaWV3ZXJJZCI6Ijg3NzFlMTBhLTcxNjUtNDcxOS1iMjFiLTkwNjljZDgzNzdhYyIsIlN0cmVhbVRva2VuVmlld2VyVHlwZSI6IkN1c3RvbWVyIiwiU3RyZWFtVG9rZW5SZXNvdXJjZUlkIjoiZDY3Mzc4NWMtNDEzNy00MDRhLTkzZjctNjQxN2Q4MmY2NmUxIiwiU3RyZWFtVG9rZW5SZXNvdXJjZVR5cGUiOiJWaWRlb09uRGVtYW5kIn1dfQ__; CloudFront-Signature=H0RwSHRX9y4PIqbAmxtEoGEPbO5da%7EW764sbHBXcPwnSSuq5PcjPM2UuP1YKL%7E92WcRTEiJ9FMDVbxNtPDZea2lCk9txvpHdmn7BBy6JNwKd-%7ED9RKq3SSqB00O8P1VkztKtkALYgn8lq3ihk7Nss0wYE9WxgvNNU30umcP-wSHFtuiGsbArivbWvu639Ku5bkfwm8azXI9hvz5D7OtwSyo3z%7E8trw3rALDwCgHZiqQrEQtfN4NYAWZ%7EuzdcGRgdUVmMQotBHG0WpPDItqBR9RLVel%7EWB0mQOO3Dax9DnGHlBaBs5mdR28NqOj8XCY4pAhguJQlERcANIK2WXm56dA__; CloudFront-Key-Pair-Id=APK3IWIJLRLBNXI2PR4Q\r\n' -i https://video.stellartickets.com/organizations/2ad4a0ac-bec7-4863-a0f1-36247cc83d23/transcoded/91afb281-07-20-23_Krazam_Presents_index_1080p_20230721T024151_1.m3u8 -acodec copy -vcodec copy krazam.mp4
# #
@@ -943,17 +1120,17 @@ download_mp4() {
# #
# If you need to debug the http request then add "-v trace" to the command above. # If you need to debug the http request then add "-v trace" to the command above.
# #
download_mp4_from_m3u8() { download_mp4_from_stream() {
local m3u8_path="$1" local stream_path="$1"
local filename="$2" local filename="$2"
if [[ $m3u8_path == "" || $filename == "" ]]; then if [[ $stream_path == "" || $filename == "" ]]; then
error "Usage: <m3u8 path> <filename>" error "Usage: <stream path> <filename>"
return return
fi fi
printf "${BOLD}Downloading: ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Downloading: ${YELLOW}$filename${NORMAL}\n"
ffmpeg.exe -protocol_whitelist file,https,crypto,tls,tcp -i $m3u8_path -acodec copy -vcodec copy "${filename}.mp4" ffmpeg.exe -protocol_whitelist file,data,https,crypto,tls,tcp -allowed_extensions ALL -i $stream_path -acodec copy -vcodec copy "${filename}.mp4"
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
error "Error: failed to download." error "Error: failed to download."
@@ -961,20 +1138,21 @@ download_mp4_from_m3u8() {
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.
download_aac_from_m3u8() { download_aac_from_stream() {
local m3u8_path="$1" local stream_path="$1"
local filename="$2" local filename="$2"
if [[ $m3u8_path == "" || $filename == "" ]]; then if [[ $stream_path == "" || $filename == "" ]]; then
error "Usage: <m3u8 path> <filename>" error "Usage: <stream path> <filename>"
return return
fi fi
printf "${BOLD}Downloading: ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Downloading: ${YELLOW}$filename${NORMAL}\n"
ffmpeg.exe -protocol_whitelist file,https,crypto,tls,tcp -i $m3u8_path -acodec copy "${filename}.aac" ffmpeg.exe -protocol_whitelist file,https,crypto,tls,tcp -i $stream_path -acodec copy "${filename}.aac"
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
error "Error: failed to download." error "Error: failed to download."
@@ -982,6 +1160,7 @@ download_aac_from_m3u8() {
fi fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
@@ -993,29 +1172,55 @@ alias yt-list-desc='download_youtube_uploads_list 1 '
alias yt='download_youtube_vid "" $SHORTNAME_OFF $TRANSCRIBE_OFF' alias yt='download_youtube_vid "" $SHORTNAME_OFF $TRANSCRIBE_OFF'
alias yt-shortname='download_youtube_vid "" $SHORTNAME_ON $TRANSCRIBE_OFF' alias yt-shortname='download_youtube_vid "" $SHORTNAME_ON $TRANSCRIBE_OFF'
alias yt-1080='download_youtube_vid "137+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
alias yt-1080-shortname='download_youtube_vid "137+140" $SHORTNAME_ON $TRANSCRIBE_OFF' alias yt-4k='download_youtube_vid "625+234" $SHORTNAME_OFF $TRANSCRIBE_OFF'
alias yt-720='download_youtube_vid "136+140" $SHORTNAME_OFF $TRANSCRIBE_OFF' alias yt-4k-shortname='download_youtube_vid "625+234" $SHORTNAME_ON $TRANSCRIBE_OFF'
alias yt-720-shortname='download_youtube_vid "136+140" $SHORTNAME_ON $TRANSCRIBE_OFF'
alias yt-1440='download_youtube_vid "620+234" $SHORTNAME_OFF $TRANSCRIBE_OFF'
alias yt-1440p60='download_youtube_vid "400+234" $SHORTNAME_OFF $TRANSCRIBE_OFF'
alias yt-1440-shortname='download_youtube_vid "620+234" $SHORTNAME_OFF $TRANSCRIBE_OFF'
# Premium
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'
# Normal
alias yt-1080='download_youtube_vid "137+ba[ext=m4a]" $SHORTNAME_OFF $TRANSCRIBE_OFF'
alias yt-1080-shortname='download_youtube_vid "137+ba[ext=m4a]" $SHORTNAME_ON $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'
#TRANSCRIPTION ON #TRANSCRIPTION ON
alias ytt='download_youtube_vid "" $SHORTNAME_OFF $TRANSCRIBE_ON' alias ytt='download_youtube_vid "" $SHORTNAME_OFF $TRANSCRIBE_ON'
alias yt-shortname-t='download_youtube_vid "" $SHORTNAME_ON $TRANSCRIBE_ON' alias yt-shortname-t='download_youtube_vid "" $SHORTNAME_ON $TRANSCRIBE_ON'
alias yt-1080-t='download_youtube_vid "137+140" $SHORTNAME_OFF $TRANSCRIBE_ON' alias yt-4k-t='download_youtube_vid "625+234" $SHORTNAME_OFF $TRANSCRIBE_ON'
alias yt-1080-shortname-t='download_youtube_vid "137+140" $SHORTNAME_ON $TRANSCRIBE_ON' alias yt-4k-shortname-t='download_youtube_vid "625+234" $SHORTNAME_ON $TRANSCRIBE_ON'
alias yt-720-t='download_youtube_vid "136+140" $SHORTNAME_OFF $TRANSCRIBE_ON' alias yt-1440-t='download_youtube_vid "620+234" $SHORTNAME_OFF $TRANSCRIBE_ON'
alias yt-720-shortname-t='download_youtube_vid "136+140" $SHORTNAME_ON $TRANSCRIBE_ON' alias yt-1440-shortname-t='download_youtube_vid "620+234" $SHORTNAME_ON $TRANSCRIBE_ON'
alias yt-1080p-t='download_youtube_vid "616+234" $SHORTNAME_OFF $TRANSCRIBE_ON'
alias yt-1080p-shortname-t='download_youtube_vid "616+234" $SHORTNAME_ON $TRANSCRIBE_ON'
alias yt-1080-t='download_youtube_vid "270+234" $SHORTNAME_OFF $TRANSCRIBE_ON'
alias yt-1080-shortname-t='download_youtube_vid "270+234" $SHORTNAME_ON $TRANSCRIBE_ON'
alias yt-720-t='download_youtube_vid "136+234" $SHORTNAME_OFF $TRANSCRIBE_ON'
alias yt-720-shortname-t='download_youtube_vid "136+234" $SHORTNAME_ON $TRANSCRIBE_ON'
#--------------------------- #---------------------------
alias yt-playlist='download_youtube_playlist ""' alias yt-playlist='download_youtube_playlist ""'
alias yt-playlist-audio='download_youtube_playlist "234"'
alias yt-playlist-4k='download_youtube_playlist "625+234"'
alias yt-playlist-1440='download_youtube_playlist "620+234"'
alias yt-playlist-1080p='download_youtube_playlist "616+234"'
alias yt-playlist-1080='download_youtube_playlist "270+234"'
alias yt-playlist-720='download_youtube_playlist "136+234"'
alias yt-playlist-tiny='download_youtube_playlist "160+234"'
alias yt-playlist-list='download_youtube_playlist_list ' alias yt-playlist-list='download_youtube_playlist_list '
alias yt-playlist-1080='download_youtube_playlist "137+140"' #---------------------------
alias yt-playlist-720='download_youtube_playlist "136+140"'
alias yt-playlist-tiny='download_youtube_playlist "160+140"'
alias yt-audio='download_youtube_audio' alias yt-audio='download_youtube_audio'
#------------------------------------------------- #-------------------------------------------------
# Twitch Vid DL # Twitch Vid DL
#------------------------------------------------- #-------------------------------------------------
alias tw-chat='download_twitch_chat' alias tw-chat='download_twitch_chat'
alias twc='download_twitch_chat 1'
alias tw='download_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_OFF $TRANSCRIBE_OFF' alias tw='download_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_OFF $TRANSCRIBE_OFF'
alias tw-compressed='download_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF' alias tw-compressed='download_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
@@ -1088,16 +1293,16 @@ alias tw-4k-shortname-compressed-t='download_twitch_vi "2160p" $SHORTNAM
#------------------------------------------------- #-------------------------------------------------
# Vimeo Vid DL # Vimeo Vid DL
#------------------------------------------------- #-------------------------------------------------
alias vimeo='download_vimeo_vid $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF' alias vimeo='download_vimeo_vid "" $SHORTNAME_OFF $COMPRESSION_OFF $TRANSCRIBE_OFF'
alias vimeo-t='download_vimeo_vid $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON' alias vimeo-t='download_vimeo_vid "" $SHORTNAME_OFF $COMPRESSION_OFF $TRANSCRIBE_ON'
alias vimeo-compressed='download_vimeo_vid $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF' alias vimeo-compressed='download_vimeo_vid "" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias vimeo-compressed-t='download_vimeo_vid $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON' alias vimeo-compressed-t='download_vimeo_vid "" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
#------------------------------------------------- #-------------------------------------------------
# Instagram Vid DL # Instagram Vid DL
#------------------------------------------------- #-------------------------------------------------
alias ig='download_instagram_vid $TRANSCRIBE_OFF' alias ig='echo using my accounts with cookies to dl ig vids makes instagram think i am a bot and they might close my account. do not use your accounts; download_instagram_vid $TRANSCRIBE_OFF'
alias igt='download_instagram_vid $TRANSCRIBE_ON' alias igt='echo using my accounts with cookies to dl ig vids makes instagram think i am a bot and they might close my account. do not use your accounts' #download_instagram_vid $TRANSCRIBE_ON'
#------------------------------------------------- #-------------------------------------------------
# Twitter Vid DL # Twitter Vid DL
@@ -1108,37 +1313,50 @@ alias twitter='download_twitter_vid "" '
# Misc # Misc
#------------------------------------------------- #-------------------------------------------------
alias download-mp4='download_mp4' alias download-mp4='download_mp4'
alias download-from-m3u8='download_mp4_from_m3u8' alias download-from-stream='download_mp4_from_stream'
alias download-audio-from-m3u8='download_aac_from_m3u8' alias download-audio-from-stream='download_aac_from_stream'
alias download-audio-from-m3u8='echo Use download-audio-from-stream instead.'
#################################################################################################### ####################################################################################################
# Video Compression # Video Compression
#################################################################################################### ####################################################################################################
function _compress_video_hard() { alias cv='compress-video'
local crf=35 alias jv='join-video'
local name="$1" alias av='analyze-volume'
local out="$2" alias aa='analyze-volume'
if [[ name == "" || out == "" ]]; then alias nv='normalize-volume'
error "Usage: cmd <source> <dest>" alias na='normalize-volume'
alias tv='echo can just do a cv with a time range...' #trim-video-vbr'
function compress_and_normalize_volume() {
local final_name="$1"
shift 1
local opts="$@"
if [[ $final_name == "" ]]; then
error "Provide a final file name and optional args for compress-video"
return return
fi fi
# 0=cpu, 1=gpu compress-video f.mp4 ff $opts ; normalize-volume ff.mp4 "$final_name" ; flash_taskbar
compress-video-with-crf $crf "$name" "$out" 0
} }
alias compress-video-hard='_compress_video_hard' 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"
fi fi
# Performs a commit amend with the nocheckin prehook disabled.
git_amend_nocheckin() {
eval "DISABLE_NOCHECKIN=1 git commit --amend"
}
git_cmd_wrapper() { git_cmd_wrapper() {
# If no args are provided then run `git status -s` # If no args are provided then run `git status -s`
if [[ $# > 0 ]]; then if [[ $# > 0 ]]; then
@@ -1164,6 +1382,7 @@ git_commit_signed() {
eval "$cmd" eval "$cmd"
} }
# Performs a commit amend to the head with the nocheckin prehook disabled.
git_fix_nocheckin() { git_fix_nocheckin() {
eval "DISABLE_NOCHECKIN=1 git commit --amend -C HEAD" eval "DISABLE_NOCHECKIN=1 git commit --amend -C HEAD"
} }
@@ -1184,11 +1403,23 @@ git_create_stash_patch() {
printf "${BOLD}${YELLOW}Created $file for stash@{$stashNum}.${NORMAL}\n" printf "${BOLD}${YELLOW}Created $file for stash@{$stashNum}.${NORMAL}\n"
} }
git_print_tracked_file_sizes() {
git ls-tree -r -l HEAD | sort -k 4 -nr | awk '{
sha = substr($3, 1, 7); # Truncate the commit SHA to 7 characters
if ($4 >= 1024 * 1024) {
printf "%s sha:%s %06.2f MB %s\n", $2, sha, $4 / 1024 / 1024, $5
} else if ($4 >= 1024) {
printf "%s sha:%s %06.2f KB %s\n", $2, sha, $4 / 1024, $5
} else {
printf "%s sha:%s %04d B %s\n", $2, sha, $4, $5
}
}'
}
alias am='git commit --amend' alias am='git commit --amend'
alias amno='git_amend_nocheckin'
alias ama='git commit --amend -C head --author' alias ama='git commit --amend -C head --author'
alias ams='git commit -S --amend' # signed alias ams='git commit -S --amend' # signed
alias ammend='echo "use am instead"'
alias amend='echo "use am instead"'
alias g='git_cmd_wrapper' alias g='git_cmd_wrapper'
alias ga='git add -A' alias ga='git add -A'
alias gaa='git add -A; gdcc' alias gaa='git add -A; gdcc'
@@ -1226,12 +1457,16 @@ alias gf='git fetch'
alias gfa='git fetch --all' alias gfa='git fetch --all'
alias gfd='git fetch --prune' # Removes remote branches that don't have a counterpart branch on the remote. alias gfd='git fetch --prune' # Removes remote branches that don't have a counterpart branch on the remote.
alias gfix='git commit --amend -C HEAD' alias gfix='git commit --amend -C HEAD'
alias gfx='git commit --amend -C HEAD'
alias gfixs='git commit -S -a --amend -C HEAD' # signed alias gfixs='git commit -S -a --amend -C HEAD' # signed
alias gfxs='git commit -S -a --amend -C HEAD' # signed
alias gfixno='git_fix_nocheckin' alias gfixno='git_fix_nocheckin'
alias gfxno='git_fix_nocheckin'
alias gfo='git fetch origin' alias gfo='git fetch origin'
alias gfu='git fetch up' alias gfu='git fetch up'
alias gfm='git fetch origin master' alias gfm='git fetch origin master'
alias gfup='git fetch upstream' alias gfup='git fetch upstream'
alias ggcf='git gc --prune=now'
alias ggrep='git log --all --oneline | grep ' alias ggrep='git log --all --oneline | grep '
alias gla='git lg --all' alias gla='git lg --all'
alias gl='git lg -30' alias gl='git lg -30'
@@ -1246,8 +1481,8 @@ alias gmffm='git merge --ff-only master'
alias gmffs='git merge --ff-only --squash' alias gmffs='git merge --ff-only --squash'
alias gmtheirs='git merge -Xtheirs' alias gmtheirs='git merge -Xtheirs'
alias gp='git push' alias gp='git push'
alias gpa='git push --all && echo "pushing tags..." && git push --tags' alias gpa='echo "pushing all branches..." && git push --all && echo "pushing tags..." && git push --tags'
alias gpaf='git push --all -f && echo "pushing tags..." && git push --tags -f' alias gpaf='echo "force pushing all branches..." && git push --all -f && echo "force pushing tags..." && git push --tags -f'
alias gpf='git push -f' alias gpf='git push -f'
alias gpff='git pull --ff-only' alias gpff='git pull --ff-only'
alias gplu='git pull --set-upstream origin HEAD' alias gplu='git pull --set-upstream origin HEAD'
@@ -1256,6 +1491,7 @@ alias gpo='git push origin'
alias gpom='git push origin master' alias gpom='git push origin master'
alias gpr='git pull --rebase' alias gpr='git pull --rebase'
alias gpt='git push --tags' alias gpt='git push --tags'
alias gptf='git push --tags -f'
alias gpu='git push --set-upstream origin HEAD' alias gpu='git push --set-upstream origin HEAD'
alias gr='git reset' alias gr='git reset'
alias gr1='git reset HEAD^1' alias gr1='git reset HEAD^1'
@@ -1292,6 +1528,7 @@ alias gsd='git stash drop'
alias gsl='git stash list' alias gsl='git stash list'
alias gsi='git stash -p' alias gsi='git stash -p'
alias gsp='git stash pop' alias gsp='git stash pop'
alias gspm='git stash pop --merge'
alias gsp0='git stash pop stash@{0}' alias gsp0='git stash pop stash@{0}'
alias gsp1='git stash pop stash@{1}' alias gsp1='git stash pop stash@{1}'
alias gsp2='git stash pop stash@{2}' alias gsp2='git stash pop stash@{2}'
@@ -1308,6 +1545,7 @@ alias gx='git reset --hard'
alias gxx='git reset --hard HEAD~1' alias gxx='git reset --hard HEAD~1'
alias gxom='git reset --hard origin/master' alias gxom='git reset --hard origin/master'
alias gstats='echo "Total commits: $(git rev-list HEAD --count)"; echo "\nAuthor breakdown:"; git shortlog | grep -E "^[^ ]"' alias gstats='echo "Total commits: $(git rev-list HEAD --count)"; echo "\nAuthor breakdown:"; git shortlog | grep -E "^[^ ]"'
alias gsize='git_print_tracked_file_sizes'
alias gwip="git add . && git commit -m \"WIP\"" alias gwip="git add . && git commit -m \"WIP\""
#################################################################################################### ####################################################################################################

View File

@@ -1,12 +1,15 @@
[include] [include]
path = ~/.gitconfig.private # Shared config from private dotfiles
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 = ~/.gitignore.global excludesfile = ~/.private-dotfiles.common/gitignore
hookspath = ~/.git_hooks hookspath = ~/.git_hooks
preloadindex = true preloadindex = true
fscache = true fscache = true

View File

@@ -22,7 +22,7 @@
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' " Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" "
" " On-demand loading " " On-demand loading
" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } " Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
" Plug 'tpope/vim-fireplace', { 'for': 'clojure' } " Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" "
" " Using a non-default branch " " Using a non-default branch

View File

@@ -15,29 +15,32 @@ endif
set background=dark set background=dark
hi clear hi clear
syntax reset if exists("syntax_on")
syntax reset
endif
source $HOME/.vim/colors/utils source $HOME/.vim/colors/utils
let g:colors_name = "campo-dark-blue" let g:colors_name = "campo-dark-blue"
" Shared colors " Shared colors
let s:blue = "3699cc" let s:blue = "3699cc"
let s:purple = "ce93d8" let s:purple = "ce93d8"
let s:grey = "b0bec5" let s:grey = "b0bec5"
let s:orange = "ffb74d" let s:orange = "ffb74d"
let s:yellow = "fff176" let s:yellow = "fff176"
let s:green = "88b888" let s:green = "88b888"
let s:red = "ef2929" let s:red = "ef2929"
let s:text = "f1f1e8" " A majority of the syntax will use this. let s:text = "f1f1e8" " A majority of the syntax will use this.
let s:bg = "072730" let s:bg = "072730"
let s:select = "546e8f" let s:select = "546e8f"
let s:window = "37474f" let s:window = "37474f"
let s:comment = "5dea82" let s:comment = "5dea82"
let s:tab = "03404a" let s:annotated_note = "8dea82"
let s:error = "e40e0e" let s:tab = "03404a"
let s:proc = "0eefcb" let s:error = "e40e0e"
let s:warn = "dcd53e" let s:proc = "0eefcb"
let s:spell = "aaf53e" let s:warn = "dcd53e"
let s:spell = "aaf53e"
" Vim " Vim
call X("Normal", s:text, s:bg, "") call X("Normal", s:text, s:bg, "")
@@ -83,7 +86,7 @@ call X("Identifier", s:grey, "", "none")
call X("Statement", s:text, "", "") " 'return', 'goto', 'case', 'break', etc call X("Statement", s:text, "", "") " 'return', 'goto', 'case', 'break', etc
call X("Conditional", s:text, "", "") call X("Conditional", s:text, "", "")
call X("Repeat", s:text, "", "") " 'for' and 'while' call X("Repeat", s:text, "", "") " 'for' and 'while'
call X("Structure", "ae90ea", "", "") call X("Structure", "ae90ea", "", "") " enum, struct, union
call X("Function", s:proc, "", "") call X("Function", s:proc, "", "")
call X("Constant", s:text, "", "") " Constants, e.g. SOME_CONST call X("Constant", s:text, "", "") " Constants, e.g. SOME_CONST
call X("Boolean", s:text, "", "") " true, false call X("Boolean", s:text, "", "") " true, false
@@ -96,11 +99,12 @@ call X("Define", "a5bce4", "", "none")
call X("Include", s:text, "", "") " #include in C/C++ call X("Include", s:text, "", "") " #include in C/C++
call X("Number", s:text, "", "") call X("Number", s:text, "", "")
" Notes " Notes and annotated comment text
call X("Todo", "b8fbb0", s:bg, "underline") call X("MyTitle", s:text, "", "bold") " // # Some Title
call X("Bugs", "d8fbb0", s:bg, "standout") call X("MyAnnotatedNote", s:text, "", "bold") " // @incomplete
call X("Notes", "ffffff", s:bg, "standout") call X("MyNote", s:annotated_note, "", "standout") " // NOTE:, IDEA:, TODO:
call X("Notices", s:warn, s:bg, "bold") call X("MyEmphasis", s:yellow, "", "bold") " // WARNING:, IMPORTANT:
call X("MyBug", s:red, "", "standout") " // FIXME:, BUG:, DEPRECATED:
" Build markers " Build markers
call X("BuildError", s:error, s:bg, "bold") call X("BuildError", s:error, s:bg, "bold")
@@ -123,31 +127,6 @@ call X("cStorageClass", s:text, "", "")
call X("cConditional", s:text, "", "") call X("cConditional", s:text, "", "")
call X("cRepeat", s:text, "", "") call X("cRepeat", s:text, "", "")
" Python Highlighting
call X("pythonInclude", s:red, "", "")
call X("pythonStatement", s:blue, "", "")
call X("pythonConditional", s:purple, "", "")
call X("pythonRepeat", s:purple, "", "")
call X("pythonException", s:purple, "", "")
call X("pythonFunction", s:proc, "", "")
call X("pythonSelf", s:grey, "", "")
call X("pythonOperator", s:purple, "", "")
call X("pythonExtraOperator", s:purple, "", "")
call X("pythonClass", s:proc, "", "")
call X("pythonDecorator", s:orange, "", "")
call X("pythonDocstring", s:comment, "", "")
call X("pythonBuiltinObj", s:yellow, "", "")
call X("pythonBuiltinType", s:orange, "", "")
call X("pythonNumber", s:orange, "", "")
" JS Highlighting
call X("javaScriptBraces", s:text, "", "")
call X("javaScriptFunction", s:purple, "", "")
call X("javaScriptConditional", s:purple, "", "")
call X("javaScriptRepeat", s:purple, "", "")
call X("javaScriptNumber", s:orange, "", "")
call X("javaScriptMember", s:orange, "", "")
" HTML Highlighting " HTML Highlighting
call X("htmlTag", s:text, "", "") call X("htmlTag", s:text, "", "")
call X("htmlTagName", s:text, "", "") call X("htmlTagName", s:text, "", "")

View File

@@ -0,0 +1,136 @@
" A simple dark earth-tone vim colorscheme.
" Created by Michael Campagnaro (https://git.michael.is)
if has('termguicolors')
" Supports 24-bit color range
set termguicolors
else
echoerr "This theme requires 'termguicolors' support!"
endif
if !has("gui_running") && &t_Co != 88 && &t_Co != 256
echoerr "Don't have expected color support!"
endif
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
source $HOME/.vim/colors/utils
let g:colors_name = "campo-dark-earth"
" Shared colors
let s:blue = "3699cc"
let s:purple = "ce93d8"
let s:grey = "b0bec5"
let s:orange = "ffb74d"
let s:yellow = "fff176"
let s:green = "88b888"
let s:red = "ef2929"
let s:text = "e5d8d0" " A majority of the syntax will use this.
let s:bg = "24252a"
let s:select = "614853"
let s:window = "1f2126"
let s:comment = "888984"
let s:annotated_note = "aaaba6"
let s:tab = "3d2a38"
let s:error = "e40e0e"
let s:proc = s:text
let s:warn = "dcd53e"
let s:spell = "aaf53e"
let s:soft_red = "9a5d6e"
let s:cursor_line = "2a2a2d"
" Vim
call X("Normal", s:text, s:bg, "")
call X("LineNr", s:comment, "", "")
call X("NonText", s:text, "", "")
call X("SpecialKey", s:blue, "", "")
call X("Search", s:text, s:select, "")
call X("TabLineSel", s:text, s:bg, "bold")
call X("TabLine", "dddddd", s:tab, "none")
call X("TabLineFill", "", s:tab, "none") " The tab line region that doesn't contain tab entries.
call X("StatusLine", s:window, s:text, "reverse")
call X("StatusLineNC", s:window, s:comment, "reverse")
call X("VertSplit", s:window, s:window, "none")
call X("Visual", "", s:select, "")
call X("Directory", s:blue, "", "")
call X("ModeMsg", s:green, "", "")
call X("MoreMsg", s:green, "", "")
call X("Question", s:green, "", "")
call X("MatchParen", "", s:select, "")
call X("Folded", s:comment, s:bg, "")
call X("FoldColumn", s:comment, s:bg, "")
call X("SpellBad", s:spell, s:bg, "bold")
call X("SpellCap", s:text, s:bg, "") " A word that should start with a capital
call X("SpellLocal", s:spell, s:bg, "bold") " Correctly spelled but used in another region.
call X("SpellRare", s:text, s:bg, "") " A correctly spelled that is hardly ever used. Don't care about this.
call X("ErrorMsg", s:error, s:bg, "bold")
if version >= 700
call X("PMenu", s:text, s:select, "none") " Autocompletion menu
call X("PMenuSel", s:text, "926975", "bold") " Selected autocompletion item
call X("SignColumn", "", s:bg, "none")
call X("CursorLine", "", s:cursor_line, "none") " Horizontal line at the cursor.
call X("CursorColumn", "", s:cursor_line, "none") " Vertical line at the cursor.
end
if version >= 703
call X("ColorColumn", "", s:cursor_line, "none") " Vertical line set by colorcolumn option.
end
" Standard Highlighting
call X("Comment", s:comment, "", "")
call X("Title", s:comment, "", "")
call X("Cursor", "", s:text, "")
call X("Identifier", s:soft_red, "", "none")
call X("Statement", s:soft_red, "", "") " 'return', 'goto', 'case', 'break', etc
call X("Conditional", s:soft_red, "", "")
call X("Repeat", s:text, "", "") " 'for' and 'while'
call X("Structure", s:soft_red, "", "") " enum, struct, union
call X("Function", s:proc, "", "")
call X("Constant", s:text, "", "") " Constants, e.g. SOME_CONST
call X("Boolean", s:text, "", "") " true, false
call X("String", "bba76a", "", "")
call X("Special", s:text, "", "")
call X("PreProc", s:text, "", "")
call X("Operator", s:text, "", "none")
call X("Type", s:text, "", "") " Data types
call X("Define", s:text, "", "none")
call X("Include", s:text, "", "") " #include in C/C++
call X("Number", s:soft_red, "", "")
" Notes and annotated comment text
call X("MyTitle", s:annotated_note, "", "bold") " // # Some Title
call X("MyAnnotatedNote", s:annotated_note, "", "bold") " // @incomplete
call X("MyNote", s:soft_red, "", "standout") " // NOTE:, IDEA:, TODO:
call X("MyEmphasis", s:yellow, "", "bold") " // WARNING:, IMPORTANT:
call X("MyBug", s:red, "", "standout") " // FIXME:, BUG:, DEPRECATED:
" Build markers
call X("BuildError", s:error, s:bg, "bold")
call X("BuildWarn", s:warn, s:bg, "bold")
call X("BuildInfo", s:text, s:bg, "bold")
" Jai Highlighting
call X("jaiVariableDeclaration", s:text, "", "")
call X("jaiDirective", s:soft_red, "", "")
" airblade/vim-gitgutter
call X("GitGutterAdd", s:green, "", "")
call X("GitGutterDelete", s:red, "", "")
call X("GitGutterChange", s:yellow, "", "")
call X("GitGutterChangeDelete", s:orange, "", "")
" C Highlighting
call X("cType", s:text, "", "")
call X("cStorageClass", s:text, "", "")
call X("cConditional", s:text, "", "")
call X("cRepeat", s:text, "", "")
" Diff Highlighting
call X("DiffAdd", s:window, s:green, "none")
call X("DiffDelete", s:window, s:red, "none")
call X("DiffChange", s:window, s:yellow, "none")
call X("DiffText", s:bg, s:yellow, "none")

View File

@@ -5,6 +5,8 @@
" The theme file original copied from the Tomorrow theme. " The theme file original copied from the Tomorrow theme.
" See https://github.com/chriskempson/vim-tomorrow-theme.git for it. " See https://github.com/chriskempson/vim-tomorrow-theme.git for it.
" Hex color conversion functions borrowed from the theme "Desert256". " Hex color conversion functions borrowed from the theme "Desert256".
"
" @todo convert to new format (see campo-dark-blue.vim)
if has('termguicolors') if has('termguicolors')
" Supports 24-bit color range " Supports 24-bit color range

View File

@@ -7,7 +7,8 @@
" Hex color conversion functions borrowed from the theme "Desert256". " Hex color conversion functions borrowed from the theme "Desert256".
" @TODO port these colors over to a copy of campo-dark-greyscale so that I " @TODO port these colors over to a copy of campo-dark-greyscale so that I
" have better control over the C syntax highlighting. " have better control over the C syntax highlighting. And use the improved
" format used in campo-dark-blue.vim
if has('termguicolors') if has('termguicolors')

View File

@@ -3,6 +3,8 @@
" Version: 1.0 " Version: 1.0
" "
" Hex color conversion functions borrowed from the theme "Desert256". " Hex color conversion functions borrowed from the theme "Desert256".
"
" @todo convert to new format (see campo-dark-blue.vim)
if has('termguicolors') if has('termguicolors')
" Supports 24-bit color range " Supports 24-bit color range

View File

@@ -1,6 +1,7 @@
" A very simple light colorscheme. " A very simple light colorscheme.
" Maintainer: Michael Campagnaro <mikecampo@gmail.com> " Maintainer: Michael Campagnaro <mikecampo@gmail.com>
" Version: 1.0 " Version: 1.0
"
if has('termguicolors') if has('termguicolors')
" Supports 24-bit color range " Supports 24-bit color range

View File

@@ -5,6 +5,8 @@
" The theme file original copied from the Tomorrow theme. " The theme file original copied from the Tomorrow theme.
" See https://github.com/chriskempson/vim-tomorrow-theme.git for it. " See https://github.com/chriskempson/vim-tomorrow-theme.git for it.
" Hex color conversion functions borrowed from the theme "Desert256". " Hex color conversion functions borrowed from the theme "Desert256".
"
" @todo convert to new format (see campo-dark-blue.vim)
let g:campo_theme_use_rainbow_parens = 1 let g:campo_theme_use_rainbow_parens = 1
@@ -13,7 +15,7 @@ let s:foreground = "263238"
let s:background = "fbfbfb" let s:background = "fbfbfb"
let s:selection = "e3fc8d" let s:selection = "e3fc8d"
let s:line = "d5d5d5" let s:line = "d5d5d5"
let s:comment = "7c7c7c" let s:comment = "4c4c4c"
let s:red = "d62a28" let s:red = "d62a28"
let s:orange = "ff7800" let s:orange = "ff7800"
let s:yellow = "eab700" let s:yellow = "eab700"
@@ -294,13 +296,14 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256
call <SID>X("Number", s:black, "", "") call <SID>X("Number", s:black, "", "")
"call <SID>X("Ignore", "666666", "", "") "call <SID>X("Ignore", "666666", "", "")
" Custom TODO/NOTE colors " Notes and annotated comment text
call <SID>X("Todo", s:red, s:background, "underline") call <SID>X("MyTitle", s:foreground, "", "bold") " // # Some Title
call <SID>X("Bugs", s:red, s:background, "standout") call <SID>X("MyAnnotatedNote", s:foreground, "", "bold") " // @incomplete
call <SID>X("Notes","666666", "ffffff","bold") call <SID>X("MyNote", "", s:black, "standout") " // NOTE:, IDEA:, TODO:
call <SID>X("Notices","dcd53e",s:background,"bold") call <SID>X("MyEmphasis", s:orange, "", "bold,standout") " // WARNING:, IMPORTANT:
call <SID>X("ErrorMsg", s:error_msg_foreground, s:error_msg_background, "underline") call <SID>X("MyBug", s:red, "", "standout") " // FIXME:, BUG:, DEPRECATED:
call <SID>X("ErrorMsg", s:error_msg_foreground, s:error_msg_background, "underline")
" Vim Highlighting " Vim Highlighting
call <SID>X("vimCommand", s:blue, "", "none") call <SID>X("vimCommand", s:blue, "", "none")

755
.vimrc

File diff suppressed because it is too large Load Diff

View File

@@ -5,11 +5,13 @@
# change-volume script, supplying it the volume delta you want. Typically you # change-volume script, supplying it the volume delta you want. Typically you
# use the delta from the analysis report this script provides, e.g. if the # use the delta from the analysis report this script provides, e.g. if the
# max_volume is -5 db then you would call change-volume with a value of 5. I # max_volume is -5 db then you would call change-volume with a value of 5. I
# find that the two pass normalize-audio script works better than this # find that the two pass normalize-volume script works better than this
# approach...but it will take longer to run! # approach...but it will take longer to run!
# #
# 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
@@ -50,3 +52,4 @@ 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,22 +1,32 @@
@setlocal enableextensions enabledelayedexpansion
@echo off @echo off
setlocal enableextensions enabledelayedexpansion
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 NOTE: Defender may see this file as malware, so you might need to exclude this before things can be disabled. 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 Modified version of:
rem https://raw.githubusercontent.com/mattreecebentley/win10_disable_defender/main/win10_enable_defender.bat rem https://github.com/ggannann/win10_disable_defender
rem https://gist.github.com/xezrunner/a7a42dbc1096a40b0c78f09488fe5a2b 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
)
echo Running with administrative privileges.
echo.
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
@@ -103,4 +113,5 @@ echo Defender has already been disabled by this script.
:eof :eof
echo. echo.
pause pause

View File

@@ -1,17 +1,11 @@
@setlocal enableextensions enabledelayedexpansion
@echo off @echo off
setlocal enableextensions enabledelayedexpansion
rem Make sure we're running as admin. Got this garbage from https://stackoverflow.com/a/40388766 rem NOTE: Defender may see this file as malware, so you might need to exclude this before things can be disabled.
if not "%1"=="am_admin" (
powershell -Command "Start-Process -Verb RunAs -FilePath '%0' -ArgumentList 'am_admin'"
exit /b
)
rem USE AT OWN RISK AS IS WITHOUT WARRANTY OF ANY KIND !!!!! rem Modified version of:
rem rem https://github.com/ggannann/win10_disable_defender
rem Modified version of rem https://gist.github.com/xezrunner/a7a42dbc1096a40b0c78f09488fe5a2b (as of Jan 2026 this seems to have been deleted or made private)
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
@@ -19,7 +13,23 @@ 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
@@ -105,4 +115,5 @@ echo Defender has already been enabled by this script.
:eof :eof
echo. echo.
pause pause

View File

@@ -0,0 +1,72 @@
#!/usr/bin/env bash
# Shows you the status of an object restore job.
#
# e.g. aws-check-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'll need the aws cli tools. Download them from https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
#
# If you see an error like along the lines of "'charmap' codec can't encode
# character '\u200e' in position 42: character maps to <undefined>" then that
# means a filename has a Unicode codepoint and the dumb aws Python code is
# trying to read it using your system's locale, which is very likely not set to
# use the Windows UTF-8 beta feature. This is an ongoing issue in this tool
# that goes back to 2013!!! There's no way to fix it using environment
# variables, at least nothing worked for me. The fix provided by the devs is
# heavy handed: you change your system locale to use UTF-8... This has
# consequences though like breaking legacy apps that don't have Unicode support
# and I'm sure other weird things will happen, such as file corruption. Anyway,
# if you're getting this charmap error then I suggest changing your system
# locale, run this again, then switch back to your previous locale. If you
# don't get the canonical file name then you won't be able to restore it.
#
# You can enable the UTF-8 locale with:
#
# win+r -> intl.cpl -> Administrative tab -> Change system locale -> Beta: Use Unicode UTF-8 box.
#
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
MAGENTA="$(tput setaf 5)"
CYAN="$(tput setaf 6)"
BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
MAGENTA=""
CYAN=""
BOLD=""
NORMAL=""
fi
error() {
printf "${BOLD}${RED}$1${NORMAL}\n"
}
abort() {
error "\nAborting...\n"
exit 1
}
set -e
bucket="$1"
path="$2"
if [[ $bucket == "" || $path == "" ]]; then
error "Usage: aws-check-restore-status <bucket-name> <path-in-bucket>"
exit 1
fi
aws s3api head-object --bucket $bucket --key "$path" --query "{Restore:Restore, StorageClass:StorageClass}" --output json

View File

@@ -52,11 +52,6 @@ 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"
@@ -68,4 +63,24 @@ if [[ $bucket == "" || $path == "" || $output_file == "" ]]; then
exit 1 exit 1
fi fi
aws s3api list-objects-v2 --bucket $bucket --prefix $path --query "Contents[?StorageClass=='DEEP_ARCHIVE']" --output text | LC_ALL=C awk '{print substr($0, index($0, $2))}' | awk '{NF-=3};3' > "$output_file" # .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')"
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 "Wrote file list to ${BOLD}${YELLOW}$output_file${NORMAL}\n"

View File

@@ -1,28 +1,44 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Restores all objects recursively from a specific bucket path. If want to
# restore objects from an rclone crypt (encrypted remote), then you'll need to
# do some manual steps first. See the `# Rclone Crypt` section for details.
# #
# Restores all files/folders inside a particular bucket path for the next 7 days. This uses the bulk retreival tier: # You can set how long restore files are available for download and the AWS
# retrieval tier. The defaults are 7 days and the bulk tier respectively.
#
# Available tiers: bulk, standard, and expedited.
# #
# Bulk retrievals are the lowest-cost retrieval option when restoring objects # Bulk retrievals are the lowest-cost retrieval option when restoring objects
# from S3 Glacier Deep Archive. They typically finish within 48 hours for # from S3 Glacier Deep Archive. They typically finish within 48 hours for
# objects stored in the S3 Glacier Deep Archive storage class or S3 # objects stored in the S3 Glacier Deep Archive storage class or S3
# Intelligent-Tiering Deep Archive tier. # Intelligent-Tiering Deep Archive tier.
# #
# If you need faster access then use the `Expedited` or `Standard` tiers. # If you need faster access then use the `expedited` or `standard` tiers.
# #
# Example usage: # Example usage:
# #
# aws-restore-deep-glacier-folder my-deep-glacier-bucket path/to/images restored_images # aws-restore-deep-glacier-folder my-deep-glacier-bucket path/to/images restored_images 14 expedited
# #
# This will create a run.sh script in a folder called "restored_images". Run that to restore all files inside the `path/to/images` folder inside the my-deep-glacier bucket. # This will create a run.sh script in a folder called "restored_images". Run
# that to restore all files inside the `path/to/images` folder from the
# my-deep-glacier bucket. Restored objects will be available for 14 days and
# retrieved using the expedited tier.
# #
# After you run the generated script, you have to wait for AWS to make the files available for download. You can check the status of a file with: # After you run the generated script, you have to wait for AWS to make the
# files available for download. You can check the status of a file with:
# #
# aws s3api head-object --bucket my-deep-glacier --key path/to/images/photo1.jpg # aws s3api head-object --bucket my-deep-glacier-bucket --key "path/to/images/photo1.jpg" --query "{Restore:Restore, StorageClass:StorageClass}"
# #
# (obviously change the bucket and path to suit your needs). # (obviously change the bucket and path to suit your needs).
# #
# Once the files are restored you can download them on the S3 website or better yet use RcloneBrowser. I'm sure there's also a way to do it over cli too, I just haven't checked. # Or use the aws-check-restore-status script.
# 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.
#
# Once the files are restored you can download them on the S3 website or better
# yet use RcloneBrowser. I'm sure there's also a way to do it over cli too, I
# just haven't checked.
# #
# You'll need the aws cli tools for this script. Download them from https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html # You'll need the aws cli tools for this script. Download them from https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
# Once installed, open a new shell and verify that you can run the `aws` command. # Once installed, open a new shell and verify that you can run the `aws` command.
@@ -44,6 +60,67 @@
# You can enable the UTF-8 locale with: # You can enable the UTF-8 locale with:
# #
# win+r -> intl.cpl -> Administrative tab -> Change system locale -> Beta: Use Unicode UTF-8 box. # win+r -> intl.cpl -> Administrative tab -> Change system locale -> Beta: Use Unicode UTF-8 box.
##########################
# Rclone Crypt
##########################
#
# To restore an rclone crypt, you need to first find the encrypted name that
# maps to the parent folder or the file you want to restore. To do this you
# need to use rclone. There are two ways to go about this.
#
# 1. The simple way is to use `cryptdecode` to convert your object path to its
# encrypted form.
#
# For example, say you have an rclone crypt called `s3-deep-glacier-encrypted`
# that is stored in S3 at `my-deep-glacier-bucket:encrypted/` You have a folder
# called `dev/fonts` that you want to restore. To get its path, run the following
# command:
#
# rclone cryptdecode --reverse s3-deep-glacier-encrypted: dev/fonts
#
# This will give you the encrypted path, e.g. "44ildo3grlk44jmfr96nb5r56o/oatuh75ej3l4re96nvq2qbj8ik"
#
# You can now restore this by running:
#
# aws-restore-deep-glacier-folder my-deep-glacier-bucket 44ildo3grlk44jmfr96nb5r56o/oatuh75ej3l4re96nvq2qbj8ik restore_dev_fonts
#
# You should be able to simply download the dev/fonts folder after its
# restored. The easiest way is using rclone browser because it'll decrypt them
# for you. Alternatively you can download the encrypted files using whatever
# method you want and then decrypt them locally with rclone.
#
# 2. You can also get the encrypted names by enabling the 'show_mapping' option
# in the rclone remote config. This will log the encrytped names of folders and
# files with the original name in the same log line. This makes it easy to
# parse the output.
#
# To enable the option, edit your rclone config, edit the remote you want to
# restore from, edit the advanced config and set `show_mapping` to true.
#
# Now you can list the directories and files with rclone and get the mapping
# output on stderr. e.g. let's capture all folders and files in a txt file:
#
# rclone lsf s3-deep-glacier-encrypted: -R &> keys.txt
#
# If your rclone config has password protection then you'll be prompted for it
# but won't see the output since it's being written to the file. Just paste it
# and hit enter.
#
# Now you have a listing of all objects and the encrypted keys that they map
# to. If you want to scope the output to a specific path in the crypt then add
# it after the remote name, e.g. `s3-deep-glacier-encrypted:dev/fonts`
#
# If you scope it like that then be aware that the output won't contain the
# mapping for the parent path, i.e. `dev/fonts`, but you can get that using
# `cryptdecode` (see above) or with some non-recursive outputs of the parent
# parts using `lsd`, e.g.
#
# // First call will include the dev/ key
# rclone lsd s3-deep-glacier-encrypted:
#
# // Second call has the fonts key
# rclone lsd s3-deep-glacier-encrypted:dev
# #
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
@@ -73,36 +150,182 @@ 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"
path="$2" path="$2"
temp_dir="$3" temp_dir="$3"
number_of_objects_per_file=100
days_available=7 days_available=7
restore_tier="Bulk" # Can also be "Standard" or "Expedited" restore_tier="bulk" # Can also be "standard" or "expedited"
if [[ $bucket == "" || $path == "" || $temp_dir == "" ]]; then if [[ $bucket == "" || $path == "" || $temp_dir == "" ]]; then
error "Usage: aws-restore-deep-glacier-folder <bucket-name> <path-in-bucket> <local-temp-dir>" error "Usage: aws-restore-deep-glacier-folder <bucket-name> <path-in-bucket> <local-temp-dir> <optional: days available> <optional: restore tier>"
exit 1 exit 1
fi fi
printf "${BOLD}Restoring ${GREEN}$bucket:$path${NORMAL}${BOLD} with local temp folder ${GREEN}$temp_dir${NORMAL}\n" # Get the days available.
if [[ $4 != "" ]]; then
days_available=$4
fi
# Get the restore tier.
if [[ $5 != "" ]]; then
restore_tier="$5"
fi
if ! grep -qiE '\b(bulk|standard|expedited)\b' <<<"$restore_tier"; then
error "Restore tier is invalid. Accepted values is \"bulk\", \"standard\" and \"expedited\""
exit 1
fi
# Normalize the tier; lowercase it then capitalize the first character.
restore_tier="${restore_tier,,}"
restore_tier="${restore_tier^}"
printf "Restoring ${BOLD}${YELLOW}$bucket:$path${NORMAL} for ${BOLD}${YELLOW}$days_available${NORMAL} days using the ${BOLD}${YELLOW}\"$restore_tier\"${NORMAL} restore tier.\nSaving the restoration script in ${BOLD}${YELLOW}$temp_dir${NORMAL}\n"
mkdir -p "$temp_dir" mkdir -p "$temp_dir"
pushd "$temp_dir" &>/dev/null pushd "$temp_dir" &>/dev/null
aws s3api list-objects-v2 --bucket $bucket --prefix $path --query "Contents[?StorageClass=='DEEP_ARCHIVE']" --output text | LC_ALL=C awk '{print substr($0, index($0, $2))}' | awk '{NF-=3};3' > all_objects_list.txt # .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')"
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[@]}"
# Generate the main script that will kick off the restoration. # Generate the main script that will kick off the restoration.
printf "while read x; do\n printf \"aws s3api restore-object --restore-request '{\\\\\"Days\\\\\":$days_available,\\\\\"GlacierJobParameters\\\\\":{\\\\\"Tier\\\\\":\\\\\"$restore_tier\\\\\"}}' --bucket $bucket --key \\\\\"\$x\\\\\"\\\\n\"\n aws s3api restore-object --restore-request \"{\\\\\"Days\\\\\":$days_available,\\\\\"GlacierJobParameters\\\\\":{\\\\\"Tier\\\\\":\\\\\"$restore_tier\\\\\"}}\" --bucket $bucket --key \"\$x\"\ndone < all_objects_list.txt\nprintf \"\\\\nDone! You can now delete this folder.\\\\nYour files are currently being restored. The time it takes to restore 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\"\n" > run.sh printf "Number of items to restore: ${BOLD}${YELLOW}$item_count${NORMAL}\n"
chmod +x run.sh printf "${BOLD}${RED}Create the restore script?\n> ${NORMAL}"
printf "${BOLD}You can now run ${GREEN}$temp_dir/run.sh${NORMAL}${BOLD} to start the restoration process.\n" 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
if which tput >/dev/null 2>&1; then
ncolors=\$(tput colors)
fi
if [ -t 1 ] && [ -n "\$ncolors" ] && [ "\$ncolors" -ge 8 ]; then
RED="\$(tput setaf 1)"
GREEN="\$(tput setaf 2)"
YELLOW="\$(tput setaf 3)"
BLUE="\$(tput setaf 4)"
MAGENTA="\$(tput setaf 5)"
CYAN="\$(tput setaf 6)"
BOLD="\$(tput bold)"
NORMAL="\$(tput sgr0)"
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
MAGENTA=""
CYAN=""
BOLD=""
NORMAL=""
fi
# Open an output file.
exec 3>>output.txt
fail_count=0
failed_filename="failed_keys_\$(printf '%%04x' \$((RANDOM * RANDOM))).txt"
before_sleep_count=0
sleep_every_n_requests=25
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" >&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
while read key; do
printf "* [\$index/$item_count] \${BOLD}\$key\${NORMAL}\\\n"
printf "* [\$index/$item_count] \$key\\\n" >&3
err=\$(
aws s3api restore-object \\
--bucket mcampagnaro-deep-glacier \\
--key \\"\$key\\" \\
--restore-request '{\\"Days\\":$days_available,\\"GlacierJobParameters\\":{\\"Tier\\":\\"$restore_tier\\"}}' \\
2>&1 >/dev/null
)
index=\$((index + 1))
before_sleep_count=\$((before_sleep_count + 1))
# strip newlines
err="\${err//[$'\\\t\\\r\\\n']}"
if [[ \$err != "" ]]; then
if ! grep -qE 'RestoreAlreadyInProgress|ObjectAlreadyInActiveTierError' <<<"\$err"; then
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
if grep -qE 'RestoreAlreadyInProgress' <<<"\$err"; then
printf "\${BOLD}\${YELLOW}SKIPPING! File restore is already in progress.\${NORMAL}"
printf "SKIPPING! File restore is already in progress." >&3
else
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
else
printf "\${BOLD}\${GREEN}SUCCESS!\${NORMAL}"
printf "SUCCESS!" >&3
fi
printf "\\\n\\\n"
printf "\\\n\\\n" >&3
if [[ \$before_sleep_count -eq sleep_every_n_requests ]]; then
printf "SLEEPING...\\\n\\\n"
printf "SLEEPING...\\\n\\\n" >&3
sleep \$sleep_duration
before_sleep_count=0
fi
done < all_objects_list.txt
printf "\${BOLD}\${GREEN}Done!\${NORMAL}\\\n\\\n"
printf "Done!\\\n\\\n" >&3
if [[ \$fail_count > 0 ]]; then
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
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" >&3
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 "You can check the status of a file using the aws-check-restore-status script)\\\n"
exec 3>&-
EOF
)
printf "$RUN_TEMPLATE" > run.sh
chmod +x run.sh
printf "${BOLD}You can now run ${GREEN}$temp_dir/run.sh${NORMAL}${BOLD} to start the restoration process.\n"
else
echo Aborting.
fi
popd &>/dev/null popd &>/dev/null

View File

@@ -7,6 +7,8 @@
# #
# 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
@@ -51,9 +53,10 @@ fi
printf "\n${YELLOW}${BOLD}Modifying audio volume in $filename.$extension | output: $output | delta: $delta_db${NORMAL}\n" printf "\n${YELLOW}${BOLD}Modifying audio volume in $filename.$extension | output: $output | delta: $delta_db${NORMAL}\n"
# Since we're re-encoding the audio we have to specify a codec to use. # Since we're re-encoding the audio we have to specify a codec to use.
cmd="ffmpeg -y -stats -loglevel level+error -i \"$filename.$extension\" -af \"volume=${delta_db}dB\" -c:v copy -c:a aac -map 0 \"$output\"" cmd="ffmpeg -y -stats -loglevel level+error -i \"$filename.$extension\" -af \"volume=${delta_db}dB\" -c:v copy -c:a aac \"$output\""
printf "\n${BOLD}Running: $cmd\n\n${NORMAL}" printf "\n${BOLD}Running: $cmd\n\n${NORMAL}"
eval $cmd 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,5 +1,9 @@
#!/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
@@ -23,10 +27,13 @@ else
NORMAL="" NORMAL=""
fi fi
use_gpu=0 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 || $# > 3 ]]; then if [[ $# < 2 || $# > 5 ]]; then
printf "${BOLD}${RED}Usage: compress-video <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> ${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> (NOTE: gpu crf is $gpu_crf and cpu crf is $cpu_crf - change it by calling compress-video-with-crf)${NORMAL}\n"
exit 1 exit 1
fi fi
@@ -37,11 +44,12 @@ if [[ $# > 2 ]]; then
use_gpu=$3 use_gpu=$3
fi fi
# Found the following to work best with vids containing text (e.g. programming vid): 25 for CPU encoding and 27 for GPU. use_crf=$cpu_crf
use_crf=21
if [[ $use_gpu -eq 1 ]]; then if [[ $use_gpu -eq 1 ]]; then
use_crf=25 use_crf=$gpu_crf
fi fi
compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu $4 $5
flash_taskbar

View File

@@ -1,5 +1,9 @@
#!/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
@@ -23,7 +27,7 @@ else
NORMAL="" NORMAL=""
fi fi
use_gpu=0 use_gpu=1
if [[ "$#" < 3 || "$#" > 6 ]]; then if [[ "$#" < 3 || "$#" > 6 ]]; then
printf "${BOLD}${RED}Usage: compress-video-with-crf <crf value> <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> <optional: start time HH:MM:SS> <optional: end time HH:MM:SS>\n\nIf you want to encode a range of CRF values then use -1 as the crf value.${NORMAL}\n" printf "${BOLD}${RED}Usage: compress-video-with-crf <crf value> <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> <optional: start time HH:MM:SS> <optional: end time HH:MM:SS>\n\nIf you want to encode a range of CRF values then use -1 as the crf value.${NORMAL}\n"
@@ -65,21 +69,25 @@ function encode() {
fi fi
if [[ $use_gpu -eq 1 ]]; then if [[ $use_gpu -eq 1 ]]; then
# File will be slightly larger than CPU encoding, but it's much faster to transcode and doesn't max out the CPU cores.
# RTX 3080 # RTX 3080
ffmpeg -y -stats -loglevel level+error $timing_args -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i "$filename.$extension" -c:a copy -c:v h264_nvenc -profile:v high -rc:v vbr_hq -cq:v $crf -b:v 5M -maxrate 5M -max_muxing_queue_size 9999 "$output" # vbr_hq is smaller file and less bitrate than vbr - strange!
ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda $timing_args -accurate_seek -i "$filename.$extension" -c:v h264_nvenc -profile:v high -preset 3 -rc:v vbr -cq:v $crf -c:a copy -max_muxing_queue_size 9999 -movflags +faststart "$output"
# GTX 1070 # capped bitrate w/ crf is weird. gives a more compressed copy
#ffmpeg -y -stats -loglevel level+error $timing_args -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i "$filename.$extension" -c:a copy -c:v h264_nvenc -profile:v high -rc:v vbr_hq -cq:v $crf -b:v 5M -maxrate 5M -max_muxing_queue_size 9999 "$output" # ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda $timing_args -accurate_seek -i "$filename.$extension" -c:v h264_nvenc -profile:v high -preset 3 -cq:v $crf -b:v 1200K -maxrate:v 1200K -bufsize:v 2400K -c:a copy -max_muxing_queue_size 9999 -movflags +faststart "$output"
else else
ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c:v libx264 -crf $crf -preset veryfast -profile:v high -level 3.0 -strict -2 "$output" ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c:v libx264 -crf $crf -preset veryfast -profile:v high -level 3.0 -strict -2 "$output"
fi fi
printf "\n${GREEN}${BOLD}Finished encoding '$filename.$extension' (CRF $crf) | output name '$output'${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished encoding '$filename.$extension' (CRF $crf) | output name '$output'${NORMAL}\n\n"
original_size=$(wc -c <"$filename.$extension")
new_size=$(wc -c <"$output")
printf "${BOLD}Original size: $original_size${NORMAL}\n"
printf "${BOLD}New size: $new_size${NORMAL}\n\n"
} }
if [[ $use_crf -ne -1 ]]; then if [[ $use_crf -ne -1 ]]; then
encode $use_crf time encode $use_crf
else else
printf "\n${YELLOW}${BOLD}Encoding using a range of CRF values.${NORMAL}\n" printf "\n${YELLOW}${BOLD}Encoding using a range of CRF values.${NORMAL}\n"
@@ -89,3 +97,5 @@ else
encode $crf encode $crf
done done
fi fi
flash_taskbar

View File

@@ -3,6 +3,8 @@
# 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
@@ -57,7 +59,7 @@ fi
cmd="" cmd=""
if [[ $extension == "mkv" || $extension == "mpg" ]]; then if [[ $extension == "mkv" || $extension == "mpg" || $extension == "mov" ]]; then
if [[ $bitrate != "" ]]; then if [[ $bitrate != "" ]]; then
bitrate_args="-b:v $bitrate" bitrate_args="-b:v $bitrate"
else else
@@ -94,3 +96,5 @@ 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

@@ -1,7 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Use this to fix the audio of a video that has audio in only the left or right # Use this to copy audio from the left channel to the right. This does not re-encode the video.
# channel. This does not re-encode the video.
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
@@ -27,7 +26,7 @@ else
fi fi
if [[ $1 == "" ]]; then if [[ $1 == "" ]]; then
printf "${BOLD}${RED}Usage: fix-audio-in-one-channel <filename> <optional output name>${NORMAL}\n" printf "${BOLD}${RED}Usage: copy-left-audio-channel-to-right <filename> <optional output name>${NORMAL}\n"
exit 1 exit 1
fi fi
@@ -43,9 +42,9 @@ else
output="${output_name}.$extension" output="${output_name}.$extension"
fi fi
printf "\n${YELLOW}${BOLD}Repairing audio in $filename.$extension | output: $output${NORMAL}\n" printf "\n${YELLOW}${BOLD}Copy left audio channeel to right channel in $filename.$extension | output: $output${NORMAL}\n"
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -c:v copy -ac 1 -map 0 "$output" ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -c:v copy -af "pan=stereo|c0=c0|c1=c0" -map 0 "$output"
printf "\n${GREEN}${BOLD}Done repairing audio in $filename.$extension | output: $output${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Done copying left audio channel to right channel in $filename.$extension | output: $output${NORMAL}\n\n"

View File

@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Use this to copy audio from the right channel to the left. This does not re-encode the video.
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
MAGENTA="$(tput setaf 5)"
CYAN="$(tput setaf 6)"
BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
MAGENTA=""
CYAN=""
BOLD=""
NORMAL=""
fi
if [[ $1 == "" ]]; then
printf "${BOLD}${RED}Usage: copy-right-audio-channel-to-left <filename> <optional output name>${NORMAL}\n"
exit 1
fi
filename=$(basename -- "$1")
extension="${filename##*.}"
filename="${filename%.*}"
output_name="$2"
if [[ $output_name == "" ]]; then
output="${filename}_repaired_audio.$extension"
else
output="${output_name}.$extension"
fi
printf "\n${YELLOW}${BOLD}Copy right audio channeel to left channel in $filename.$extension | output: $output${NORMAL}\n"
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -c:v copy -af "pan=stereo|c0=c1|c1=c1" -map 0 "$output"
printf "\n${GREEN}${BOLD}Done copying right audio channel to left channel in $filename.$extension | output: $output${NORMAL}\n\n"

View File

@@ -0,0 +1,11 @@
@echo off
if exist %1\* (
echo Run on a file
) else (
if exist "%~1_checksum-md5.txt" (
del "%~1_checksum-md5.txt"
)
certutil.exe -hashfile "%~1" MD5 > "%~1_checksum-md5.txt"
start notepad "%~1_checksum-md5.txt"
)

View File

@@ -0,0 +1,11 @@
@echo off
if exist %1\* (
echo Run on a file
) else (
if exist "%~1_checksum-sha1.txt" (
del "%~1_checksum-sha1.txt"
)
certutil.exe -hashfile "%~1" SHA1 > "%~1_checksum-sha1.txt"
start notepad "%~1_checksum-sha1.txt"
)

View File

@@ -0,0 +1,11 @@
@echo off
if exist %1\* (
echo Run on a file
) else (
if exist "%~1_checksum-sha256.txt" (
del "%~1_checksum-sha256.txt"
)
certutil.exe -hashfile "%~1" SHA256 > "%~1_checksum-sha256.txt"
start notepad "%~1_checksum-sha256.txt"
)

View File

@@ -0,0 +1,11 @@
@echo off
if exist %1\* (
echo Run on a file
) else (
if exist "%~1_checksum-sha512.txt" (
del "%~1_checksum-sha512.txt"
)
certutil.exe -hashfile "%~1" SHA512 > "%~1_checksum-sha512.txt"
start notepad "%~1_checksum-sha512.txt"
)

View File

@@ -1,12 +1,13 @@
@echo off @echo off
cd %DEV_TOOLS%\SysinternalsSuite cd /d %DEV_TOOLS%\SysinternalsSuite
if exist %1\* ( if exist %1\* (
echo Run on a file echo Run on a file
) else ( ) else (
if exist "%~1_Report.txt" ( if exist "%~1_sigcheck_report.txt" (
del "%~1_Report.txt" del "%~1_sigcheck_report.txt"
) )
sigcheck.exe /a "%~1" > "%~1_sigcheck_report.txt" sigcheck64.exe /a "%~1" > "%~1_sigcheck_report.txt"
start notepad "%~1_sigcheck_report.txt" start notepad "%~1_sigcheck_report.txt"
) )

View File

@@ -1,6 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Re-encodes the video to get a more accurate timeline. If you want fast video joining at the expense of accuracy then use join-video-fast. # 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.
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)
@@ -26,18 +29,41 @@ else
fi fi
filename=$(basename -- "$1") filename=$(basename -- "$1")
output_name="$2" output="$2"
target_crf="$3"
max_bitrate_mb="$4"
if [[ $filename == "" || $output_name == "" ]]; then 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)
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\n$0 <list name> <output name>${NORMAL}\n" default_max_bitrate="6"
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"
exit 1 exit 1
fi fi
output="${output_name}.mp4" extension="${output##*.}"
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"
exit 1
fi
printf "\n${YELLOW}${BOLD}Joining contents of '$filename'| output: $output${NORMAL}\n" if [[ $target_crf == "" || $target_crf == "0" ]] then
target_crf=$default_crf
fi
ffmpeg -y -stats -loglevel level+error -f concat -safe 0 -accurate_seek -i "$filename.$extension" -c:v libx264 -c:a copy "$output" if [[ $max_bitrate_mb == "" ]] then
max_bitrate_mb=$default_max_bitrate
fi
# bufsize is typically double the maxrate
bufsize=$((max_bitrate_mb * 2))
bufsize="${bufsize}M"
max_bitrate="${max_bitrate_mb}M"
printf "\n${YELLOW}${BOLD}Joining contents of '$filename' | output: $output | crf: $target_crf | max rate: $max_bitrate | buffer size: $bufsize ${NORMAL}\n"
time ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda -f concat -safe 0 -accurate_seek -i "$filename" -c:v h264_nvenc -profile:v high -preset 3 -rc:v vbr -cq:v $target_crf -maxrate:v $max_bitrate -bufsize:v $bufsize -c:a copy -movflags +faststart "$output"
printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n"
flash_taskbar

View File

@@ -5,6 +5,8 @@
# 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
@@ -44,3 +46,4 @@ 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

@@ -1,12 +1,17 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Use this to normalize the volume of a video or audio file using the average loudness, or RMS-based normalization. It does a pretty good job! # Use this to normalize the volume of a video or audio file using the average
# If you want to modify the volume manually then checkout the analyze-volume and change-volume scripts. # loudness, or RMS-based normalization. It does a pretty good job!
#
# If you want to modify the volume manually then checkout the analyze-volume
# and change-volume scripts.
# #
# This does not re-encode video when given a video file. # This does not re-encode video when given a video file.
# #
# 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
@@ -68,10 +73,11 @@ it=`grep \"input_thresh\" $temp_file | cut -d: -f2 | tr -cd [:digit:].-`
to=`grep \"target_offset\" $temp_file | cut -d: -f2 | tr -cd [:digit:].-` to=`grep \"target_offset\" $temp_file | cut -d: -f2 | tr -cd [:digit:].-`
# 2nd pass: # 2nd pass:
cmd="ffmpeg -y -stats -loglevel level+error -i \"$filename.$extension\" -c:v copy -pass 2 -filter:a loudnorm=linear=true:I=-16:LRA=11:tp=-1.5:measured_I=$ii:measured_LRA=$ilra:measured_tp=$itp:measured_thresh=$it:offset=$to:print_format=summary -map 0 \"$output\"" cmd="ffmpeg -y -stats -loglevel level+error -i \"$filename.$extension\" -c:v copy -pass 2 -filter:a loudnorm=linear=true:I=-16:LRA=11:tp=-1.5:measured_I=$ii:measured_LRA=$ilra:measured_tp=$itp:measured_thresh=$it:offset=$to:print_format=summary \"$output\""
printf "${BOLD}Re-encoding audio:\n$cmd\n\n${NORMAL}" printf "${BOLD}Re-encoding audio:\n$cmd\n\n${NORMAL}"
eval "$cmd" 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

@@ -34,4 +34,4 @@ end_time="$4"
if [[ $start_time == "" ]]; then start_time="0"; fi if [[ $start_time == "" ]]; then start_time="0"; fi
if [[ $end_time == "" ]]; then end_time="0"; fi if [[ $end_time == "" ]]; then end_time="0"; fi
transcribe-video "$1" "$2" "base" transcribe-video "$1" "$2" $start_time $end_time "base"

View File

@@ -34,4 +34,4 @@ end_time="$4"
if [[ $start_time == "" ]]; then start_time="0"; fi if [[ $start_time == "" ]]; then start_time="0"; fi
if [[ $end_time == "" ]]; then end_time="0"; fi if [[ $end_time == "" ]]; then end_time="0"; fi
transcribe-video "$1" "$2" "medium" transcribe-video "$1" "$2" $start_time $end_time "medium"

View File

@@ -34,4 +34,4 @@ end_time="$4"
if [[ $start_time == "" ]]; then start_time="0"; fi if [[ $start_time == "" ]]; then start_time="0"; fi
if [[ $end_time == "" ]]; then end_time="0"; fi if [[ $end_time == "" ]]; then end_time="0"; fi
transcribe-video "$1" "$2" "small" transcribe-video "$1" "$2" $start_time $end_time "small"

View File

@@ -2,6 +2,8 @@
# 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
@@ -53,5 +55,9 @@ printf "\n${YELLOW}${BOLD}Trimming '$filename' | output: $output_name_with_exten
ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename" -map a "$output_name_with_extension" ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename" -map a "$output_name_with_extension"
#If you want to have a specific bit rate and sample rate then you need to add it before the output filename. Might also need to remove the -map a arg. e.g.
#ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename" -c:a aac -b:a 191k -ar 48000 "$output_name_with_extension"
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
flash_taskbar

View File

@@ -2,6 +2,8 @@
# 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
@@ -62,3 +64,4 @@ 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,6 +5,8 @@
# 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
@@ -64,3 +66,4 @@ 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

@@ -0,0 +1,95 @@
#!/usr/bin/env bash
# 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
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
MAGENTA="$(tput setaf 5)"
CYAN="$(tput setaf 6)"
BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
MAGENTA=""
CYAN=""
BOLD=""
NORMAL=""
fi
filename=$(basename -- "$1")
output_name="$2"
target_bitrate_mb="$3"
start_time="$4"
end_time="$5"
if [[ $filename == "" || $output_name == "" || $target_bitrate_mb == "" || $start_time == "" ]]; then
printf "${BOLD}${RED}Usage: trim-video <filename> <output name> <target bitrate in MB, e.g. 6> <start time HH:MM:SS> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n"
exit 1
fi
extension="${filename##*.}"
filename="${filename%.*}"
output="${output_name}.$extension"
# bufsize is typically double the maxrate
bufsize=$((target_bitrate_mb * 2))
bufsize="${bufsize}M"
bitrate="${target_bitrate_mb}M"
timing_args=""
if [[ $start_time != "" ]]; then
timing_args="-ss $start_time "
fi
if [[ $end_time != "" ]]; then
if [[ $start_time == "0" && $end_time == "0" ]]; then
# We treat a start and end with 0 values as no op.
timing_args=""
elif [[ $end_time != "0" ]]; then
# Handle having a start time but end time is set to 0, can just ignore it and it'll use the remainder of the video.
timing_args+="-to $end_time"
fi
fi
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time | max rate: $bitrate | buffer size: $bufsize ${NORMAL}\n"
# You might have issues if the file has multiple video streams or embedded
# subtitles. The -map 0 arg is typically given when copying a video stream, but
# I'm not sure if it's appropriate to use here. If you want to target one of
# the video streams then use `-map 0:v:0` and if you want to re-encode
# subtitles then include `-c:s mov_text` with either of the `-map` args.
# -preset 3 and 4 are the fastest on my 3080 and have the same output file
# size. p3 seems slightly faster. Apparently 7 is the best for 30 series
# according to chatgpt (lol) but it was slow and compressed.
# -accurate_seek doesn't seem to be needed when -ss is after -i, only when -ss
# is before -i. Having -ss after is apparently a way of enabling accurate
# seeking. The catch is that if the trim doesn't start at 0, it can be a long
# wait before the encoder gets to the portion you want to start trimming from.
# To speed this up we are putting -ss and -accurate_seek before -i ... the
# video duration might be slightly off from this but so far I haven't seen any
# seeking issues. If they come up then we can move -ss to after -i again and
# delete -accurate_seek.
# I'm using -b:v, -maxrate:v, and -bufsize:v to constrain the bitrate and
# indirectly control quality. The bitrate won't be fixed exactly to -b:v
# unless using CBR, but NVENC will attempt to average around it and cap the
# bitrate at -maxrate:v, using -bufsize:v as a smoothing buffer.
ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda $timing_args -accurate_seek -i "$filename.$extension" -c:v h264_nvenc -profile:v high -preset 3 -b:v $bitrate -maxrate:v $bitrate -bufsize:v $bufsize -c:a copy -movflags +faststart "$output"
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
flash_taskbar

129
dotfiles/bin/trim-video-vbr Normal file
View File

@@ -0,0 +1,129 @@
#!/usr/bin/env bash
# Re-encodes the video using a target quality level and a variable bitrate.
# 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
# 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
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
MAGENTA="$(tput setaf 5)"
CYAN="$(tput setaf 6)"
BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
MAGENTA=""
CYAN=""
BOLD=""
NORMAL=""
fi
filename=$(basename -- "$1")
output_name="$2"
start_time="$3"
end_time="$4"
target_crf="$5"
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_max_bitrate="6"
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"
exit 1
fi
extension="${filename##*.}"
filename="${filename%.*}"
output="${output_name}.$extension"
if [[ $target_crf == "" || $target_crf == "0" ]] then
target_crf=$default_crf
fi
if [[ $max_bitrate_mb == "" ]] then
max_bitrate_mb=$default_max_bitrate
fi
# bufsize is typically double the maxrate
bufsize=$((max_bitrate_mb * 2))
bufsize="${bufsize}M"
max_bitrate="${max_bitrate_mb}M"
timing_args=""
if [[ $start_time != "" ]]; then
timing_args="-ss $start_time "
fi
if [[ $end_time != "" ]]; then
if [[ $start_time == "0" && $end_time == "0" ]]; then
# We treat a start and end with 0 values as no op.
timing_args=""
elif [[ $end_time != "0" ]]; then
# Handle having a start time but end time is set to 0, can just ignore it and it'll use the remainder of the video.
timing_args+="-to $end_time"
fi
fi
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time | crf: $target_crf | max rate: $max_bitrate | buffer size: $bufsize ${NORMAL}\n"
# You might have issues if the file has multiple video streams or embedded
# subtitles. The -map 0 arg is typically given when copying a video stream, but
# I'm not sure if it's appropriate to use here. If you want to target one of
# the video streams then use `-map 0:v:0` and if you want to re-encode
# subtitles then include `-c:s mov_text` with either of the `-map` args.
# -preset 3 and 4 are the fastest on my 3080 and have the same output file
# size. p3 seems slightly faster. Apparently 7 is the best for 30 series
# according to chatgpt (lol) but it was slow and compressed.
# -accurate_seek doesn't seem to be needed when -ss is after -i, only when -ss
# is before -i. Having -ss after is apparently a way of enabling accurate seeking.
# The catch is that if the trim doesn't start at 0, it can be a long wait before
# the encoder gets to the portion you want to start trimming from. To speed this up
# we are putting -ss and -accurate_seek before -i ... the video duration might be
# slightly off from this but so far I haven't seen any seeking issues. If they come
# up then we can move -ss to after -i again and delete -accurate_seek.
# I'm using -rc:v vbr -cq:v 20 (higher = more compression) to have a variable
# bit-rate with a quality target. This gives us a good looking re-encoding that
# does a good job preserving the quality of the source video (at least for
# twitch streams I'm trimming) but the bitrate might be higher or lower than
# the source. The quality metric will fluctuate during encoding because NVENC
# does't use a fixed quantization parameter. -cq:v is a target, not a constraint.
# So you can have quite the fluctuating (or high) bitrate with these two params.
# In order to set a birate cap that is prioritized over visual fidelity, we can
# add in:
# -maxrate:v -bufsize:v
# (with bufsize typically being double the maxrate)
#
# Using this with the vbr and crf params tells the NVENC encoder to try to
# encode at a perceptual quality level around CQ=20 but keep the bitrate under
# 6000 kbps (constrained VBR). If a scene is too complex to maintain CQ=20
# within the bitrate cap, the encoder will:
# * Raise the quantizer (lower quality) to obey the -maxrate
# * Result: CQ metric fluctuates upward
# If a scene is simple:
# * Encoder can exceed CQ=20 (e.g. better quality) while staying under maxrate
# * Result: CQ metric fluctuates downward
#
# To have a mostly fixed bitrate with no variable quality, use trim-video-target-rate
time ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda $timing_args -accurate_seek -i "$filename.$extension" -c:v h264_nvenc -profile:v high -preset 3 -rc:v vbr -cq:v $target_crf -maxrate:v $max_bitrate -bufsize:v $bufsize -c:a copy -movflags +faststart "$output"
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
flash_taskbar

View File

@@ -11,7 +11,7 @@ if [[ -d "/c/msys64" ]]; then
shell_is_mingw is_mingw shell_is_mingw is_mingw
if [[ $is_mingw -eq 1 ]]; then if [[ $is_mingw -eq 1 ]]; then
printf "${BOLD}${YELLOW}Updating MinGW Shell${NORMAL}\n" printf "${BOLD}${YELLOW}Updating MinGW Shell${NORMAL}\n"
pacman -Syu pacman --sync --refresh --sysupgrade
printf "${BOLD}${GREEN}Done!${NORMAL}\n" printf "${BOLD}${GREEN}Done!${NORMAL}\n"
printf "\n${BOLD}Re-run this in a new shell if the updater requires the shells to be closed.\n" printf "\n${BOLD}Re-run this in a new shell if the updater requires the shells to be closed.\n"
else else

View File

@@ -1,13 +1,79 @@
# Arch Linux # Arch Linux
ughhhhhh had to reinstall the test vm like 5 times. finally got lxqt with virtualbox driver to load the desktop
but networking is not working. Perf is kinda shitty. UI is shitty. QT sucks. I hate linux.
## Setup
* Installation guide https://wiki.archlinux.org/title/Installation_guide
* Can go through manually or use the new guided installer: `archinstall`
* use btrfs file system
* I guess I should enable compression but I'm not sure how it affects perf.
* I tried Luks disk encryption in a VirtualBox VM and I couldn't get into the
desktop. Locks up on login. Not sure if it's related to this...can try
encryption on a real install.
* desktop environment
**VM Test**
* lxqt, vmware graphics driver, lightdm-slick-greeter
* lxqt - X11 based. I was using lxde in the past but it was abandoned by
the original team. They made lxqt. It's QT based which is lame but might
be fine. This is lightweight and I have my old configs (for LXDE and
OpenBox) which might still be usable.
* sway - Wayland based. Martins uses this. I want to try it but it lacks
nvidia driver support and requires something called wlroots? I don't
want to mess with this in my testing vm. Maybe later if I do a proper
Arch install.
* https://github.com/tyqualters/sway-nvidia-guide
* https://www.reddit.com/r/archlinux/comments/yuu7ra/whats_the_difference_between_nvidia_and_nvidiaopen/
* using seatd for hardware device collection
## Graphics
* card family https://nouveau.freedesktop.org/CodeNames.html
* nvidia driver install guide https://github.com/korvahannu/arch-nvidia-drivers-installation-guide?tab=readme-ov-file
Martins — 06/17/2024 2:59 PM
if you don't want upstream releases then obviously arch is not for you, but
they have simple solution for that - aur, you can keep managing your
dependencies separately from system packages
Martins uses Sway:
Martins — 04/08/2024 10:41 PM
no, .bashrc
I have autologin on tty1
so whenever .bashrc executes on tty1, it starts sway:
if [ -z "${WAYLAND_DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then
export _JAVA_AWT_WM_NONREPARENTING=1
export SDL_VIDEODRIVER=wayland
export GDK_BACKEND=wayland
export CLUTTER_BACKEND=wayland
export QT_QPA_PLATFORM=wayland
export BEMENU_BACKEND=wayland
export TERMINAL=foot
export BROWSER=firefox
export MOZ_ENABLE_WAYLAND=1
export XDG_SESSION_TYPE=wayland
export XDG_CURRENT_DESKTOP=sway
exec systemd-cat -- sway
fi
Saw this on reddit: sudo pacman -S wayland xorg-xwayland xorg-xlsclients sway swaybg swaylock waybar wofi -y
What is wofi ?
* `config/` -> map contents to `~/.config`. * `config/` -> map contents to `~/.config`.
* `home/` -> map contents to `~/`. * `home/` -> map contents to `~/`.
# Setup
* Full disk encryption with Veracrypt
* Store /tmp in RAM * Store /tmp in RAM
* 2024: looks like it's done by default. See https://wiki.archlinux.org/title/Tmpfs
* Move browser cache directories to /tmp as a means of reducing file writes on SSD * Move browser cache directories to /tmp as a means of reducing file writes on SSD

View File

@@ -190,7 +190,7 @@ expand_unix_path_if_not_symlink_or_absolute() {
echo $path echo $path
} }
# Moves a single file. Optionally provide a new file name as a third param. # Moves a single file. Optionally provide a new file name as a third param.
move_file() { move_file() {
local src="$1" local src="$1"
local src_expanded=$(expand_path "$src") local src_expanded=$(expand_path "$src")
@@ -216,7 +216,7 @@ move_file() {
fi fi
} }
# Copies a single file. Optionally provide a new file name as a third param. # Copies a single file. Optionally provide a new file name as a third param.
# If you want to copy all files with a specific extension then use copy_dir_files. # If you want to copy all files with a specific extension then use copy_dir_files.
copy_file() { copy_file() {
local src="$1" local src="$1"
@@ -375,6 +375,8 @@ make_link() {
if [[ $dest_has_space -eq 1 ]]; then cmd_dest_path="\"$cmd_dest_path\""; fi if [[ $dest_has_space -eq 1 ]]; then cmd_dest_path="\"$cmd_dest_path\""; fi
link_cmd="cmd //c 'mklink $cmd_dest_path $cmd_source_path'" link_cmd="cmd //c 'mklink $cmd_dest_path $cmd_source_path'"
else else
cmd_source_path="$final_src"
cmd_dest_path="$final_dest"
if [[ $source_has_space -eq 1 ]]; then cmd_source_path="\"$cmd_source_path\""; fi if [[ $source_has_space -eq 1 ]]; then cmd_source_path="\"$cmd_source_path\""; fi
if [[ $dest_has_space -eq 1 ]]; then cmd_dest_path="\"$cmd_dest_path\""; fi if [[ $dest_has_space -eq 1 ]]; then cmd_dest_path="\"$cmd_dest_path\""; fi
link_cmd="ln -sf $cmd_source_path $cmd_dest_path" link_cmd="ln -sf $cmd_source_path $cmd_dest_path"

View File

@@ -1,3 +1,5 @@
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

@@ -41,6 +41,11 @@
127.0.0.1 mpa.autodesk.com #[Autodesk Analytics Client Service] 127.0.0.1 mpa.autodesk.com #[Autodesk Analytics Client Service]
127.0.0.1 sv.symcd.com #[Autodesk Download Manager] 127.0.0.1 sv.symcd.com #[Autodesk Download Manager]
# Dangerous polyfill
127.0.0.1 polyfill.io
# Very invasive info tracker # Very invasive info tracker
127.0.0.1 static.audienceinsights.net 127.0.0.1 static.audienceinsights.net
127.0.0.1 api.behavioralengine.com 127.0.0.1 api.behavioralengine.com
@@ -54,18 +59,18 @@
127.0.0.1 www.wip2.adobe.com www.wip3.adobe.com www.wip4.adobe.com wwis-dubc1-vip60.adobe.com crl.verisign.net CRL.VERISIGN.NET ood.opsource.net 127.0.0.1 www.wip2.adobe.com www.wip3.adobe.com www.wip4.adobe.com wwis-dubc1-vip60.adobe.com crl.verisign.net CRL.VERISIGN.NET ood.opsource.net
# Block Facebook # Block Facebook
127.0.0.1 www.facebook.com #127.0.0.1 www.facebook.com
127.0.0.1 facebook.com #127.0.0.1 facebook.com
127.0.0.1 static.ak.fbcdn.net #127.0.0.1 static.ak.fbcdn.net
127.0.0.1 www.static.ak.fbcdn.net #127.0.0.1 www.static.ak.fbcdn.net
127.0.0.1 login.facebook.com #127.0.0.1 login.facebook.com
127.0.0.1 www.login.facebook.com #127.0.0.1 www.login.facebook.com
127.0.0.1 fbcdn.net #127.0.0.1 fbcdn.net
127.0.0.1 www.fbcdn.net #127.0.0.1 www.fbcdn.net
127.0.0.1 fbcdn.com #127.0.0.1 fbcdn.com
127.0.0.1 www.fbcdn.com #127.0.0.1 www.fbcdn.com
127.0.0.1 static.ak.connect.facebook.com #127.0.0.1 static.ak.connect.facebook.com
127.0.0.1 www.static.ak.connect.facebook.com #127.0.0.1 www.static.ak.connect.facebook.com
#---------------------------------------------- #----------------------------------------------

View File

@@ -0,0 +1,4 @@
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell]
"FolderType"="NotSpecified"

View File

@@ -1,6 +1,8 @@
# Windows Setup # Windows Setup
* Make a system restore point after a fresh install. * Disable Microsoft's piece of shit Secure Time Seed (STS) because it can result in insane system clock times that wreck havoc.
* Open regedit and go to `KEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config`
* Set `UtilizeSslTimeDat` to 0 and reboot.
* Disable Windows Platform Binary Table * Disable Windows Platform Binary Table
* This is a system Windows made for hardware vendors to inject firmware to the OS drive, running it at boot time. * This is a system Windows made for hardware vendors to inject firmware to the OS drive, running it at boot time.
@@ -9,18 +11,32 @@
that they're corporate systems have been hacked multiple times in the last year). Anyway, this feature is fucking that they're corporate systems have been hacked multiple times in the last year). Anyway, this feature is fucking
dumb and you can be sure that all mobo vendors are using this stupid shit. I don't blame them though since Microsoft dumb and you can be sure that all mobo vendors are using this stupid shit. I don't blame them though since Microsoft
built this for them. There's no way to stop this from happening other than to disable the platform entirely. built this for them. There's no way to stop this from happening other than to disable the platform entirely.
* Run `disable-windows-platform-binary-table.reg` and reboot. * Open `disable-windows-platform-binary-table.reg` and reboot.
**Make a system restore point before proceeding.**
* Change PC name * Change PC name
* Open settings -> System -> About -> Rename this PC * Open settings -> System -> About -> Rename this PC
* Reboot * Reboot
* Disable the annoying Windows alert sound that plays when doing things like using a terminal, hitting tab to autocomplete and it has no match. * Optionally target a specific Windows release for updates
* Open C:/windows/media * Useful when you want to stay on a specific release or install one that isn't yet available to you, e.g. running Win10 21H1, want 22H2.
* Find `Windows Background.wav` * If you don't care and just want Windows to give you the release when your system is selected then you probably want to disable the policy
* Right-click -> Properties -> Security -> Advanced -> Change Owner from `TrustedInstaller` to your user account -> Apply instead of leaving it as "not configured". I wasn't getting 22H2 and Windows Update claimed this policy was in use. I had to target 22H2
* Back in the previous Security tab, click Edit to change permisisons -> add your user account and grant all permissions to get it and then I left the option disabled. So, you might want to try disabled from the get-go and see how it plays out.
* Now you can delete the file or rename it. * Group policy editor:
* Administrative Templates -> Windows Components -> Windows Update -> Windows Update for Business
* Enable `Select the target Feature Update version`, set the product to `Windows 10` and the version to `22H2` or whatever you want.
* Now check for new Windows updates, should pick up the target version.
* Review trusted root certificate authorities
* Open the Microsoft Management Console (win+r, mmc)
* File -> Add/Remove Snap-in -> Certificates -> Add
* Choose `Computer Account` -> Next -> select `Local computer` -> Finish -> OK
* Expand the cert tree -> click on `Trusted Root Certificate Authorities` -> `Certificates`
* Before deleting a certificate, export it as a backup in case it's needed for system operation. Can also make a
restore point before making any changes.
* Note: I'm putting exports in backups/windows_certificates
* Maybe disable swapfile * Maybe disable swapfile
* Not a good idea to have this turned on for SSDs since it's extra writes, and writing to an SSD degrades the drive. Probably best to put this on a spinning disk. * Not a good idea to have this turned on for SSDs since it's extra writes, and writing to an SSD degrades the drive. Probably best to put this on a spinning disk.
@@ -29,29 +45,128 @@
* Advanced System Settings -> Advanced -> Performance settings -> Advanced -> Change paging settings -> set the drives to none * Advanced System Settings -> Advanced -> Performance settings -> Advanced -> Change paging settings -> set the drives to none
* Reboot * Reboot
* Download [O&O ShutUp10](https://www.oo-software.com/en/shutup10) and disable things.
* Download [InControl](https://www.grc.com/incontrol.htm) to stop Microsoft from pushing Windows 11.
* Install Open-Shell to restore the start menu to the sensible Windows 7 style.
* Disable `Enhance Pointer Precision`: * Disable `Enhance Pointer Precision`:
* Mouse Properties -> Pointer Options -> Motion section * Mouse Properties -> Pointer Options -> Motion section
* Laptop: change touchpad sensitivity to medium or high in order to prevent mouse movement when palm touches the pad while typing. * Laptop: change touchpad sensitivity to medium or high in order to prevent mouse movement when palm touches the pad while typing.
* If using a Lenovo then disable touchpad lock in the Lenovo Vantage app. * If using a Lenovo then disable touchpad lock in the Lenovo Vantage app.
* Map caps key to left-ctrl * Desktop: turn off hibernation
* If the keyboard supports remapping at the hardware level (e.g. like the Keychron keyboards) then map it there and this should cover all * Open admin cmd prompt: `powercfg.exe /hibernate off`
use cases, including Steam Link which for some reason does not respect the various remapping setups (except for PowerTools - see below).
* For software based remapping, there are two options:
* Use SharpKeys for a simple config change in Windows. You don't have to run any software at startup to get the remapping. The downside is that
this doesn't work over Steam Link.
* Use Bill Microsoft's [PowerTools](https://github.com/microsoft/PowerToys/releases/). Install it and then go to the key remapper tool in the settings.
This works over Steam Link but it requires you to run the program to get the remapping. If you go down this path then be sure to go through the settings
and disable the various tools that you don't want.
* Download [O&O ShutUp10](https://www.oo-software.com/en/shutup10) and disable things. * Enable long paths:
* winkey+r -> `gpedit.msc`.
* Computer Configuration > Administrative Templates > System > Filesystem
* Double-click the `Enable Win32 long paths` policy.
* Select Enabled.
* Download [InControl](https://www.grc.com/incontrol.htm) to stop Microsoft from pushing Windows 11. * Disable power throttling:
* winkey+r -> `gpedit.msc`.
* Computer Configuration > Administrative Templates > System > Power Management > Power Throttling Settings
* Double-click the `Turn off Power Throttling` policy.
* Select Enabled.
* Disable Corana: group policy -> Administrative Templates -> Search -> disable the "Allow Cortana ..." settings. * Enable Ultimate Power Plan (alternatively make a new plan and set the min/max processor speed to 100%)
* Open cmd as admin, run `powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61`
* Can now select the ultimate power plan in power options.
* Install Open-Shell to restore the start menu to the sensible Windows 7 style. * Create a power plan for software benchmarking
* This will disable turbo boost and general lock the frequency to base-ish clock. This can help
keep CPU temps stable (hot temps affect clock) and it avoids variable clock changes.
* AFAIK this only works for Intel CPUs; not sure how to do the same thing on AMD.
* In the power plan set the processor min/max speed to 99%.
* Disable reserved network bandwidth
* winkey+r -> `gpedit.msc`.
* Computer Configuration > Administrative Templates > Network > QoS Packet Scheduler > Limit reservable bandwidth
* Enable it and set the % to 0.
* Disable auto folder type discovery to speed up opening folders with a lot of files
* Open `disable-folder-type-auto-discovery.reg` from this folder.
* Turn off drive indexing for all drives since we'll be using Everything app for search and it does its own indexing.
* Right-click a drive, under `General` tab uncheck `Allow files on this drive to have contents indiexed ...`
* Disable UAC screen dimming
* Open User Account Control settings
* Drag the slider down to the notch that doesn't dim the screen.
* Disable remote assistance
* Disable Windows error reporting dialog so that when stuff crashes you can get to a debugger faster.
* Open an admin cmd prompt and run the file `disable-windows-error-reporting-dialog.bat` from this directory.
* Disable Microsoft Compatibility Appraiser (I believe this is for checking if you can run the next major OS; it's a CPU hog)
* Open task scheduler.
* Go to `Microsoft\Windows\Application Experience` and disable the `Microsoft Compatibility Appraiser` task.
* Disable the WinSAT task which is used to figure out your Windows performance score. It eats up
processor time and is generally useless.
* Open task scheduler.
* **note** If you see an error about a selected task {0} no longer existing then you'll need
to repair the task scheduler. See
https://www.thewindowsclub.com/the-selected-task-0-no-longer-exists-error-in-task-scheduler
* Go to `Microsoft\Windows\Maintenance` and disable the `WinSAT` task.
* Disable the Windows Customer Experience Improvement program via group policy
https://web.archive.org/web/20200131202352/https://www.ghacks.net/2016/10/26/turn-off-the-windows-customer-experience-program/
* Disable web search in Windows explorer search box (can speed up the horrible search feature, but really just use the Everything app!)
* Group policy editor:
* Computer Configuration -> Administrative Templates -> Windows Components -> Search
* Enable `Do no allow web search` and `Don't search the web or disable web results in Search`
* Alternatively, just disable the Windows search service altogether.
* Disable Cortana:
* Group policy editor:
* Computer Configuration -> Administrative Templates -> Windows Components -> Search
* Disable `Allow Cortana ...` settings.
* Increase TDR setting for GPU Driver
* TDR determines the length of time that a GPU can hang on a computation until the OS restarts
the driver. By default this is set to a few seconds so you can experience app crashes when
using GPU intensive software, like 3D modeling or texturing. To increase the duration, follow
this guide: https://web.archive.org/web/20191107173337/https://docs.substance3d.com/spdoc/gpu-drivers-crash-with-long-computations-128745489.html
* **Optional:** disable Windows Defender real-time protection:
* This can speed up compilation times since Defender will scan every file written to disk. I was
able to shave off ~2-5 seconds in a particular project.
* If you'd rather keep real-time protection active then you can add specific files or
folders to the Defender exclusion list in the Windows Security settings, however I did
some testing and didn't see any speedup when excluding a project folder.
* Go into the Windows security settings and disable `Tamper Protection`.
* winkey+r -> `gpedit.msc`.
* Can now disable either with a policy or some custom batch files.
* Group policy:
* Computer Configuration > Administrative Templates > Windows Components > Microsoft Defender Antivirus -> Real-time Protection
* Double-click the `Turn off real-time protection` policy.
* Select Enabled (you may have to restart PC).
* If you want to re-enable then change the policy to `Not configured` and re-enable tamper protection.
* Batch files: in `dotfiles/bin` run `antimalware-service-disable.bat` then restart. Reenable it with `antimalware-service-enable.bat`
* Enable/disable various Window features:
* Go to Add/Remove Programs -> Turn Windows features on or off
* Disable:
* Windows hypervisor platform (can break Virtualbox)
* Internet Explorer 11
* Legacy Components - DirectPlay
* Media Features - Windows Media Player
* Microsoft Print to PDF
* Microsoft XPS Document Writer (and any other XPS components)
* Print and Document Services - Internet Printing Client & Windows Fax and Scan
* Windows PowerShell 2.0 (current version is 5+ as of 2021-03-05)
* Work folders client
* Turn off various startup processes
* ctrl+shift+esc -> startup
* Disable unneeded services
* Pin "This PC" to taskbar * Pin "This PC" to taskbar
* In Win 10 start menu, search for "This PC", right click top result and pin to taskbar * In Win 10 start menu, search for "This PC", right click top result and pin to taskbar
@@ -78,90 +193,11 @@
* Disable window suggestion when snapping a window * Disable window suggestion when snapping a window
* Windows settings -> System -> Multitasking -> uncheck "When I snap a window, show what I can snap next to it" * Windows settings -> System -> Multitasking -> uncheck "When I snap a window, show what I can snap next to it"
* Desktop: turn off hibernation
* Open admin cmd prompt: `powercfg.exe /hibernate off`
* Disable power throttling:
* winkey+r -> `gpedit.msc`.
* Computer Configuration > Administrative Templates > System > Power Management > Power Throttling Settings
* Double-click the `Turn off Power Throttling` policy.
* Select Enabled.
* Disable reserved network bandwidth
* winkey+r -> `gpedit.msc`.
* Computer Configuration > Administrative Templates > Network > QoS Packet Scheduler > Limit reservable bandwidth
* Enable it and set the % to 0.
* Enable ultimate power plan (alternatively make a new plan and set the min/max processor speed to 100%)
* Open cmd as admin, run `powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61`
* Can now select the ultimate power plan in power options.
* Create a power plan for software benchmarking
* This will disable turbo boost and general lock the frequency to base-ish clock. This can help
keep CPU temps stable (hot temps affect clock) and it avoids variable clock changes.
* AFAIK this only works for Intel CPUs; not sure how to do the same thing on AMD.
* In the power plan set the processor min/max speed to 99%.
* Disable UAC screen dimming
* Open User Account Control settings
* Drag the slider down to the notch that doesn't dim the screen.
* Disable remote assistance
* Disable Windows error reporting dialog so that when stuff crashes you can get to a debugger faster.
* Open an admin cmd prompt and run the file `disable-windows-error-reporting-dialog.bat` from this directory.
* Disable the WinSAT task which is used to figure out your Windows performance score. It eats up
processor time and is generally useless.
* Open task scheduler.
* **note** If you see an error about a selected task {0} no longer existing then you'll need
to repair the task scheduler. See
https://www.thewindowsclub.com/the-selected-task-0-no-longer-exists-error-in-task-scheduler
* Go to `Local\Microsoft\Windows\Maintenance` and disable the WinSAT task.
* Disable the Windows Customer Experience Improvement program via group policy
https://web.archive.org/web/20200131202352/https://www.ghacks.net/2016/10/26/turn-off-the-windows-customer-experience-program/
* Increase TDR setting for GPU Driver
* TDR determines the length of time that a GPU can hang on a computation until the OS restarts
the driver. By default this is set to a few seconds so you can experience app crashes when
using GPU intensive software, like 3D modeling or texturing. To increase the duration, follow
this guide: https://web.archive.org/web/20191107173337/https://docs.substance3d.com/spdoc/gpu-drivers-crash-with-long-computations-128745489.html
* **Optional:** disable Windows Defender real-time protection:
* This can speed up compilation times since Defender will scan every file written to disk. I was
able to shave off ~2-5 seconds in a particular project.
* If you'd rather keep real-time protection active then you can add specific files or
folders to the Defender exclusion list in the Windows Security settings, however I did
some testing and didn't see any speedup when excluding a project folder.
* Go into the Windows security settings and disable `Tamper Protection`.
* winkey+r -> `gpedit.msc`.
* Can now disable either with a policy or some custom batch files.
* Policy:
* Computer Configuration > Administrative Templates > Windows Components > Microsoft Defender Antivirus -> Real-time Protection
* Double-click the `Turn off real-time protection` policy.
* Select Enabled (you may have to restart PC).
* If you want to re-enable then change the policy to `Not configured` and re-enable tamper protection.
* Batch files: in `dotfiles/bin` run `antimalware-service-disable.bat` then restart. Reenable it with `antimalware-service-enable.bat`
* Enable/disable various Window features:
* Go to Add/Remove Programs -> Turn Windows features on or off
* Disable:
* Windows hypervisor platform (can break Virtualbox)
* Internet Explorer 11
* Legacy Components - DirectPlay
* Media Features - Windows Media Player
* Microsoft Print to PDF
* Microsoft XPS Document Writer (and any other XPS components)
* Print and Document Services - Internet Printing Client & Windows Fax and Scan
* Windows PowerShell 2.0 (current version is 5+ as of 2021-03-05)
* Work folders client
* Restore classic Windows Photo Viewer app (the default Win10 photos app is fucking awful): * Restore classic Windows Photo Viewer app (the default Win10 photos app is fucking awful):
* Run photo_viewer.reg from this folder. * Open `photo_viewer.reg` from this folder.
* You'll need to change the default app for the various image extensions. Don't change gif types * You'll need to change the default app for the various image extensions. Don't change gif types
though because photo viewer doesn't support animations. though because photo viewer doesn't support animations.
* Now run disable-are-you-sure-you-want-to-open-with-the-default-program-dialog.reg to stop it * Open `disable-are-you-sure-you-want-to-open-with-the-default-program-dialog.reg` to stop it
from occasionally asking if you still want to use photo viewer. from occasionally asking if you still want to use photo viewer.
* Add custom hosts file * Add custom hosts file
@@ -185,12 +221,29 @@ processor time and is generally useless.
* Disable various web trackers using browserleaks.com as a guide. * Disable various web trackers using browserleaks.com as a guide.
* e.g. disable WebGL, canvas fingerprinting, geolocation, font fingerprint, etc. * e.g. disable WebGL, canvas fingerprinting, geolocation, font fingerprint, etc.
* Turn off various startup processes * Disable the annoying Windows alert sound that plays when doing things like using a terminal, hitting tab to autocomplete and it has no match.
* ctrl+shift+esc -> startup * Open C:/windows/media
* Find `Windows Background.wav`
* Right-click -> Properties -> Security -> Advanced -> Change Owner from `TrustedInstaller` to your user account -> Apply
* Back in the previous Security tab, click Edit to change permisisons -> add your user account and grant all permissions
* Now you can delete the file or rename it.
* Disable unneeded services * Map caps key to left-ctrl
* If the keyboard supports remapping at the hardware level (e.g. like the Keychron keyboards) then map it there and this should cover all
use cases, including Steam Link which for some reason does not respect the various remapping setups (except for PowerTools - see below).
* For software based remapping, there are two options:
* Use SharpKeys for a simple config change in Windows. You don't have to run any software at startup to get the remapping. The downside is that
this doesn't work over Steam Link.
* Use Bill Microsoft's [PowerTools](https://github.com/microsoft/PowerToys/releases/). Install it and then go to the key remapper tool in the settings.
This works over Steam Link but it requires you to run the program to get the remapping. If you go down this path then be sure to go through the settings
and disable the various tools that you don't want.
* If using 2+ monitors with different resolutions then you'll very likely have trouble with the mouse cursor moving from one screen to another due to a bad mapping.
You can fix this by installing [LittleBigMouse](https://github.com/mgth/LittleBigMouse/releases), run it, check the `Allow Corner Crossing` box and then apply. But note
that I had some issues when running this. I forget the details now. Ended up uninstalling.
* Do a pass over all Windows setting screens for anything obvious that wasn't covered here. * Do a pass over all Windows setting screens for anything obvious that wasn't covered here.
* Open the Windows settings Apps & features and remove bloatware that isn't visible in the * Open the Windows settings Apps & features and remove bloatware that isn't visible in the
control panel add/remove list, e.g. OneDrive control panel add/remove list, e.g. OneDrive