Compare commits

..

58 Commits

Author SHA1 Message Date
d19e60cfc3 Changed the worktree to one directory back (i.e. $HOME) and simplified the setup 2023-06-14 02:02:43 -04:00
0ee1e7666e Prep work before we use the new setup 2023-06-13 15:45:28 -04:00
c7845e62d9 Make moving lines easier in vim and change the tab listchar 2023-06-13 14:56:35 -04:00
2a57ce8837 Rename stuff in vimrc 2023-06-12 22:51:42 -04:00
a529cd6560 Improve vimrc - abbreviation fix, some leader stuff 2023-06-12 22:50:02 -04:00
589abb9e46 Tweak whisper core/thread count 2023-06-12 22:49:45 -04:00
6df4a1e506 Add a registry key for disabling the Windows platform binary table 2023-06-09 17:20:39 -04:00
10c6e8e06c Update aliases 2023-06-09 17:20:24 -04:00
f70bc8b9cd Alias tweaks around video dl 2023-06-06 15:48:43 -04:00
dad6be889f More transcription script improvements 2023-06-05 17:12:16 -04:00
e979d1094c Set whisper thread count based on the model 2023-06-05 14:18:44 -04:00
ce1599466e Update aliases with some audio transcription stuff 2023-06-05 01:23:47 -04:00
e5e8f309e5 Improve transcribe api and add alias to transcribe twitch stream downloads 2023-06-04 14:40:45 -04:00
8ff9c338b5 Add vimrc function for searching specific extensions 2023-06-03 17:42:42 -04:00
173bda9eb0 Add scripts for audio transcription using whisper.cpp 2023-06-03 17:42:30 -04:00
06bbc0c995 Use absolute path to build.jai 2023-06-03 16:22:13 -04:00
f19e84e1a5 Change some vim mappings 2023-05-21 18:02:21 -04:00
1a46964bd7 Tweak Windows key remapping notes 2023-05-16 12:05:46 -04:00
0e91857946 Note on disabling Cortana 2023-05-14 21:31:22 -04:00
bb31351404 Explain how to map caps to ctrl for wireless keyboards connected to a Steam Link 2023-05-12 18:35:13 -04:00
7b031d3127 More tweaks to the vimrc run function 2023-05-10 14:56:43 -04:00
c05131d38f Move a vimrc function so that it can be called in a private vimrc 2023-05-10 13:06:52 -04:00
418d1ae956 Fix typo in vimrc 2023-05-08 23:34:04 -04:00
e614936478 Add a trim video script that is more accurate 2023-05-07 16:11:49 -04:00
5bed58e55c Split jai compiler and metaprogram args in vimrc 2023-05-06 22:07:05 -04:00
6800f7ccc4 Improve jai build code in vimrc 2023-05-06 22:01:03 -04:00
40eb9aa808 SSH notes 2023-05-01 04:50:41 -04:00
53082c6034 Tweak some vim build/run stuff around jai 2023-05-01 04:50:36 -04:00
f084b19637 Add x32dbg wrapper script 2023-04-26 15:46:12 -04:00
4323bd9721 Add a note about disabling the annoying windows alert sound 2023-04-06 12:17:03 -04:00
28c88ca5f1 Stop git from changing line endings on Windows and add support for editorconfig in vim 2023-03-16 16:44:38 -04:00
4464e4f681 Add a script that removes audio from a video 2023-03-16 12:59:38 -04:00
08a26b6716 Update windows readme 2023-03-13 19:07:15 -04:00
84b221bdb9 Renaming alias stuff 2023-03-01 15:27:38 -05:00
2e07b0c85f vim build and run updates 2023-03-01 15:27:26 -05:00
d664ba882c Do our own save call when compiling files in vim 2023-02-01 17:11:25 -05:00
2f9dc3aba7 Add batch file for running x64dbg 2023-02-01 16:43:26 -05:00
f0248008a6 Add a vim function to toggle a 'simple' view of the current buffer 2023-01-30 13:57:38 -05:00
7e586d284d Formatting changes in vimrc 2023-01-27 16:04:50 -05:00
816a0be564 Disable vim terminal cmd 2023-01-26 15:54:02 -05:00
cef7886859 vimrc cleanup (move templates, remove static scopes) 2023-01-24 14:08:56 -05:00
9e07b24cf7 Escape some characters in vim rip-grep search 2023-01-22 08:34:29 -05:00
12969578aa Change vim centering offset 2023-01-22 08:34:06 -05:00
89d5709677 Update vim color scheme 2023-01-19 19:10:47 -05:00
2343c46b89 Set jai build args in a private vimrc 2023-01-19 18:13:38 -05:00
9371817937 Improve jai search and compiling in vim 2023-01-04 22:25:15 -05:00
8eccc9659a Clean up some aliases 2023-01-04 22:24:48 -05:00
45d3fa244a Clean up vim search and import local jai modules when building 2022-12-30 18:47:27 -05:00
2640761dc5 Improve ctrlp ctag situation and add some jai searching 2022-12-29 19:20:11 -05:00
0227534656 Improve vim theme toggling 2022-12-29 18:53:54 -05:00
78fd8f6d45 Update setup notes 2022-12-28 00:49:01 -05:00
736bab22ec Disable some vim plugins 2022-12-28 00:48:50 -05:00
0a7bb3c2a1 Improve the compress video scripts 2022-12-28 00:46:37 -05:00
c0dd5208a0 Tweak color scheme and vim dict 2022-12-13 17:33:51 -05:00
7c828c01f1 Update vimrc 2022-12-10 19:40:37 -05:00
c1e333e7db Start cleaning up vim color schemes 2022-12-10 19:40:37 -05:00
4238273951 Add vim function to edit current color scheme 2022-11-29 22:33:10 -05:00
7f121ab292 Add support for info error marker in vimrc 2022-11-29 22:32:52 -05:00
148 changed files with 2944 additions and 2264 deletions

View File

@@ -36,11 +36,6 @@ error() {
printf "${BOLD}${RED}$1${NORMAL}\n"
}
abort() {
error "\nAborting..."
exit 1
}
reload() {
test -f ~/.env.loader && . ~/.env.loader
}
@@ -130,37 +125,37 @@ open_explorer_here() {
# Dev build
b() {
if [ -f build ]; then ./build $@ ; else test -f build.sh && ./build.sh $@ ; fi
test -f build && ./build $@ ; test -f build.sh && ./build.sh $@ ; test -f build.jai && ./build.jai $@
}
# fast dev build
bf() {
if [ -f build ]; then ./build $@ -fast ; else test -f build.sh && ./build.sh $@ -fast ; fi
test -f build && ./build $@ -fast ; test -f build.sh && ./build.sh $@ -fast ; test -f build.jai && ./build.jai $@
}
# Optimized dev build
bb() {
if [ -f build ]; then ./build -o 1 $@ ; else test -f build.sh && ./build.sh -o 1 $@ ; fi
test -f build && ./build $@ -o 1 ; test -f build.sh && ./build.sh $@ -o 1 ; test -f build.jai && ./build.jai -release $@
}
# Production build
bp() {
if [ -f build ]; then ./build -p p $@ ; else test -f build.sh && ./build.sh -p p $@ ; fi
test -f build && ./build $@ -p p ; test -f build.sh && ./build.sh $@ -p p ; test -f build.jai && ./build.jai -release $@ - -prod
}
# Profiling build
bpf() {
if [ -f build ]; then ./build -p pf $@ ; else test -f build.sh && ./build.sh -p pf $@ ; fi
test -f build && ./build $@ -p pf ; test -f build.sh && ./build.sh $@ -p pf
}
# GPU profiling build
bgpf() {
if [ -f build ]; then ./build -p gpu $@ ; else test -f build.sh && ./build.sh -p gpu $@ ; fi
test -f build && ./build $@ -p gpu ; test -f build.sh && ./build.sh $@ -p gpu
}
# Run build
r() {
if [ -f run ]; then ./run $@ ; else test -f run.sh && ./run.sh $@ ; fi
test -f run && ./run $@ ; test -f run.sh && ./run.sh $@
}
# Build then run
@@ -194,7 +189,7 @@ alias ls='ls -F --color'
alias l='ls -lh'
alias ll='ls -lha'
alias aliases='vim ~/.dotfiles/aliases'
alias aliases='vim ~/.aliases'
alias al='aliases'
if [[ "${platform,,}" == *'ming'* ]]; then
@@ -217,7 +212,7 @@ check_signature() {
local sig_file="$4"
if [[ $hashes_file == "" || $pem_file == "" || $sig_file == "" ]]; then
error "Format: $0 <hashes file (e.g. sha512 hashes)> <pem file> <sig file>\n"
error "Usage: <hashes file (e.g. sha512 hashes)> <pem file> <sig file>"
return
fi
@@ -283,6 +278,8 @@ custom_grep() {
local include_list=("$@")
local include_arg=""
if [[ $include_list != "" ]]; then
# We're looping like this instead of for var in "$@", because that way of looping is affecting
# my shell environment. Very strange!
for i in "${include_list[@]}"; do
include_arg+="--include=\*${i} "
done
@@ -316,9 +313,13 @@ alias grep-dev='grep_dev'
COMPRESSION_ON=1
COMPRESSION_OFF=0
SHORTNAME_ON=1
SHORTNAME_OFF=0
TRANSCRIBE_ON=1
TRANSCRIBE_OFF=0
make_vid_dir_and_cd_into() {
local url="$1"
local dir_name="$2"
@@ -342,79 +343,78 @@ make_vid_dir_and_cd_into() {
error=$?
if [[ ! $error -eq 0 ]]; then
error "Error: failed to create directory. Aborting.\n"
error "Error: failed to create directory. Aborting."
return 1
fi
return 0
}
function my_transcribe_video() {
file="$1"
output="$2"
if [[ $file == "" ]]; then
printf "Usage: <input video> <optional output name>\n"
return
fi
if [[ $output == "" ]]; then
output="${1%.*}" # just use the input name without the extension.
fi
# Tiny is fast and semi-accurate, so whatever.
# Base is pretty good overall. It has good punctuation inserting and
# catches most words. Small and medium can do better word detection at
# times, but suffer from bad punctuation. Medium is particularly bad and
# not adding commas and periods.
transcribe-video "$file" "$output" tiny base
}
function my_transcribe_video_all_models() {
file="$1"
output="$2"
if [[ $file == "" ]]; then
printf "Usage: <input video> <optional output name>\n"
return
fi
if [[ $output == "" ]]; then
output="${1%.*}" # just use the input name without the extension.
fi
transcribe-video "$file" "$output" tiny base small medium
}
# Download YouTube videos. Note that yt-dlp downloads a lot faster than streamlink.
dl_youtube_vid() {
download_youtube_vid() {
local format="$1"
local shortname="$2"
local make_folder="$3"
local url="$4"
shift 4
local transcribe="$3"
local make_folder="$4"
local url="$5"
shift 5
local opts="$@"
if [[ $url == "" ]]; then
error "Format: $0 <make folder?> <url> <optional args>\n"
error "Usage: <make folder?> <url> <optional args>"
return
fi
if [[ $format == "" ]]; then
printf "${BOLD}No format given; using best available.${NORMAL}\n"
# Download best mp4 video and best m4a audio, then merge.
format="bv*[ext=mp4]+ba[ext=m4a]"
opts+=" --merge-output-format mp4"
fi
opts+=" --write-subs --sub-lang en --embed-subs"
if [[ $make_folder == "1" ]]; then
make_vid_dir_and_cd_into $url ""
if [[ $? -ne 0 ]]; then
return
fi
fi
if [[ $shortname -eq 0 ]]; then
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s.%(ext)s"
if [[ $shortname == "1" || $transcribe == "1" ]]; then
printf "${BOLD}Downloading Youtube vid "
if [[ $shortname == "1" ]]; then printf "| ${YELLOW}using short name${NORMAL}${BOLD} "; fi
if [[ $transcribe == "1" ]]; then printf "| ${YELLOW}audio transcription on${NORMAL}${BOLD} "; fi
printf "\n\n${NORMAL}"
else
local name_format="%(upload_date>%Y-%m-%d)s-shortname-yt-%(id)s.%(ext)s"
printf "${BOLD}Downloading Youtube vid\n\n${NORMAL}"
fi
local cmd="yt-dlp.exe -f $format -o \"$name_format\" $opts $url"
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
# Removing any trailing subtitle files
rm *.vtt *.srt 2>/dev/null
if [[ $make_folder == "1" ]]; then
cd ..
fi
}
# Download YouTube video and flip horizontally.
dl_youtube_vid_and_hflip() {
local format="$1"
local make_folder="$2"
local url="$3"
shift 3
local opts="$@"
if [[ $url == "" ]]; then
error "Format: $0 <make folder?> <url> <optional args>\n"
return
fi
if [[ $format == "" ]]; then
printf "${BOLD}No format given; using best available.${NORMAL}\n"
# Download best mp4 video and best m4a audio, then merge.
# Download best mp4 video.
format="bv*[ext=mp4]+ba[ext=m4a]"
opts+=" --merge-output-format mp4"
fi
opts+=" --write-sub --sub-lang en --embed-subs"
# 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
make_vid_dir_and_cd_into $url ""
@@ -423,24 +423,40 @@ dl_youtube_vid_and_hflip() {
fi
fi
local filename=$(yt-dlp.exe --get-filename -f $format -o "%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s.%(ext)s" $url)
if [[ $shortname == "0" ]]; then
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s"
else
local name_format="%(upload_date>%Y-%m-%d)s-shortname-yt-%(id)s"
fi
# Get the video filename.
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
printf "filename: $filename\n"
# Download
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
# Removing any trailing subtitle files
rm *.vtt *.srt 2>/dev/null
# Flip
ffmpeg -i "$filename" -vf hflip -c:a copy "copy_${filename}"
mv "copy_${filename}" "$filename"
if [[ $make_folder == "1" ]]; then
cd ..
if [[ $transcribe == "1" ]]; then
my_transcribe_video "$filename"
fi
if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
}
dl_youtube_playlist() {
download_youtube_playlist() {
local format="$1"
local url="$2"
local dir_name="$3"
@@ -448,9 +464,12 @@ dl_youtube_playlist() {
local opts="$@"
if [[ $url == "" ]]; then
error "Format: $0 <url> <directory name (optional)> <optional args>\n"
error "Usage: <url> <directory name (optional)> <optional args>"
return
fi
printf "${BOLD}Downloading Youtube playlist\n\n${NORMAL}"
if [[ $format == "" ]]; then
printf "${BOLD}No format given; using best available.${NORMAL}\n"
# Download best mp4 video and best m4a audio, then merge.
@@ -473,11 +492,60 @@ dl_youtube_playlist() {
# Removing any trailing subtitle files
rm *.vtt *.srt 2>/dev/null
cd ..
if [[ $dir_name == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading the playlist\n${NORMAL}"
}
download_youtube_playlist_list() {
local url="$1"
local output_name="$2"
shift 2
local opts="$@"
if [[ $url == "" || $output_name == "" ]]; then
error "Usage: <url> <output name> <optional args>"
return
fi
printf "${BOLD}Downloading Youtube playlist video list\n\n${NORMAL}"
local cmd="yt-dlp.exe --ignore-errors -O \"%(playlist_index)s-%(title)s--%(id)s\" --skip-download $opts $url"
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}"
}
download_youtube_uploads_list() {
local include_descriptions="$1"
local url="$2"
local output_name="$3"
shift 3
local opts="$@"
if [[ $url == "" || $output_name == "" ]]; then
error "Usage: <url> <output name> <optional args>"
return
fi
local cmd=""
if [[ $include_descriptions == "1" ]]; then
printf "${BOLD}Downloading Youtube uploads list with descriptions\n\n${NORMAL}"
cmd="yt-dlp.exe --ignore-errors -O \"@@@ %(video_autonumber)s-%(upload_date>%Y-%m-%d)s--%(title)s--%(id)s\" --skip-download --get-description $opts $url"
else
printf "${BOLD}Downloading Youtube uploads list\n\n${NORMAL}"
cmd="yt-dlp.exe --ignore-errors -O \"%(video_autonumber)s-%(upload_date>%Y-%m-%d)s--%(title)s--%(id)s\" --skip-download $opts $url"
fi
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}"
}
# Download Twitch chat transcript
actually_dl_twitch_chat() {
actually_download_twitch_chat() {
local url="$1"
local filename="$2"
@@ -488,16 +556,18 @@ actually_dl_twitch_chat() {
else
error "Video doesn't have a chat transcript."
fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
}
dl_twitch_chat() {
download_twitch_chat() {
local make_folder="$1"
local url="$2"
shift 2
local opts="$@"
if [[ $url == "" ]]; then
error "Format: $0 <url>\n"
error "Usage: <url>"
return
fi
@@ -508,11 +578,9 @@ dl_twitch_chat() {
fi
fi
actually_dl_twitch_chat $url "$(yt-dlp.exe --get-filename -o "%(upload_date>%Y-%m-%d)s-%(title)s-tw-%(id)s" $opts $url)"
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)"
if [[ $make_folder == "1" ]]; then
cd ..
fi
if [[ $make_folder == "1" ]]; then cd ..; fi
}
# Download Twitch videos, both VODs and live streams. Pass a Twitch account URL to download a live stream.
@@ -526,17 +594,18 @@ dl_twitch_chat() {
# 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.
#
dl_twitch_vid() {
download_twitch_vid() {
local format="$1"
local shortname="$2"
local compress="$3"
local make_folder="$4"
local url="$5"
shift 5
local transcribe="$4"
local make_folder="$5"
local url="$6"
shift 6
local opts="$@"
if [[ $url == "" ]]; then
error "Format: $0 <make folder?> <url> <optional args>\n"
error "Usage: <make folder?> <url> <optional args>"
return
fi
@@ -551,10 +620,14 @@ dl_twitch_vid() {
printf "${BOLD}Subscriber VOD. Will use yt-dlp to download.${NORMAL}\n"
fi
if [[ $compress -eq 0 ]]; then
printf "${BOLD}Downloading Twitch vid with no compression.${NORMAL}\n"
if [[ $shortname == "1" || $compress == "1" || $transcribe == "1" ]]; then
printf "${BOLD}Downloading Twitch vid "
if [[ $shortname == "1" ]]; then printf "| ${YELLOW}using short name${NORMAL}${BOLD} "; fi
if [[ $compress == "1" ]]; then printf "| ${YELLOW}compression on${NORMAL}${BOLD} "; fi
if [[ $transcribe == "1" ]]; then printf "| ${YELLOW}audio transcription on${NORMAL}${BOLD} "; fi
printf "\n\n${NORMAL}"
else
printf "${BOLD}Downloading Twitch vid with compression.${NORMAL}\n"
printf "${BOLD}Downloading Twitch vid\n\n${NORMAL}"
fi
local yt_dlp_format=""
@@ -577,69 +650,82 @@ dl_twitch_vid() {
fi
fi
if [[ $shortname -eq 0 ]]; then
if [[ $shortname == "0" ]]; then
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-tw-%(id)s"
else
local name_format="%(upload_date>%Y-%m-%d)s-shortname-tw-%(id)s"
fi
# Download Twitch chat transcript
actually_dl_twitch_chat $url "$(yt-dlp.exe --get-filename -o "$name_format" $opts $url)"
actually_download_twitch_chat $url "$(yt-dlp.exe --get-filename -o "$name_format" $opts $url)"
# Get the video filename.
local filename=$(yt-dlp.exe --get-filename -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)
# Download
if [[ $subscriber_vod -eq 0 ]]; then
if [[ $subscriber_vod == "0" ]]; 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\""
else
local cmd="yt-dlp.exe -f $yt_dlp_format -o \"$filename\" $opts $url"
fi
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
printf "${YELLOW}${BOLD}Downloading video\n${NORMAL}"
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
error=$?
if [[ $error -eq 0 ]]; then
if [[ $compress -eq 1 ]]; then
local temp_name="temp_${RANDOM}"
# 1 arg = use GPU
compress-video 0 "$filename" "$temp_name"
extension="${filename##*.}"
mv "$filename" "orig_$filename"
mv $temp_name.$extension "$filename"
printf "${BOLD}Make sure to delete the original video file${NORMAL}\n"
fi
else
error "Error: Failed to download '$url'\n"
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 ..
if [[ $compress == "1" ]]; then
local temp_name="temp_${RANDOM}"
# 0=cpu, 1=gpu
compress-video "$filename" "$temp_name" 0
extension="${filename##*.}"
mv "$filename" "orig_$filename"
mv $temp_name.$extension "$filename"
printf "${BOLD}Make sure to delete the original video file\n${NORMAL}"
fi
if [[ $transcribe == "1" ]]; then
my_transcribe_video "$filename"
fi
if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
}
# Download Vimeo videos.
# Can download an embedded vid. You might need to save the site cookies if the vid is behind a paywall.
# e.g. yt-dlp.exe -F --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.
dl_vimeo_vid() {
local format="$1"
local shortname="$2"
local compress="$3"
local make_folder="$4"
local url="$5"
download_vimeo_vid() {
local shortname="$1"
local compress="$2"
local transcribe="$3"
local format="$4"
local make_folder="$5"
local url="$6"
shift 5
local opts="$@"
if [[ $url == "" ]]; then
error "Format: $0 <make folder?> <url> <optional args>\n"
if [[ $format == "" || $url == "" ]]; then
error "Usage: <format> <make folder?> <url> <optional args>"
return
fi
if [[ $compress -eq 0 ]]; then
printf "${BOLD}Downloading Vimeo vid with no compression.${NORMAL}\n"
if [[ $shortname == "1" || $compress == "1" || $transcribe == "1" ]]; then
printf "${BOLD}Downloading Vimeo vid "
if [[ $shortname == "1" ]]; then printf "| ${YELLOW}using short name${NORMAL}${BOLD} "; fi
if [[ $compress == "1" ]]; then printf "| ${YELLOW}compression on${NORMAL}${BOLD} "; fi
if [[ $transcribe == "1" ]]; then printf "| ${YELLOW}audio transcription on${NORMAL}${BOLD} "; fi
printf "\n\n${NORMAL}"
else
printf "${BOLD}Downloading Vimeo vid with compression.${NORMAL}.\n"
printf "${BOLD}Downloading Vimeo vid\n\n${NORMAL}"
fi
if [[ $make_folder == "1" ]]; then
@@ -649,7 +735,7 @@ dl_vimeo_vid() {
fi
fi
if [[ $shortname -eq 0 ]]; then
if [[ $shortname == "0" ]]; then
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-vimeo-%(id)s"
else
local name_format="%(upload_date>%Y-%m-%d)s-shortname-vimeo-%(id)s"
@@ -663,33 +749,39 @@ dl_vimeo_vid() {
error=$?
if [[ $error -eq 0 ]]; then
if [[ $compress -eq 1 ]]; then
if [[ $compress == "1" ]]; then
local temp_name="temp_${RANDOM}"
# 1 arg = use GPU
compress-video 1 "$filename" "$temp_name"
# 0=cpu, 1=gpu
compress-video "$filename" "$temp_name" 0
extension="${filename##*.}"
mv "$filename" "orig_$filename"
mv $temp_name.$extension "$filename"
printf "${BOLD}Make sure to delete the original video file${NORMAL}\n"
fi
else
error "Error: Failed to download '$url'\n"
error "Error: Failed to download '$url'"
if [[ $make_folder == "1" ]]; then cd ..; fi
return
fi
if [[ $make_folder == "1" ]]; then
cd ..
if [[ $transcribe == "1" ]]; then
my_transcribe_video "$filename"
fi
if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
}
# Download Twitter videos.
dl_twitter_vid() {
download_twitter_vid() {
local format="$1"
local make_folder="$2"
local url="$3"
local vid_name="$4"
if [[ $url == "" ]]; then
error "Format: $0 <make folder?> <url> <optional filename> <optional args>\n"
error "Usage: <make folder?> <url> <optional filename> <optional args>"
return
fi
@@ -724,21 +816,76 @@ dl_twitter_vid() {
error=$?
if [[ $error -eq 1 ]]; then
error "Error: Failed to download '$url'\n"
error "Error: Failed to download '$url'"
fi
if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
}
# Download Instagram videos.
download_instagram_vid() {
local transcribe="$1"
local make_folder="$2"
local url="$3"
local vid_name="$4"
if [[ $url == "" ]]; then
error "Usage: <make folder?> <url> <optional filename> <optional args>"
return
fi
printf "${BOLD}Downloading Instagram vid.${NORMAL}\n"
if [[ $vid_name == "" ]]; then
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-ig-%(id)s"
local opts=""
else
local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-ig-%(id)s"
shift 4
local opts="$@"
fi
if [[ $make_folder == "1" ]]; then
cd ..
make_vid_dir_and_cd_into $url $vid_name $opts
if [[ $? -ne 0 ]]; then
return
fi
fi
format="b" # best available
# Download the video.
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $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.
error=$?
if [[ $error -eq 1 ]]; then
error "Error: Failed to download '$url'"
if [[ $make_folder == "1" ]]; then cd ..; fi
return
fi
if [[ $transcribe == "1" ]]; then
transcribe "$filename"
fi
if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
}
# Download MP4 video.
dl_mp4() {
download_mp4() {
local url="$1"
local filename="$2"
if [[ $url == "" || $filename == "" ]]; then
error "Format: $0 <url> <filename>\n"
error "Usage: <url> <filename>"
return
fi
@@ -748,7 +895,7 @@ dl_mp4() {
curl "$url" -o $temp_name
if [[ $? -ne 0 ]]; then
error "Error: failed to download.\n"
error "Error: failed to download."
return
fi
@@ -756,12 +903,12 @@ dl_mp4() {
}
# Download from m3u8 stream to mp4.
dl_from_m3u8() {
download_from_m3u8() {
local m3u8_path="$1"
local filename="$2"
if [[ $m3u8_path == "" || $filename == "" ]]; then
error "Format: $0 <m3u8 path> <filename>\n"
error "Usage: <m3u8 path> <filename>"
return
fi
@@ -769,102 +916,138 @@ dl_from_m3u8() {
ffmpeg.exe -protocol_whitelist file,https,crypto,tls,tcp -i $m3u8_path -acodec copy -vcodec copy "${filename}.mp4"
if [[ $? -ne 0 ]]; then
error "Error: failed to download.\n"
error "Error: failed to download."
return
fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
}
# Download Instagram video and flip horizontally.
dl_instagram_vid_and_hflip() {
local url="$1"
local filename="$2"
if [[ $url == "" || $filename == "" ]]; then
error "Format: $0 <url> <filename>\n"
return
fi
temp_name="temp_${RANDOM}.mp4"
printf "${BOLD}Downloading: ${YELLOW}$filename${NORMAL}\n"
curl "$url" -o $temp_name
if [[ $? -ne 0 ]]; then
error "Error: failed to download.\n"
return
fi
# Flip
ffmpeg -i $temp_name -vf hflip -c:a copy "copy_$temp_name"
mv copy_${temp_name} "$filename.mp4"
rm $temp_name
}
#-------------------------------------------------
# YouTube Vid DL
alias yt='dl_youtube_vid "" $SHORTNAME_OFF'
alias yt-shortname='dl_youtube_vid "" $SHORTNAME_ON'
alias yt-1080='dl_youtube_vid "137+140" $SHORTNAME_OFF'
alias yt-1080-shortname='dl_youtube_vid "137+140" $SHORTNAME_ON'
alias yt-720='dl_youtube_vid "136+140" $SHORTNAME_OFF'
alias yt-720-shortname='dl_youtube_vid "136+140" $SHORTNAME_ON'
#-------------------------------------------------
alias yt-list='download_youtube_uploads_list 0 '
alias yt-list-desc='download_youtube_uploads_list 1 '
alias yt-playlist='dl_youtube_playlist ""'
alias yt-playlist-1080='dl_youtube_playlist "137+140"'
alias yt-playlist-720='dl_youtube_playlist "136+140"'
alias yt-playlist-tiny='dl_youtube_playlist "160+140"'
alias yt='download_youtube_vid "" $SHORTNAME_OFF $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-720='download_youtube_vid "136+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
alias yt-720-shortname='download_youtube_vid "136+140" $SHORTNAME_ON $TRANSCRIBE_OFF'
#TRANSCRIPTION ON
alias ytt='download_youtube_vid "" $SHORTNAME_OFF $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-1080-shortname-t='download_youtube_vid "137+140" $SHORTNAME_ON $TRANSCRIBE_ON'
alias yt-720-t='download_youtube_vid "136+140" $SHORTNAME_OFF $TRANSCRIBE_ON'
alias yt-720-shortname-t='download_youtube_vid "136+140" $SHORTNAME_ON $TRANSCRIBE_ON'
#---------------------------
alias yt-playlist='download_youtube_playlist ""'
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='yt-dlp.exe -f "140"'
alias yt-and-hflip='dl_youtube_vid_and_hflip "137+140"' # 1080p
#-------------------------------------------------
# Twitch Vid DL
alias tw='dl_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_OFF'
alias tw-compressed='dl_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_ON'
alias tw-shortname='dl_twitch_vid "" $SHORTNAME_ON $COMPRESSION_OFF'
alias tw-shortname-compressed='dl_twitch_vid "" $SHORTNAME_ON $COMPRESSION_ON'
alias tw-custom='dl_twitch_vid '
alias tw-chat='dl_twitch_chat'
#-------------------------------------------------
alias tw-chat='download_twitch_chat'
alias tw-1080='dl_twitch_vid "1080" $SHORTNAME_OFF $COMPRESSION_OFF'
alias tw-1080-compressed='dl_twitch_vid "1080" $SHORTNAME_OFF $COMPRESSION_ON'
alias tw-1080-shortname='dl_twitch_vid "1080" $SHORTNAME_ON $COMPRESSION_OFF'
alias tw-1080-shortname-compressed='dl_twitch_vid "1080" $SHORTNAME_ON $COMPRESSION_ON'
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-shortname='download_twitch_vid "" $SHORTNAME_ON $COMPRESSION_OFF $TRANSCRIBE_OFF'
alias tw-shortname-compressed='download_twitch_vid "" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-source='download_twitch_vid "Source" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-custom='download_twitch_vid '
#TRANSCRIPTION ON
alias twt='download_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_OFF $TRANSCRIBE_ON'
alias tw-compressed-t='download_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-shortname-t='download_twitch_vid "" $SHORTNAME_ON $COMPRESSION_OFF $TRANSCRIBE_ON'
alias tw-shortname-compressed-t='download_twitch_vid "" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-source-t='download_twitch_vid "Source" "Source" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p60='dl_twitch_vid "1080p60" $SHORTNAME_OFF $COMPRESSION_OFF'
alias tw-1080p50='dl_twitch_vid "1080p50" $SHORTNAME_OFF $COMPRESSION_OFF'
alias tw-1080p60-compressed='dl_twitch_vid "1080p60" $SHORTNAME_OFF $COMPRESSION_ON'
alias tw-1080p50-compressed='dl_twitch_vid "1080p50" $SHORTNAME_OFF $COMPRESSION_ON'
alias tw-1080p60-shortname='dl_twitch_vid "1080p60" $SHORTNAME_ON $COMPRESSION_OFF'
alias tw-1080p50-shortname='dl_twitch_vid "1080p50" $SHORTNAME_ON $COMPRESSION_OFF'
alias tw-1080p60-shortname-compressed='dl_twitch_vid "1080p60" $SHORTNAME_ON $COMPRESSION_ON'
alias tw-1080p50-shortname-compressed='dl_twitch_vid "1080p50" $SHORTNAME_ON $COMPRESSION_ON'
#1080p
alias tw-1080='download_twitch_vid "1080" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080-compressed='download_twitch_vid "1080" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080-shortname='download_twitch_vid "1080" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080-shortname-compressed='download_twitch_vid "1080" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
#TRANSCRIPTION ON
alias tw-1080-t='download_twitch_vid "1080" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080-compressed-t='download_twitch_vid "1080" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080-shortname-t='download_twitch_vid "1080" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080-shortname-compressed-t='download_twitch_vid "1080" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-720='dl_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_OFF'
alias tw-720-compressed='dl_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_ON'
alias tw-720-shortname='dl_twitch_vid "720p" $SHORTNAME_ON $COMPRESSION_OFF'
alias tw-720p60='dl_twitch_vid "720p60" $SHORTNAME_OFF $COMPRESSION_OFF'
alias tw-720p60-shortname='dl_twitch_vid "720p60" $SHORTNAME_ON $COMPRESSION_OFF'
#1080p60/50
alias tw-1080p60='download_twitch_vid "1080p60" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080p50='download_twitch_vid "1080p50" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080p60-compressed='download_twitch_vid "1080p60" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080p50-compressed='download_twitch_vid "1080p50" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080p60-shortname='download_twitch_vid "1080p60" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080p50-shortname='download_twitch_vid "1080p50" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080p60-shortname-compressed='download_twitch_vid "1080p60" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080p50-shortname-compressed='download_twitch_vid "1080p50" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
#TRANSCRIPTION ON
alias tw-1080p60-t='download_twitch_vid "1080p60" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p50-t='download_twitch_vid "1080p50" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p60-compressed-t='download_twitch_vid "1080p60" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p50-compressed-t='download_twitch_vid "1080p50" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p60-shortname-t='download_twitch_vid "1080p60" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p50-shortname-t='download_twitch_vid "1080p50" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p60-shortname-compressed-t='download_twitch_vid "1080p60" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p50-shortname-compressed-t='download_twitch_vid "1080p50" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-4k='dl_twitch_vid "2160p" $SHORTNAME_OFF $COMPRESSION_OFF'
alias tw-4k-compressed='dl_twitch_vid "2160p" $SHORTNAME_OFF $COMPRESSION_ON'
alias tw-4k-shortname='dl_twitch_vid "2160p" $SHORTNAME_ON $COMPRESSION_OFF'
alias tw-4k-shortname-compressed='dl_twitch_vid "2160p" $SHORTNAME_ON $COMPRESSION_ON'
#720p
alias tw-720='download_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-720-compressed='download_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-720-shortname='download_twitch_vid "720p" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-720p60='download_twitch_vid "720p60" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-720p60-shortname='download_twitch_vid "720p60" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
#TRANSCRIPTION ON
alias tw-720-t='download_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-720-compressed-t='download_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-720-shortname-t='download_twitch_vid "720p" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-720p60-t='download_twitch_vid "720p60" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-720p60-shortname-t='download_twitch_vid "720p60" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-source='dl_twitch_vid "Source" $SHORTNAME_OFF $COMPRESSION_OFF'
#4k
alias tw-4k='download_twitch_vid "2160p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-4k-compressed='download_twitch_vid "2160p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-4k-shortname='download_twitch_vid "2160p" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-4k-shortname-compressed='download_twitch_vid "2160p" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
#TRANSCRIPTION ON
alias tw-4k-t='download_twitch_vid "2160p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-4k-compressed-t='download_twitch_vid "2160p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-4k-shortname-t='download_twitch_vid "2160p" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-4k-shortname-compressed-t='download_twitch_vi "2160p" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
#-------------------------------------------------
# Vimeo Vid DL
alias vimeo='dl_vimeo_vid "Original" $SHORTNAME_OFF $COMPRESSION_OFF'
alias vimeo-compressed='dl_vimeo_vid "Original" $SHORTNAME_OFF $COMPRESSION_ON'
#-------------------------------------------------
alias vimeo='download_vimeo_vid $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias vimeo-t='download_vimeo_vid $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
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'
#-------------------------------------------------
# Instagram Vid DL
alias ig-download-and-hflip='dl_instagram_vid_and_hflip '
#-------------------------------------------------
alias ig='download_instagram_vid $TRANSCRIBE_OFF'
alias igt='download_instagram_vid $TRANSCRIBE_ON'
#-------------------------------------------------
# Twitter Vid DL
alias twitter='dl_twitter_vid "" '
#-------------------------------------------------
alias twitter='download_twitter_vid "" '
#-------------------------------------------------
# Misc
alias download-mp4='dl_mp4'
alias download-from-m3u8='dl_from_m3u8'
#-------------------------------------------------
alias download-mp4='download_mp4'
alias download-from-m3u8='download_from_m3u8'
####################################################################################################
# Video Compression
@@ -875,11 +1058,11 @@ function _compress_video_hard() {
local name="$1"
local out="$2"
if [[ name == "" || out == "" ]]; then
error "Format: cmd <source> <dest>\n"
error "Usage: cmd <source> <dest>"
return
fi
# 1 arg = use GPU
compress-video-with-crf 1 $crf "$name" "$out"
# 0=cpu, 1=gpu
compress-video-with-crf $crf "$name" "$out" 0
}
alias compress-video-hard='_compress_video_hard'
@@ -953,7 +1136,7 @@ alias gaup='git add --update -p'
alias gb='git branch -v'
alias gbb='git bisect bad'
alias gbd='git branch -D'
alias gbdr='git branch -Dr'
alias gbdr='git branch -Dr' # Delete a remote tracking branch; useful when the remote no longer exists and branch pruning isn't removing the lingering tracking branches.
alias gbg='git bisect good'
alias gbl='git branch --all'
alias gblm='git blame -wMC'
@@ -1002,6 +1185,7 @@ alias gmffs='git merge --ff-only --squash'
alias gmtheirs='git merge -Xtheirs'
alias gp='git push'
alias gpa='git push --all && echo "pushing tags..." && git push --tags'
alias gpaf='git push --all -f && echo "pushing tags..." && git push --tags -f'
alias gpf='git push -f'
alias gpff='git pull --ff-only'
alias gplu='git pull --set-upstream origin HEAD'
@@ -1053,10 +1237,11 @@ alias gsp3='git stash pop stash@{3}'
alias gsp4='git stash pop stash@{4}'
alias gsp5='git stash pop stash@{6}'
alias gsp6='git stash pop stash@{7}'
alias gt='git tag -s' # Signed
alias gt='git tag' # Unsigned
alias gta='git tag -a'
alias gtd='git tag -d'
alias gtl='git tag -l'
alias gts='git tag -s' # Signed
alias gx='git reset --hard'
alias gxx='git reset --hard HEAD~1'
alias gxom='git reset --hard origin/master'

View File

View File

@@ -13,16 +13,20 @@ esac
export PLATFORM=$platform
export PLATFORM_OS=$platform_os
test -f "$HOME/.env.platform" && . "$HOME/.env.platform"
os_lower="${platform_os,,}"
test -f "$HOME/dotfiles/${os_lower}/env.platform" && . "$HOME/dotfiles/${os_lower}/env.platform"
test -f "$HOME/.env.common-pre" && . "$HOME/.env.common-pre"
test -f "$HOME/.env.private" && . "$HOME/.env.private"
test -f "$HOME/.env.common-post" && . "$HOME/.env.common-post"
test -f "$HOME/.aliases" && . "$HOME/.aliases"
test -f "$HOME/.aliases.common" && . "$HOME/.aliases.common"
test -f "$HOME/.aliases.private" && . "$HOME/.aliases.private"
if [[ $_MC_SET_ENV_PATH -ne 1 ]]; then
test -d "$HOME/bin" && export PATH=$HOME/bin/:$PATH
#TODO: remove this
test -d "$HOME/.dotfiles/bin" && export PATH=$HOME/.dotfiles/bin/:$PATH
fi

5
.gitattributes vendored Normal file
View File

@@ -0,0 +1,5 @@
# All text files will have LF line endings, except batch files.
* text=auto
# Preserve crlf in batch files when checking in.
*.bat text eol=crlf

View File

@@ -1,5 +1,4 @@
[include]
path = ~/.gitconfig.platform
path = ~/.gitconfig.private
[init]
defaultBranch = master
@@ -7,11 +6,25 @@
summary = true
tool = vimdiff
[core]
excludesfile = ~/.gitignore
excludesfile = ~/.gitignore.global
hookspath = ~/.git_hooks
preloadindex = true
fscache = true
editor = vim
# I used to have this set to true, which would result in checked out files
# being converted to CRLF line endings and commits converting to LF. I'm
# tired of this conversion shit though so I'm turning it off and will be
# enforcing LF line endings via a combination of editorconfig and
# gitattribute files on a per-project basis. This should make sure that
# anyone contributing to my projects will be committing LF line endings.
# The only exception is that the gitattributes files will commit batch
# files with CRLF to avoid Windows glitches.
#
# I used these posts for reference:
# https://markentier.tech/posts/2021/10/autocrlf-true-considered-harmful/
# https://troyready.com/blog/git-windows-dont-convert-line-endings.html
#
autocrlf = false
[push]
default = upstream
[pull]

10
.gitignore vendored
View File

@@ -1,9 +1 @@
vim/.netrwhist
vim/bundle/*
vim/plugged/*
vim/undo
vim/undo/*
vim/autoload/plug.vim.old
config/openbox/lxde-rc.xml
*.pyc
!bin
*

3
.gitmodules vendored
View File

@@ -1,3 +0,0 @@
[submodule "vim/bundle/Vundle.vim"]
path = vim/bundle/Vundle.vim
url = https://github.com/VundleVim/Vundle.vim.git

View File

@@ -0,0 +1,162 @@
" A simple dark vim colorscheme.
" Created by Michael Campagnaro (https://git.michael.is)
if has('termguicolors')
" Supports 24-bit color range
set termguicolors
let g:campo_theme_use_rainbow_parens = 0
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
syntax reset
source $HOME/.vim/colors/utils
let g:colors_name = "campo-dark-blue"
" 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 = "f1f1e8" " A majority of the syntax will use this.
let s:bg = "072730"
let s:select = "546e8f"
let s:window = "37474f"
let s:comment = "5dea82"
let s:tab = "03404a"
let s:error = "e40e0e"
let s:proc = "0eefcb"
let s:warn = "dcd53e"
let s:spell = "aaf53e"
" Vim
call X("Normal", s:text, s:bg, "")
call X("LineNr", s:grey, "", "")
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, "027990", "bold") " Selected autocompletion item
call X("SignColumn", "", s:bg, "none")
call X("CursorLine", "", "022f36", "none") " Horizontal line at the cursor.
call X("CursorColumn", "", "022c33", "none") " Vertical line at the cursor.
end
if version >= 703
call X("ColorColumn", "", "022c33", "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:grey, "", "none")
call X("Statement", s:text, "", "") " 'return', 'goto', 'case', 'break', etc
call X("Conditional", s:text, "", "")
call X("Repeat", s:text, "", "") " 'for' and 'while'
call X("Structure", "ae90ea", "", "")
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", s:text, "", "")
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", "a5bce4", "", "none")
call X("Include", s:text, "", "") " #include in C/C++
call X("Number", s:text, "", "")
" Notes
call X("Todo", "b8fbb0", s:bg, "underline")
call X("Bugs", "d8fbb0", s:bg, "standout")
call X("Notes", "ffffff", s:bg, "standout")
call X("Notices", s:warn, s:bg, "bold")
" 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("jaiTagNote", s:orange, "", "bold")
" 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, "", "")
" 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
call X("htmlTag", s:text, "", "")
call X("htmlTagName", s:text, "", "")
call X("htmlArg", s:text, "", "")
call X("htmlScriptTag", s:blue, "", "")
" 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

@@ -447,9 +447,6 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256
call <SID>X("bladeKeyword", s:blue, "", "")
" Diff Highlighting
call <SID>X("diffAdded", "", s:green, "none")
call <SID>X("diffRemoved", "", s:red, "none")
call <SID>X("diffChanged", "", s:yellow, "none")
call <SID>X("DiffAdd", s:window, s:green, "none")
call <SID>X("DiffDelete", s:window, s:red, "none")
call <SID>X("DiffChange", s:window, s:yellow, "none")

View File

@@ -414,9 +414,6 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256
call <SID>X("bladeKeyword", s:blue, "", "")
" Diff Highlighting
call <SID>X("diffAdded", "", s:green, "none")
call <SID>X("diffRemoved", "", s:red, "none")
call <SID>X("diffChanged", "", s:yellow, "none")
call <SID>X("DiffAdd", s:window, s:green, "none")
call <SID>X("DiffDelete", s:window, s:red, "none")
call <SID>X("DiffChange", s:window, s:yellow, "none")

View File

@@ -432,9 +432,6 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256
call <SID>X("bladeKeyword", s:blue, "", "")
" Diff Highlighting
call <SID>X("diffAdded", "", s:green, "none")
call <SID>X("diffRemoved", "", s:red, "none")
call <SID>X("diffChanged", "", s:yellow, "none")
call <SID>X("DiffAdd", s:window, s:green, "none")
call <SID>X("DiffDelete", s:window, s:red, "none")
call <SID>X("DiffChange", s:window, s:yellow, "none")

View File

@@ -45,9 +45,9 @@ if has("gui_running") || &t_Co == 256
hi PmenuSel cterm=bold,reverse ctermfg=250 ctermbg=black gui=reverse guifg=#bcbcbc guibg=#0a0a0a
hi SpecialKey cterm=NONE ctermfg=16 ctermbg=255 gui=NONE guifg=#eeeeee guibg=#0a0a0a
hi MatchParen cterm=bold ctermfg=white ctermbg=black gui=NONE guifg=#bcbcbc guibg=#454545
hi CursorLine cterm=NONE ctermfg=NONE ctermbg=233 gui=NONE guifg=NONE guibg=#222222
hi CursorColumn cterm=NONE ctermfg=NONE ctermbg=233 gui=NONE guifg=NONE guibg=#222222
hi ColorColumn cterm=NONE ctermfg=NONE ctermbg=255 gui=NONE guifg=NONE guibg=#222222 " The column line set by colorcolumn
hi CursorLine cterm=NONE ctermfg=NONE ctermbg=233 gui=NONE guifg=NONE guibg=#111111
hi CursorColumn cterm=NONE ctermfg=NONE ctermbg=233 gui=NONE guifg=NONE guibg=#111111
hi ColorColumn cterm=NONE ctermfg=NONE ctermbg=255 gui=NONE guifg=NONE guibg=#171717 " The column line set by colorcolumn
hi StatusLine cterm=bold,reverse ctermfg=245 ctermbg=black gui=bold,reverse guifg=#8a8a8a guibg=#0a0a0a
hi StatusLineNC cterm=reverse ctermfg=236 ctermbg=black gui=reverse guifg=#303030 guibg=#0a0a0a
hi Visual cterm=reverse ctermfg=250 ctermbg=black gui=reverse guifg=#bcbcbc guibg=#0a0a0a
@@ -81,8 +81,6 @@ highlight! link Todo Keyword
highlight! link Label Keyword
highlight! link Define Keyword
highlight! link DiffAdd Keyword
highlight! link diffAdded Keyword
highlight! link diffCommon Keyword
highlight! link Directory Keyword
highlight! link PreCondit Keyword
highlight! link PreProc Keyword
@@ -101,11 +99,9 @@ highlight! link iCursor SpecialKey
highlight! link SpellLocal SpellCap
highlight! link NonText NonText
highlight! link DiffDelete Comment
highlight! link diffRemoved Comment
highlight! link PmenuSbar Visual
highlight! link VisualNOS Visual
highlight! link VertSplit VertSplit
highlight! link Cursor StatusLine
highlight! link Underlined SpellRare
highlight! link rstEmphasis SpellRare
highlight! link diffChanged DiffChange

View File

@@ -79,8 +79,6 @@ highlight! link Todo Keyword
highlight! link Label Keyword
highlight! link Define Keyword
highlight! link DiffAdd Keyword
highlight! link diffAdded Keyword
highlight! link diffCommon Keyword
highlight! link Directory Keyword
highlight! link PreCondit Keyword
highlight! link PreProc Keyword
@@ -100,10 +98,8 @@ highlight! link SpellLocal SpellCap
highlight! link LineNr Comment
highlight! link NonText NonText
highlight! link DiffDelete Comment
highlight! link diffRemoved Comment
highlight! link VisualNOS Visual
highlight! link VertSplit VertSplit
highlight! link Cursor StatusLine
highlight! link Underlined SpellRare
highlight! link rstEmphasis SpellRare
highlight! link diffChanged DiffChange

View File

@@ -1,5 +1,5 @@
" A simple light colorscheme.
" Maintainer: Michael Campagnaro <mikecampo@gmail.com>
" Maintainer: Michael Campagnaro
" Version: 1.0
"
" Adapted from https://github.com/tek256/simple-dark
@@ -81,8 +81,6 @@ highlight! link Todo Keyword
highlight! link Label Keyword
highlight! link Define Keyword
highlight! link DiffAdd Keyword
highlight! link diffAdded Keyword
highlight! link diffCommon Keyword
highlight! link Directory Keyword
highlight! link PreCondit Keyword
highlight! link PreProc Keyword
@@ -102,10 +100,8 @@ highlight! link SpellLocal SpellCap
highlight! link LineNr Comment
highlight! link NonText NonText
highlight! link DiffDelete Comment
highlight! link diffRemoved Comment
highlight! link VisualNOS Visual
highlight! link VertSplit VertSplit
highlight! link Cursor StatusLine
highlight! link Underlined SpellRare
highlight! link rstEmphasis SpellRare
highlight! link diffChanged DiffChange

View File

@@ -377,9 +377,6 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256
call <SID>X("htmlScriptTag", s:blue, "", "")
" Diff Highlighting
call <SID>X("diffAdded", "", s:green, "none")
call <SID>X("diffRemoved", "", s:red, "none")
call <SID>X("diffChanged", "", s:yellow, "none")
call <SID>X("DiffAdd", s:window, s:green, "none")
call <SID>X("DiffDelete", s:window, s:red, "none")
call <SID>X("DiffChange", s:window, s:yellow, "none")

209
.vim/colors/utils Normal file
View File

@@ -0,0 +1,209 @@
" Hex color conversion functions are from https://github.com/vim-scripts/desert256.vim/blob/master/colors/desert256.vim
" Returns an approximate grey index for the given grey level
function! GreyNumber(x)
if &t_Co == 88
if a:x < 23
return 0
elseif a:x < 69
return 1
elseif a:x < 103
return 2
elseif a:x < 127
return 3
elseif a:x < 150
return 4
elseif a:x < 173
return 5
elseif a:x < 196
return 6
elseif a:x < 219
return 7
elseif a:x < 243
return 8
else
return 9
endif
else
if a:x < 14
return 0
else
let l:n = (a:x - 8) / 10
let l:m = (a:x - 8) % 10
if l:m < 5
return l:n
else
return l:n + 1
endif
endif
endif
endfun
" Returns the actual grey level represented by the grey index
function! GreyLevel(n)
if &t_Co == 88
if a:n == 0
return 0
elseif a:n == 1
return 46
elseif a:n == 2
return 92
elseif a:n == 3
return 115
elseif a:n == 4
return 139
elseif a:n == 5
return 162
elseif a:n == 6
return 185
elseif a:n == 7
return 208
elseif a:n == 8
return 231
else
return 255
endif
else
if a:n == 0
return 0
else
return 8 + (a:n * 10)
endif
endif
endfun
" Returns the palette index for the given grey index
function! GreyColor(n)
if &t_Co == 88
if a:n == 0
return 16
elseif a:n == 9
return 79
else
return 79 + a:n
endif
else
if a:n == 0
return 16
elseif a:n == 25
return 231
else
return 231 + a:n
endif
endif
endfun
" Returns an approximate colour index for the given colour level
function! RGBNumber(x)
if &t_Co == 88
if a:x < 69
return 0
elseif a:x < 172
return 1
elseif a:x < 230
return 2
else
return 3
endif
else
if a:x < 75
return 0
else
let l:n = (a:x - 55) / 40
let l:m = (a:x - 55) % 40
if l:m < 20
return l:n
else
return l:n + 1
endif
endif
endif
endfun
" Returns the actual colour level for the given colour index
function! RGBLevel(n)
if &t_Co == 88
if a:n == 0
return 0
elseif a:n == 1
return 139
elseif a:n == 2
return 205
else
return 255
endif
else
if a:n == 0
return 0
else
return 55 + (a:n * 40)
endif
endif
endfun
" Returns the palette index for the given R/G/B colour indices
function! RGBColor(x, y, z)
if &t_Co == 88
return 16 + (a:x * 16) + (a:y * 4) + a:z
else
return 16 + (a:x * 36) + (a:y * 6) + a:z
endif
endfun
" Returns the palette index to approximate the given R/G/B colour levels
function! Color(r, g, b)
" Get the closest grey
let l:gx = GreyNumber(a:r)
let l:gy = GreyNumber(a:g)
let l:gz = GreyNumber(a:b)
" Get the closest colour
let l:x = RGBNumber(a:r)
let l:y = RGBNumber(a:g)
let l:z = RGBNumber(a:b)
if l:gx == l:gy && l:gy == l:gz
" There are two possibilities
let l:dgr = GreyLevel(l:gx) - a:r
let l:dgg = GreyLevel(l:gy) - a:g
let l:dgb = GreyLevel(l:gz) - a:b
let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
let l:dr = RGBLevel(l:gx) - a:r
let l:dg = RGBLevel(l:gy) - a:g
let l:db = RGBLevel(l:gz) - a:b
let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
if l:dgrey < l:drgb
" Use the grey
return GreyColor(l:gx)
else
" Use the colour
return RGBColor(l:x, l:y, l:z)
endif
else
" Only one possibility
return RGBColor(l:x, l:y, l:z)
endif
endfun
" Returns the palette index to approximate the 'rrggbb' hex string
function! RGB(rgb)
let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
return Color(l:r, l:g, l:b)
endfun
" Sets the highlighting for the given group
function! X(group, fg, bg, attr)
if a:fg != ""
exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . RGB(a:fg)
endif
if a:bg != ""
exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . RGB(a:bg)
endif
if a:attr != ""
exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
endif
endfun

View File

View File

@@ -266,3 +266,12 @@ throughs
throughs
incentivise
malware
foofy
memcpy
strlen
u8
s64
Sculpey
grey
googly
favour

BIN
.vim/spell/en.utf-8.add.spl Normal file

Binary file not shown.

1653
.vimrc Normal file

File diff suppressed because it is too large Load Diff

View File

View File

View File

@@ -1,11 +0,0 @@
# dotfiles
Various dotfiles and misc configs. Some of it is customized around my system setup
(like aliases pointing to paths) but you should be able to easily remove that stuff.
## Installing
There is an `install` script that facilitates the setup, however it's been a while since I did a
full system setup and this script may not be fully complete. An alternative method is to manually
symlink files in the root directory. OS specific configs are in their respective folders.

View File

@@ -1,44 +0,0 @@
#!/usr/bin/env bash
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
use_gpu=$1
filename=$(basename -- "$2")
output_name="$3"
start_time="$4"
end_time="$5"
if [[ $use_gpu == "" || $2 == "" || $output_name == "" || $start_time == "" || $end_time == "" ]]; then
printf "${BOLD}${RED}Usage: $0 <use-gpu (1|0)> <filename> <output name> <start time HH:MM:SS> <end time HH:MM:SS>${NORMAL}\n"
exit 1
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=25
if [[ $use_gpu -eq 1 ]]; then
use_crf=27
fi
compress-video-with-crf $use_gpu $use_crf "$filename" "$output_name" "$start_time" "$end_time"

View File

@@ -1,16 +0,0 @@
#!/usr/bin/env bash
# Copies vim data from the home directory to the dotfiles repo.
set -e
src="$HOME/.vim"
dest="$HOME/.dotfiles/vim/"
if [ -d $src ]; then
[ -d "$src/spell" ] && echo "Syncing user dictionary" && cp -r "$src/spell" $dest
[ -d "$src/colors" ] && echo "Syncing user colors" && cp -r "$src/colors" $dest
[ -d "$src/after" ] && echo "Syncing after directory" && cp -r "$src/after" $dest
[ -d "$src/ftdetect" ] && echo "Syncing ftdetect" && cp -r "$src/ftdetect" $dest
[ -d "$src/autoload" ] && echo "Syncing autoload" && cp -r "$src/autoload" $dest
fi

View File

@@ -1,16 +0,0 @@
#!/usr/bin/env bash
# Copies vim data from the dotfiles repo to the home directory.
set -e
src="$HOME/.dotfiles/vim"
dest="$HOME/.vim/"
if [ -d $src ]; then
[ -d "$src/spell" ] && echo "Syncing user dictionary" && cp -r "$src/spell" $dest
[ -d "$src/colors" ] && echo "Syncing user colors" && cp -r "$src/colors" $dest
[ -d "$src/after" ] && echo "Syncing after directory" && cp -r "$src/after" $dest
[ -d "$src/ftdetect" ] && echo "Syncing ftdetect" && cp -r "$src/ftdetect" $dest
[ -d "$src/autoload" ] && echo "Syncing autoload" && cp -r "$src/autoload" $dest
fi

21
dotfiles/.editorconfig Normal file
View File

@@ -0,0 +1,21 @@
# EditorConfig helps developers define and maintain consistent
# coding styles # between different editors and IDEs
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.bat]
end_of_line = crlf
[*.tsv]
indent_style = tab

32
dotfiles/README.md Normal file
View File

@@ -0,0 +1,32 @@
# dotfiles
Various dotfiles and misc configs. Some of it is customized around my system
setup (like aliases pointing to paths) but you should be able to easily remove
that stuff.
This unpacks files one directory back, which is assumed to be your home
directory. The gitignore ignores all files by default. If you want to add a new
file this you need to add the `-f` flag to the git add command. This setup was
inspired by Gary Bernhardt and https://gist.github.com/meleu/053275b6842646b95491bf1af4a6ca0e
## Installing
```bash
# Go to your home directory.
cd ~
# Clone the repo with the "--no-checkout" option (so we can checkout the files in our home directory)
git clone --no-checkout <repo_url>/dotfiles.git
# Go to the created directory and change the worktree to the home direcory.
cd dotfiles
git config core.worktree '../../'
# Checkout the files. This will overwrite existing dotfiles with the same name.
git reset --hard origin/master
```
If you want to install optional OS specific stuff, like various packages, run the `install` script in this folder.
OS specific configs are in their respective folders.

View File

@@ -23,20 +23,25 @@ else
NORMAL=""
fi
use_gpu=$1
filename=$(basename -- "$2")
output_name="$3"
use_gpu=0
if [[ $use_gpu == "" || $2 == "" || $output_name == "" ]]; then
printf "${BOLD}${RED}Usage: $0 <use-gpu (1|0)> <filename> <output name>${NORMAL}\n"
if [[ $# < 2 || $# > 3 ]]; then
printf "${BOLD}${RED}Usage: $0 <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> ${NORMAL}\n"
exit 1
fi
filename=$(basename -- "$1")
output_name="$2"
if [[ $# > 2 ]]; then
use_gpu=$3
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=21
if [[ $use_gpu -eq 1 ]]; then
use_crf=25
fi
compress-video-with-crf $use_gpu $use_crf "$filename" "$output_name"
compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu

View File

@@ -23,22 +23,36 @@ else
NORMAL=""
fi
use_gpu=$1
use_crf=$2
output_name="$4"
start_time="$5"
end_time="$6"
use_gpu=0
if [[ $use_gpu == "" || $use_crf == "" || $3 == "" || $output_name == "" || ($start_time != "" && $end_time == "") ]]; then
printf "${BOLD}${RED}Usage: $0 <use-gpu (1|0)> <crf value> <filename> <output name> <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"
if [[ "$#" < 3 || "$#" > 6 ]]; then
printf "${BOLD}${RED}Usage: $0 <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"
exit 1
fi
use_crf=$1
filename=$(basename -- "$3")
filename=$(basename -- "$2")
extension="${filename##*.}"
filename="${filename%.*}"
output_name="$3"
if [[ "$#" > 3 ]]; then
use_gpu=$4
if [[ "$#" > 4 ]]; then
start_time="$5"
if [[ "$#" > 5 ]]; then
end_time="$6"
fi
fi
fi
if [[ $use_gpu -ne 0 && $use_gpu -ne 1 ]]; then
printf "${BOLD}${RED}Invalid use_gpu value. Got $use_gpu, but expected either 0 or 1${NORMAL}\n"
exit 1
fi
function encode() {
crf=$1
output="${output_name}.$extension"
@@ -52,7 +66,12 @@ function encode() {
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
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"
# GTX 1070
#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"
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"
fi

View File

@@ -29,7 +29,7 @@ else
fi
if [[ $1 == "" || $2 == "" ]]; then
printf "${BOLD}${RED}Format: $0 <filename> <bitrate, e.g. \"4000k\"> <optional output name>${NORMAL}\n"
printf "${BOLD}${RED}Usage: $0 <filename> <bitrate, e.g. \"4000k\"> <optional output name>${NORMAL}\n"
exit 1
fi

View File

@@ -27,7 +27,7 @@ else
fi
if [[ $1 == "" || $2 == "" ]]; then
printf "${BOLD}${RED}Format: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
printf "${BOLD}${RED}Usage: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
exit 1
fi

View File

@@ -27,7 +27,7 @@ else
fi
if [[ $1 == "" || $2 == "" ]]; then
printf "${BOLD}${RED}Format: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
printf "${BOLD}${RED}Usage: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
exit 1
fi

View File

@@ -0,0 +1,50 @@
#!/usr/bin/env bash
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
input="$1"
output_name="$2"
if [[ $input == "" || $output_name == "" ]]; then
printf "${BOLD}${RED}Usage: $0 <input video> <wav output name>${NORMAL}\n"
exit 1
fi
if [[ ! -f "$input" ]]; then
printf "${RED}${BOLD}Error: failed to extract audio. Video file \"$input\" doesn't exist.\n${NORMAL}"
exit 1
fi
# Add extension if not provided.
output_basename=$(basename -- "$output_name")
output_extension="${output_basename##*.}"
if [[ $output_extension != "wav" ]]; then
output_name="${output_name}.wav"
fi
printf "\n${YELLOW}${BOLD}Extracting 16-bit WAV from $input | output: $output_name${NORMAL}\n"
ffmpeg -i "$input" -ar 16000 -ac 1 -c:a pcm_s16le "$output_name"
printf "${GREEN}${BOLD}Done extracting 16-bit WAV from $input | output: $output_name${NORMAL}\n"

View File

@@ -41,7 +41,7 @@ if [[ $bitrate == "" ]]; then
bitrate="64"
fi
printf "\n${YELLOW}${BOLD}Extracting audio from '$filename.$extension' | bitrate: ${bitrate}k | output: $output_name${NORMAL}\n"
printf "\n${YELLOW}${BOLD}Extracting audio from $filename.$extension | bitrate: ${bitrate}k | output: $output_name${NORMAL}\n"
if [[ $transcode == "1" ]]; then
# Transcode audio
@@ -51,5 +51,5 @@ else
ffmpeg -i "$filename.$extension" -vn -acodec copy "$output_name"
fi
printf "\n${GREEN}${BOLD}Done extracting audio from '$filename.$extension' | output name '$output_name'${NORMAL}\n\n"
printf "\n${GREEN}${BOLD}Done extracting audio from $filename.$extension | output name '$output_name'${NORMAL}\n\n"

View File

@@ -1,4 +1,3 @@
@echo off
cd %DEV_TOOLS%\SysinternalsSuite
start %DEV_TOOLS%\ResourceHacker.exe "%~1"

View File

@@ -0,0 +1,3 @@
@echo off
start %DEV_TOOLS%\x64dbg\release\x32\x32dbg.exe "%~1"

View File

@@ -0,0 +1,3 @@
@echo off
start %DEV_TOOLS%\x64dbg\release\x64\x64dbg.exe "%~1"

View File

@@ -27,7 +27,7 @@ else
fi
if [[ $1 == "" ]]; then
printf "\n${BOLD}Usage: $0 <filename> <optional output name>${NORMAL}\n"
printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
exit 1
fi

View File

@@ -29,7 +29,7 @@ else
fi
if [[ $1 == "" ]]; then
printf "\n${BOLD}Usage: $0 <filename> <optional output name>${NORMAL}\n"
printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
exit 1
fi

View File

@@ -0,0 +1,49 @@
#!/usr/bin/env bash
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: $0 <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}_no_audio.$extension"
else
output="${output_name}.$extension"
fi
printf "\n${YELLOW}${BOLD}Removing audio from '$filename.$extension' | output: '$output'${NORMAL}\n"
# -an removes the audio.
ffmpeg -i "$filename.$extension" -c:v copy -an "$output"
printf "\n${GREEN}${BOLD}Done removing audio from '$filename.$extension' | output: '$output'${NORMAL}\n\n"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
source "$HOME/.dotfiles/script_helpers/all.sh"
source "$HOME/dotfiles/script_helpers/all.sh"
cwd=$PWD
source_path=""

View File

@@ -0,0 +1,94 @@
#!/usr/bin/env bash
# The base model is pretty good overall. It has good punctuation inserting and catches most words.
# Tiny is fast and often has correct grammar, but it misses a lot of words, especially when the
# source isn't loud or is muffled.
#
# Small and medium models can do better word detection at times, but suffer from a lack of punctuation.
# Medium is particularly bad and often excludes periods and commas.
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
# Will return a symlink path in its expanded form. If the path's root is the
# home directory symbol "~" then it'll be replaced by the full home path.
expand_path() {
local ret="$1"
IFS="/" read -ra parts <<< "$ret"
if [[ "${parts[0]}" == "~" ]]; then
ret="$HOME"
for ((i=1; i < ${#parts[@]}; i++))
do
ret="$ret/${parts[$i]}"
done
fi
ret=$(readlink -m "$ret")
echo $ret
}
input_wav="$1"
output_name_without_ext="$2"
model="$3"
threads=$4
# 4 seems to be the sweet spot for most models, except medium might be faster with 8.
default_thread_count=4
if [[ $input_wav == "" || $output_name_without_ext == "" || $model == "" ]]; then
printf "${BOLD}${RED}Usage: $0 <input.wav> <output name without extension> <model name> <optional: thread count>${NORMAL}\n"
exit 1
fi
if [[ ! -f "$input_wav" ]]; then
printf "${RED}${BOLD}Input file \"$input_wav\" doesn't exist!\n${NORMAL}"
exit 1
fi
if [[ $threads == "" ]]; then
threads=$default_thread_count
fi
output_name="$output_name_without_ext.${model}"
# 1 core 31 threads has very fast pcm_to_mel conversion and then just one core doing most of the work. You get more accurate results this way.
# 2 core 16 is about half the time but it can have errors where the two pieces come together. This only gets more likely as the core count is increased.
# 8 threads, 4 cores is good too for tiny,small and 2 threads, 4 cores for medium.
threads=31 #keep a thread for me
cores=1
printf "\n${YELLOW}${BOLD}Transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name ${NORMAL}\n"
whisper_fullname="$(expand_path $(which whisper.exe))"
whisper_path="$(dirname $whisper_fullname)"
models_path="$whisper_path/models"
whisper.exe --processors ${cores} --threads ${threads} -m "$models_path/ggml-${model}.en.bin" -otxt -osrt -f "$input_wav" -of "$output_name" --print-colors --print-progress
error=$?
if [[ error -eq 0 ]]; then
printf "${GREEN}${BOLD}Done transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name${NORMAL}\n"
else
printf "${GREEN}${BOLD}Error while transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name${NORMAL}\n"
fi

View File

@@ -0,0 +1,65 @@
#!/usr/bin/env bash
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
input_video="$1"
output_name_without_ext="$2"
shift 2
models=("$@")
if [[ $input_video == "" || $output_name_without_ext == "" || ${#models[@]} -eq 0 ]]; then
printf "${BOLD}${RED}Usage: $0 <input.mp4> <output name without extension> <list of model names to use>${NORMAL}\n"
exit 1
fi
model_csv=$(IFS=_ ; echo "${models[*]}")
wav_name="${output_name_without_ext}_${model_csv}_${RANDOM}"
# Add extension if not provided.
input_basename=$(basename -- "$wav_name")
input_extension="${input_basename##*.}"
if [[ input_extension != "wav" ]]; then
wav_name="${wav_name}.wav"
fi
extract-16bit-wav-from-video "$input_video" "$wav_name"
if [[ $? == 1 ]]; then exit 1; fi
for model in "$@"; do
# Tweak thread count based on model size.
thread_count=4
if [[ $model == "medium" ]]; then
thread_count=8
fi
transcribe-audio "$wav_name" "$output_name_without_ext" "${model}" $thread_count
if [[ $? == 1 ]]; then
printf "${RED}${BOLD}Saving the audio file \"$wav_name\" in case you want to reuse it for debugging.\n${NORMAL}"
exit 1
fi
done
rm "$wav_name"

View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
transcribe-video "$1" "$2" "base"

View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
transcribe-video "$1" "$2" "medium"

View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
transcribe-video "$1" "$2" "small"

View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
transcribe-video "$1" "$2" "tiny"

View File

@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# Reencodes the video with a more accurate length.
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"
if [[ $filename == "" || $output_name == "" || $start_time == "" || $end_time == "" ]]; then
printf "${BOLD}${RED}Usage: $0 <filename> <output name> <start time HH:MM:SS> <end time HH:MM:SS>${NORMAL}\n"
exit 1
fi
extension="${filename##*.}"
filename="${filename%.*}"
output="${output_name}.$extension"
timing_args="-ss $start_time -to $end_time"
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time${NORMAL}\n"
ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename.$extension" -c:v libx264 -c:a copy "$output"
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"

View File

@@ -40,7 +40,7 @@ timing_args="-ss $start_time -to $end_time"
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time${NORMAL}\n"
ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c:a copy -c:v copy "$output"
ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c copy "$output"
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"

View File

@@ -2,8 +2,8 @@
# If you're getting signature errors, check out https://www.msys2.org/news/#2020-06-29-new-packagers and/or other news posts.
source "$HOME/.dotfiles/script_helpers/printing.sh"
source "$HOME/.dotfiles/script_helpers/platform.sh"
source "$HOME/dotfiles/script_helpers/printing.sh"
source "$HOME/dotfiles/script_helpers/platform.sh"
set -e

89
install → dotfiles/install Executable file → Normal file
View File

@@ -4,7 +4,7 @@ if [[ $(uname) == 'Darwin' ]]; then
if ! command -v brew &>/dev/null
then
# We need to update bash, so we'll start with setting up homebrew.
./osx/pre_install
./macos/pre_install
exit
fi
fi
@@ -52,31 +52,6 @@ setup_zsh() {
if [[ $is_linux -eq 1 ]]; then
sudo apt install zsh
fi
make_link .dotfiles/zsh/core .zsh
FILES=()
FILES+=('zshrc')
FILES+=('zlogin')
for file in "${FILES[@]}"
do
make_link .dotfiles/zsh/$file .$file
done
}
setup_bash() {
printf "${MAGENTA}==> ${NORMAL}Setting up bash...\n"
FILES=()
FILES+=('bashrc')
FILES+=('bash_profile')
FILES+=('inputrc')
for file in "${FILES[@]}"
do
make_link .dotfiles/bash/$file .$file
done
}
####################################################################################################
@@ -85,40 +60,6 @@ setup_bash() {
pushd "$HOME" &>/dev/null
make_link $dotfiles_dir .dotfiles 1 # expand source path in case we're reinstalling and the cwd is a symlink.
if [[ $is_windows -eq 1 ]]; then
do_vim_copy=1
if [[ -d "$PWD/.vim" ]]; then
printf "\n${BOLD}Vim folder already found at destination. Overwrite? [1,0]\n> ${NORMAL}"
read -e copy_vim
if [[ $copy_vim != "0" && $copy_vim != "1" ]]; then
fatal "Invalid value '$copy_vim'"
elif [[ $copy_vim == "0" ]]; then
do_vim_copy=0
printf "\n"
fi
fi
if [[ $do_vim_copy -eq 1 ]]; then
printf "${MAGENTA}==> ${NORMAL}Copying ${YELLOW}.dotfiles/vim${NORMAL} to ${YELLOW}$PWD/.vim${NORMAL}\n"
cp -r .dotfiles/vim .vim
fi
else
make_link .dotfiles/vim .vim
fi
FILES=()
FILES+=('env.loader')
FILES+=('aliases')
FILES+=('gitconfig')
FILES+=('vimrc')
FILES+=('curlrc')
for file in "${FILES[@]}"
do
make_link .dotfiles/$file .$file
done
set +e
git_comp_filename=".git-completion.bash"
printf "${MAGENTA}==> ${NORMAL}Downloading Git completion list to ${YELLOW}$PWD/$git_comp_filename${NORMAL}\n"
@@ -129,37 +70,19 @@ set -e
# Setup platform files
#########################
if [[ $is_windows -eq 1 ]]; then
printf "\n${BOLD}Setting up Windows${NORMAL}\n\n"
os_name="windows"
# Already using bash if running msys2.
setup_bash
elif [[ $is_macos -eq 1 ]]; then
if [[ $is_macos -eq 1 ]]; then
printf "\n${BOLD}Setting up MacOS${NORMAL}\n\n"
os_name="osx"
$dotfiles_dir/macos/install
# might just switch back to bash since the zsh stuff is ancient.
setup_zsh
setup_bash
use_shell zsh
elif [[ $is_linux -eq 1 ]]; then
printf "\n${BOLD}Setting up Linux${NORMAL}\n\n"
os_name="linux"
setup_zsh
setup_bash
$dotfiles_dir/linux/install
use_shell bash
fi
if [[ $os_name != "" ]]; then
if [ -f .dotfiles/$os_name/env.platform ]; then
make_link .dotfiles/$os_name/env.platform .env.platform
fi
if [ -f .dotfiles/$os_name/gitconfig.platform ]; then
make_link .dotfiles/$os_name/gitconfig.platform .gitconfig.platform
fi
$dotfiles_dir/$os_name/install
fi
popd "$HOME" &>/dev/null
printf "${BOLD}${GREEN}Done!${NORMAL}\n"

Some files were not shown because too many files have changed in this diff Show More