Compare commits

...

4 Commits

5 changed files with 134 additions and 97 deletions

116
aliases
View File

@ -350,7 +350,7 @@ make_vid_dir_and_cd_into() {
} }
# Download YouTube videos. Note that yt-dlp downloads a lot faster than streamlink. # Download YouTube videos. Note that yt-dlp downloads a lot faster than streamlink.
dl_youtube_vid() { download_youtube_vid() {
local format="$1" local format="$1"
local shortname="$2" local shortname="$2"
local make_folder="$3" local make_folder="$3"
@ -402,7 +402,7 @@ dl_youtube_vid() {
} }
# Download YouTube video and flip horizontally. # Download YouTube video and flip horizontally.
dl_youtube_vid_and_hflip() { download_youtube_vid_and_hflip() {
local format="$1" local format="$1"
local make_folder="$2" local make_folder="$2"
local url="$3" local url="$3"
@ -446,7 +446,7 @@ dl_youtube_vid_and_hflip() {
fi fi
} }
dl_youtube_playlist() { download_youtube_playlist() {
local format="$1" local format="$1"
local url="$2" local url="$2"
local dir_name="$3" local dir_name="$3"
@ -483,7 +483,7 @@ dl_youtube_playlist() {
} }
# Download Twitch chat transcript # Download Twitch chat transcript
actually_dl_twitch_chat() { actually_download_twitch_chat() {
local url="$1" local url="$1"
local filename="$2" local filename="$2"
@ -496,7 +496,7 @@ actually_dl_twitch_chat() {
fi fi
} }
dl_twitch_chat() { download_twitch_chat() {
local make_folder="$1" local make_folder="$1"
local url="$2" local url="$2"
shift 2 shift 2
@ -514,7 +514,7 @@ dl_twitch_chat() {
fi fi
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" $opts $url)"
if [[ $make_folder == "1" ]]; then if [[ $make_folder == "1" ]]; then
cd .. cd ..
@ -532,7 +532,7 @@ dl_twitch_chat() {
# To extract a portion of a video, you have to first download the entire file and then use the # To extract a portion of a video, you have to first download the entire file and then use the
# `trim-video` or `compress-video-and-trim` scripts. # `trim-video` or `compress-video-and-trim` scripts.
# #
dl_twitch_vid() { download_twitch_vid() {
local format="$1" local format="$1"
local shortname="$2" local shortname="$2"
local compress="$3" local compress="$3"
@ -590,7 +590,7 @@ dl_twitch_vid() {
fi fi
# Download Twitch chat transcript # 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. # 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 -o "$name_format.%(ext)s" $opts $url)
@ -628,7 +628,7 @@ dl_twitch_vid() {
# Can download an embedded vid. You might need to save the site cookies if the vid is behind a paywall. # 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. yt-dlp.exe -F --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.
dl_vimeo_vid() { download_vimeo_vid() {
local format="$1" local format="$1"
local shortname="$2" local shortname="$2"
local compress="$3" local compress="$3"
@ -688,7 +688,7 @@ dl_vimeo_vid() {
} }
# Download Twitter videos. # Download Twitter videos.
dl_twitter_vid() { download_twitter_vid() {
local format="$1" local format="$1"
local make_folder="$2" local make_folder="$2"
local url="$3" local url="$3"
@ -739,7 +739,7 @@ dl_twitter_vid() {
} }
# Download MP4 video. # Download MP4 video.
dl_mp4() { download_mp4() {
local url="$1" local url="$1"
local filename="$2" local filename="$2"
@ -762,7 +762,7 @@ dl_mp4() {
} }
# Download from m3u8 stream to mp4. # Download from m3u8 stream to mp4.
dl_from_m3u8() { download_from_m3u8() {
local m3u8_path="$1" local m3u8_path="$1"
local filename="$2" local filename="$2"
@ -783,7 +783,7 @@ dl_from_m3u8() {
} }
# Download Instagram video and flip horizontally. # Download Instagram video and flip horizontally.
dl_instagram_vid_and_hflip() { download_instagram_vid_and_hflip() {
local url="$1" local url="$1"
local filename="$2" local filename="$2"
@ -809,68 +809,68 @@ dl_instagram_vid_and_hflip() {
} }
# YouTube Vid DL # YouTube Vid DL
alias yt='dl_youtube_vid "" $SHORTNAME_OFF' alias yt='download_youtube_vid "" $SHORTNAME_OFF'
alias yt-shortname='dl_youtube_vid "" $SHORTNAME_ON' alias yt-shortname='download_youtube_vid "" $SHORTNAME_ON'
alias yt-1080='dl_youtube_vid "137+140" $SHORTNAME_OFF' alias yt-1080='download_youtube_vid "137+140" $SHORTNAME_OFF'
alias yt-1080-shortname='dl_youtube_vid "137+140" $SHORTNAME_ON' alias yt-1080-shortname='download_youtube_vid "137+140" $SHORTNAME_ON'
alias yt-720='dl_youtube_vid "136+140" $SHORTNAME_OFF' alias yt-720='download_youtube_vid "136+140" $SHORTNAME_OFF'
alias yt-720-shortname='dl_youtube_vid "136+140" $SHORTNAME_ON' alias yt-720-shortname='download_youtube_vid "136+140" $SHORTNAME_ON'
alias yt-playlist='dl_youtube_playlist ""' alias yt-playlist='download_youtube_playlist ""'
alias yt-playlist-1080='dl_youtube_playlist "137+140"' alias yt-playlist-1080='download_youtube_playlist "137+140"'
alias yt-playlist-720='dl_youtube_playlist "136+140"' alias yt-playlist-720='download_youtube_playlist "136+140"'
alias yt-playlist-tiny='dl_youtube_playlist "160+140"' alias yt-playlist-tiny='download_youtube_playlist "160+140"'
alias yt-audio='yt-dlp.exe -f "140"' alias yt-audio='yt-dlp.exe -f "140"'
alias yt-and-hflip='dl_youtube_vid_and_hflip "137+140"' # 1080p alias yt-and-hflip='download_youtube_vid_and_hflip "137+140"' # 1080p
# Twitch Vid DL # Twitch Vid DL
alias tw='dl_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_OFF' alias tw='download_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_OFF'
alias tw-compressed='dl_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_ON' alias tw-compressed='download_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_ON'
alias tw-shortname='dl_twitch_vid "" $SHORTNAME_ON $COMPRESSION_OFF' alias tw-shortname='download_twitch_vid "" $SHORTNAME_ON $COMPRESSION_OFF'
alias tw-shortname-compressed='dl_twitch_vid "" $SHORTNAME_ON $COMPRESSION_ON' alias tw-shortname-compressed='download_twitch_vid "" $SHORTNAME_ON $COMPRESSION_ON'
alias tw-custom='dl_twitch_vid ' alias tw-custom='download_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='download_twitch_vid "1080" $SHORTNAME_OFF $COMPRESSION_OFF'
alias tw-1080-compressed='dl_twitch_vid "1080" $SHORTNAME_OFF $COMPRESSION_ON' alias tw-1080-compressed='download_twitch_vid "1080" $SHORTNAME_OFF $COMPRESSION_ON'
alias tw-1080-shortname='dl_twitch_vid "1080" $SHORTNAME_ON $COMPRESSION_OFF' alias tw-1080-shortname='download_twitch_vid "1080" $SHORTNAME_ON $COMPRESSION_OFF'
alias tw-1080-shortname-compressed='dl_twitch_vid "1080" $SHORTNAME_ON $COMPRESSION_ON' alias tw-1080-shortname-compressed='download_twitch_vid "1080" $SHORTNAME_ON $COMPRESSION_ON'
alias tw-1080p60='dl_twitch_vid "1080p60" $SHORTNAME_OFF $COMPRESSION_OFF' alias tw-1080p60='download_twitch_vid "1080p60" $SHORTNAME_OFF $COMPRESSION_OFF'
alias tw-1080p50='dl_twitch_vid "1080p50" $SHORTNAME_OFF $COMPRESSION_OFF' alias tw-1080p50='download_twitch_vid "1080p50" $SHORTNAME_OFF $COMPRESSION_OFF'
alias tw-1080p60-compressed='dl_twitch_vid "1080p60" $SHORTNAME_OFF $COMPRESSION_ON' alias tw-1080p60-compressed='download_twitch_vid "1080p60" $SHORTNAME_OFF $COMPRESSION_ON'
alias tw-1080p50-compressed='dl_twitch_vid "1080p50" $SHORTNAME_OFF $COMPRESSION_ON' alias tw-1080p50-compressed='download_twitch_vid "1080p50" $SHORTNAME_OFF $COMPRESSION_ON'
alias tw-1080p60-shortname='dl_twitch_vid "1080p60" $SHORTNAME_ON $COMPRESSION_OFF' alias tw-1080p60-shortname='download_twitch_vid "1080p60" $SHORTNAME_ON $COMPRESSION_OFF'
alias tw-1080p50-shortname='dl_twitch_vid "1080p50" $SHORTNAME_ON $COMPRESSION_OFF' alias tw-1080p50-shortname='download_twitch_vid "1080p50" $SHORTNAME_ON $COMPRESSION_OFF'
alias tw-1080p60-shortname-compressed='dl_twitch_vid "1080p60" $SHORTNAME_ON $COMPRESSION_ON' alias tw-1080p60-shortname-compressed='download_twitch_vid "1080p60" $SHORTNAME_ON $COMPRESSION_ON'
alias tw-1080p50-shortname-compressed='dl_twitch_vid "1080p50" $SHORTNAME_ON $COMPRESSION_ON' alias tw-1080p50-shortname-compressed='download_twitch_vid "1080p50" $SHORTNAME_ON $COMPRESSION_ON'
alias tw-720='dl_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_OFF' alias tw-720='download_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_OFF'
alias tw-720-compressed='dl_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_ON' alias tw-720-compressed='download_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_ON'
alias tw-720-shortname='dl_twitch_vid "720p" $SHORTNAME_ON $COMPRESSION_OFF' alias tw-720-shortname='download_twitch_vid "720p" $SHORTNAME_ON $COMPRESSION_OFF'
alias tw-720p60='dl_twitch_vid "720p60" $SHORTNAME_OFF $COMPRESSION_OFF' alias tw-720p60='download_twitch_vid "720p60" $SHORTNAME_OFF $COMPRESSION_OFF'
alias tw-720p60-shortname='dl_twitch_vid "720p60" $SHORTNAME_ON $COMPRESSION_OFF' alias tw-720p60-shortname='download_twitch_vid "720p60" $SHORTNAME_ON $COMPRESSION_OFF'
alias tw-4k='dl_twitch_vid "2160p" $SHORTNAME_OFF $COMPRESSION_OFF' alias tw-4k='download_twitch_vid "2160p" $SHORTNAME_OFF $COMPRESSION_OFF'
alias tw-4k-compressed='dl_twitch_vid "2160p" $SHORTNAME_OFF $COMPRESSION_ON' alias tw-4k-compressed='download_twitch_vid "2160p" $SHORTNAME_OFF $COMPRESSION_ON'
alias tw-4k-shortname='dl_twitch_vid "2160p" $SHORTNAME_ON $COMPRESSION_OFF' alias tw-4k-shortname='download_twitch_vid "2160p" $SHORTNAME_ON $COMPRESSION_OFF'
alias tw-4k-shortname-compressed='dl_twitch_vid "2160p" $SHORTNAME_ON $COMPRESSION_ON' alias tw-4k-shortname-compressed='download_twitch_vid "2160p" $SHORTNAME_ON $COMPRESSION_ON'
alias tw-source='dl_twitch_vid "Source" $SHORTNAME_OFF $COMPRESSION_OFF' alias tw-source='download_twitch_vid "Source" $SHORTNAME_OFF $COMPRESSION_OFF'
# Vimeo Vid DL # Vimeo Vid DL
alias vimeo='dl_vimeo_vid "Original" $SHORTNAME_OFF $COMPRESSION_OFF' alias vimeo='download_vimeo_vid "Original" $SHORTNAME_OFF $COMPRESSION_OFF'
alias vimeo-compressed='dl_vimeo_vid "Original" $SHORTNAME_OFF $COMPRESSION_ON' alias vimeo-compressed='download_vimeo_vid "Original" $SHORTNAME_OFF $COMPRESSION_ON'
# Instagram Vid DL # Instagram Vid DL
alias ig-download-and-hflip='dl_instagram_vid_and_hflip ' alias ig-download-and-hflip='download_instagram_vid_and_hflip '
# Twitter Vid DL # Twitter Vid DL
alias twt='dl_twitter_vid "" ' alias twt='download_twitter_vid "" '
# Misc # Misc
alias download-mp4='dl_mp4' alias download-mp4='download_mp4'
alias download-from-m3u8='dl_from_m3u8' alias download-from-m3u8='download_from_m3u8'
#################################################################################################### ####################################################################################################
# Video Compression # Video Compression

View File

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

3
bin/file-x64dbg.bat Normal file
View File

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

View File

@ -24,13 +24,16 @@ else
NORMAL="" NORMAL=""
fi fi
warn() {
printf "${BOLD}${YELLOW}$1${NORMAL}"
}
error() { error() {
printf "${BOLD}${RED}$1${NORMAL}" printf "${RED}$1${NORMAL}"
} }
fatal() { fatal() {
msg=$1 printf "${RED}$1${NORMAL}\n"
printf "${RED}${msg}${NORMAL}\n"
exit 1 exit 1
} }

102
vimrc
View File

@ -657,38 +657,34 @@ endfun
" These write functions below will not be reloaded because they initiate the " These write functions below will not be reloaded because they initiate the
" save. So if you make changes to them then you need to manually reload this " save. So if you make changes to them then you need to manually reload this
" file using <leader>rv or whatever. :ReloadVimrcError " file using <leader>rv or whatever. :ReloadVimrcError
function! DoSingleWrite() function! WriteCurrentFileAndCreateCtags()
write! write!
call CreateCtags() call CreateCtags()
endfunction endfunction
function! DoSingleWriteThenQuit() function! WriteCurrentFileAndCreateCtagsThenQuit()
write! write!
call CreateCtags() call CreateCtags()
quit quit
endfunction endfunction
" @fixme Sometimes a :wa that saves multiple files causes vim to hang and use " @fixme Sometimes a :wa that saves multiple files causes vim to hang and use a lot of CPU.
" a lot of CPU. function! WriteAllModifiedFilesAndCreateCtags()
function! DoMultiWrite() wall!
let l:current_buffer = bufnr("%")
bufdo wa
" Restore the last buffer because it may have changed.
exec "buffer " . l:current_buffer
call CreateCtags() call CreateCtags()
endfunction endfunction
cnoreabbrev w :call DoSingleWrite() cnoreabbrev w :call WriteCurrentFileAndCreateCtags()
cnoreabbrev W :call DoSingleWrite() cnoreabbrev W :call WriteCurrentFileAndCreateCtags()
cnoreabbrev wa :call DoMultiWrite() cnoreabbrev wa :call WriteAllModifiedFilesAndCreateCtags()
cnoreabbrev Wa :call DoMultiWrite() cnoreabbrev Wa :call WriteAllModifiedFilesAndCreateCtags()
cnoreabbrev WA :call DoMultiWrite() cnoreabbrev WA :call WriteAllModifiedFilesAndCreateCtags()
cnoreabbrev wq :call DoSingleWriteThenQuit() cnoreabbrev wq :call WriteCurrentFileAndCreateCtagsThenQuit()
cnoreabbrev Wq :call DoSingleWriteThenQuit() cnoreabbrev Wq :call WriteCurrentFileAndCreateCtagsThenQuit()
cnoreabbrev WQ :call DoSingleWriteThenQuit() cnoreabbrev WQ :call WriteCurrentFileAndCreateCtagsThenQuit()
nnoremap <leader>w :call DoSingleWrite()<cr> nnoremap <leader>w :call WriteCurrentFileAndCreateCtags()<cr>
nnoremap <leader>x :call DoSingleWriteThenQuit()<cr> nnoremap <leader>x :call WriteCurrentFileAndCreateCtagsThenQuit()<cr>
nnoremap <leader>q :q<cr> nnoremap <leader>q :q<cr>
cnoreabbrev Q q cnoreabbrev Q q
@ -984,9 +980,9 @@ endfunction
" Set the intial light/dark mode. " Set the intial light/dark mode.
if g:campo_light_dark_mode =~ 'light' if g:campo_light_dark_mode =~ 'light'
call ChangeLightDarkMode('light', 1) call ChangeLightDarkMode('light', 1)
else else
call ChangeLightDarkMode('dark', 1) call ChangeLightDarkMode('dark', 1)
endif endif
" Open the current color scheme for editing. " Open the current color scheme for editing.
@ -1156,61 +1152,97 @@ function! StopRunTask()
endfunction endfunction
function! Build(optimized=0, silent=0) function! Build(optimized=0, silent=0)
let l:ext = tolower(expand('%:e')) let l:async_cmd = "AsyncRun! "
let l:parent_dir = expand('%:p:h')
let l:async_cmd = "AsyncRun! -save=2 "
if a:silent if a:silent
let l:async_cmd .= "-post=call\\ HideAsyncResults() " let l:async_cmd .= "-post=call\\ HideAsyncResults() "
endif endif
let l:is_jai = 0 let l:is_jai = 0
let l:cmd = "" let l:cmd = ""
if filereadable(l:parent_dir . "/build.jai")
let l:ext = tolower(expand('%:e'))
let l:current_dir = expand('%:h')
let l:parent_dir = expand('%:p:h')
" Check if this is a jai module with a build.jai one directory back. This
" only works when the file is directly inside the modules folder.
let l:jai_module_with_build = (tolower(l:current_dir) == "modules") && filereadable(l:current_dir . "/../build.jai")
if (l:jai_module_with_build == 1) || filereadable(l:parent_dir . "/build.jai")
" Jai build file " Jai build file
let l:is_jai = 1 let l:is_jai = 1
let l:cmd = "jai " . l:parent_dir . "/build.jai " let l:cmd = "jai " . l:parent_dir . "/"
if l:jai_module_with_build == 1
let l:cmd .= "../build.jai"
else
let l:cmd .= "build.jai"
endif
if a:optimized == 1 if a:optimized == 1
echo "Compiling release build.jai" echo "Compiling release build.jai"
let l:cmd .= "-release " let l:cmd .= " -release"
else else
echo "Compiling debug build.jai" echo "Compiling debug build.jai"
endif endif
elseif l:ext == "jai" elseif l:ext == "jai"
let l:is_jai = 1 let l:is_jai = 1
let l:cmd = "jai % " let l:cmd = "jai % "
if a:optimized == 1 if a:optimized == 1
echo "Compiling release " . expand('%:t') echo "Compiling release " . expand('%:t')
let l:cmd .= "-release " let l:cmd .= " -release"
else else
echo "Compiling debug " . expand('%:t') echo "Compiling debug " . expand('%:t')
endif endif
" If there's a local modules/ directory then we'll import it. " If there's a local modules/ directory then we'll import it.
if isdirectory(l:parent_dir . "/modules") if isdirectory(l:parent_dir . "/modules")
let l:cmd .= "-import_dir modules " let l:cmd .= " -import_dir modules"
endif endif
else else
let l:cmd .= './build* ' let l:cmd .= './build* '
if a:optimized == 1 if a:optimized == 1
let l:cmd .= '-o ' let l:cmd .= ' -o'
endif endif
endif endif
if l:is_jai if l:is_jai
let l:cmd .= ' '.g:campo_jai_build_args let l:cmd .= ' '.g:campo_jai_build_args
endif endif
" I was originally passing -save=2 to AsyncRun! in order to save all
" modified files (it just does a `silent! wall` call), but I want ctags to
" be generated so we're handling the save ourselves.
call WriteAllModifiedFilesAndCreateCtags()
exec l:async_cmd . l:cmd exec l:async_cmd . l:cmd
endfunction endfunction
function! RunExe() function! RunProgram()
if tolower(expand('%:e')) == "jai" let l:ext = tolower(expand('%:e'))
if l:ext == "jai"
if filereadable(expand('%:p:r') . '.exe') if filereadable(expand('%:p:r') . '.exe')
exec "AsyncRun! " . expand('%:p:r') . ".exe" exec "AsyncRun! " . expand('%:p:r') . ".exe"
else else
let l:files = systemlist('ls ' . expand('%:p:h') . '/*.exe 2>/dev/null') if tolower(expand('%:h')) == "modules"
" This is likely a jai module inside a project. Check for an " exe one directory back.
let l:files = systemlist('ls ' . expand('%:p:h') . '/../*.exe 2>/dev/null')
else
let l:files = systemlist('ls ' . expand('%:p:h') . '/*.exe 2>/dev/null')
endif
if len(l:files) > 0 if len(l:files) > 0
exec "AsyncRun! " . l:files[0] exec "AsyncRun! " . l:files[0]
else else
call PrintError("No exe found. Compile first?") call PrintError("No exe found. Compile first?")
endif endif
endif endif
elseif l:ext == "py"
exec "AsyncRun! python %"
else else
exec "AsyncRun! -post=call\\ StopRunTask() ./run %" exec "AsyncRun! -post=call\\ StopRunTask() ./run %"
endif endif
@ -1237,8 +1269,8 @@ nnoremap <silent><F8> :call Build(0, 1)<cr>
nnoremap <leader>bb :call Build(1)<cr> nnoremap <leader>bb :call Build(1)<cr>
" Execute run script " Execute run script
nnoremap <silent><leader>br :call RunExe()<cr> nnoremap <silent><leader>br :call RunProgram()<cr>
nnoremap <silent><F9> :call RunExe()<cr> nnoremap <silent><F9> :call RunProgram()<cr>
nnoremap <leader>bs :AsyncStop<cr> nnoremap <leader>bs :AsyncStop<cr>