From dfc7e9ec7428c54f36d3fd1de9b69d63be4b42d5 Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Wed, 14 Jul 2021 11:16:23 -0400 Subject: [PATCH] Various things (aliases, vimrc, scripts, readme) --- aliases | 269 +++++++++++++----- bin/compress-video | 46 ++- bin/compress-video-with-crf | 69 +++++ configs/firefox/README.txt | 0 configs/firefox/userChrome.css | 10 + vimrc | 36 ++- .../AlwaysShowSubfolderThumbs.jsx | 67 +++++ ...disable-windows-error-reporting-dialog.bat | 2 + windows/readme.md | 8 +- 9 files changed, 392 insertions(+), 115 deletions(-) create mode 100644 bin/compress-video-with-crf create mode 100644 configs/firefox/README.txt create mode 100644 configs/firefox/userChrome.css create mode 100644 windows/Adobe Bridge - Startup Scripts/AlwaysShowSubfolderThumbs.jsx create mode 100644 windows/disable-windows-error-reporting-dialog.bat diff --git a/aliases b/aliases index 4bc7d4d..2f55f98 100644 --- a/aliases +++ b/aliases @@ -134,6 +134,7 @@ make_vid_dir_and_cd_into() { # @note If the filename contains symbols that are incompatible with # Windows' directory names then add --restrict-filenames to the command. dir_name=$(youtube-dl.exe --get-filename -o "%(upload_date)s - %(title)s" $opts $url) + if [[ $dir_name == "" ]]; then return 1 fi @@ -157,20 +158,23 @@ make_vid_dir_and_cd_into() { dl_youtube_vid() { local format="$1" local shortname="$2" - local url="$3" - shift 3 + local make_folder="$3" + local url="$4" + shift 4 local opts="$@" if [[ $url == "" ]]; then - error "Format: $0 \n" + error "Format: $0 \n" return fi opts+=" --write-sub --sub-lang en --embed-subs" - make_vid_dir_and_cd_into $url - if [[ $? -ne 0 ]]; then - return + if [[ $make_folder == "1" ]]; then + make_vid_dir_and_cd_into $url "" + if [[ $? -ne 0 ]]; then + return + fi fi if [[ $shortname -eq 0 ]]; then @@ -188,26 +192,31 @@ dl_youtube_vid() { youtube-dl.exe -f $format -o "$filename" $opts $url fi - cd .. + if [[ $make_folder == "1" ]]; then + cd .. + fi } # Download YouTube video and flip horizontally. dl_youtube_vid_and_hflip() { local format="$1" - local url="$2" - shift 2 + local make_folder="$2" + local url="$3" + shift 3 local opts="$@" if [[ $url == "" ]]; then - error "Format: $0 \n" + error "Format: $0 \n" return fi opts+=" --write-sub --sub-lang en --embed-subs" - make_vid_dir_and_cd_into $url - if [[ $? -ne 0 ]]; then - return + if [[ $make_folder == "1" ]]; then + make_vid_dir_and_cd_into $url "" + if [[ $? -ne 0 ]]; then + return + fi fi local filename=$(youtube-dl.exe --get-filename -o "%(upload_date)s-%(title)s-youtube-%(id)s.%(ext)s" $url) @@ -223,7 +232,9 @@ dl_youtube_vid_and_hflip() { ffmpeg -i "$filename" -vf hflip -c:a copy "copy_${filename}" mv "copy_${filename}" "$filename" - cd .. + if [[ $make_folder == "1" ]]; then + cd .. + fi } dl_youtube_playlist() { @@ -259,6 +270,21 @@ dl_youtube_playlist() { cd .. } +# Download Twitch chat transcript +actually_dl_twitch_chat() { + local url="$1" + local filename="$2" + + rechat.exe -d $url "$filename.json" + if [[ -f "$filename.json" ]]; then + rechat.exe -p "$filename.json" "$filename.txt" -b -o + mv "$filename.txt" "${filename:0:4}-${filename:4:2}-${filename:6}.txt" + rm "$filename.json" + else + error "Video doesn't have a chat transcript." + fi +} + dl_twitch_chat() { local url="$1" shift 1 @@ -274,44 +300,42 @@ dl_twitch_chat() { return fi - # Download Twitch chat transcript - local name_format="%(upload_date)s-%(title)s-twitch-%(id)s" - local chat_file=$(youtube-dl.exe --get-filename -o "$name_format" $opts $url) - rechat.exe -d $url "$chat_file.json" - rechat.exe -p "$chat_file.json" "$chat_file.txt" -b -o - mv "$chat_file.txt" "${chat_file:0:4}-${chat_file:4:2}-${chat_file:6}.txt" - rm "$chat_file.json" + actually_dl_twitch_chat $url "$(youtube-dl.exe --get-filename -o "%(upload_date)s-%(title)s-twitch-%(id)s" $opts $url)" cd .. } # Download Twitch videos. -# If you want to download a sub-only vid then extract your twitch cookies to a file (can use cookies.txt addon) -# and then pass it as an option, using the full path to the cookies file, e.g. +# If you want to download subcriber-only vids then first extract your twitch +# cookies to a file (can use cookies.txt addon from Lennon Hill) and then pass it as an option, +# using the full path to the cookies file, e.g. # `tw-1080p60 --cookies /c//twitch_cookies.txt` # dl_twitch_vid() { local format="$1" local shortname="$2" - local compression_level="$3" - local url="$4" - shift 4 + local compress="$3" + local make_folder="$4" + local url="$5" + shift 5 local opts="$@" if [[ $url == "" ]]; then - error "Format: $0 \n" + error "Format: $0 \n" return fi - if [[ $compression_level -eq 0 ]]; then + if [[ $compress -eq 0 ]]; then printf "${BOLD}Downloading Twitch vid with no compression.${NORMAL}\n" else - printf "${BOLD}Downloading Twitch vid with compression level ${YELLOW}$compression_level${NORMAL}.\n" + printf "${BOLD}Downloading Twitch vid with compression.${NORMAL}.\n" fi - make_vid_dir_and_cd_into $url "" $opts - if [[ $? -ne 0 ]]; then - return + if [[ $make_folder == "1" ]]; then + make_vid_dir_and_cd_into $url "" $opts + if [[ $? -ne 0 ]]; then + return + fi fi if [[ $shortname -eq 0 ]]; then @@ -321,11 +345,7 @@ dl_twitch_vid() { fi # Download Twitch chat transcript - local chat_file=$(youtube-dl.exe --get-filename -o "$name_format" $opts $url) - rechat.exe -d $url "$chat_file.json" - rechat.exe -p "$chat_file.json" "$chat_file.txt" -b -o - mv "$chat_file.txt" "${chat_file:0:4}-${chat_file:4:2}-${chat_file:6}.txt" - rm "$chat_file.json" + actually_dl_twitch_chat $url "$(youtube-dl.exe --get-filename -o "$name_format" $opts $url)" # Download the video. local filename=$(youtube-dl.exe --get-filename -o "$name_format.%(ext)s" $opts $url) @@ -335,18 +355,82 @@ dl_twitch_vid() { error=$? if [[ $error -eq 0 ]]; then - if [[ $compression_level -ne 0 ]]; then - compress-video "$filename" $compression_level "temp" + if [[ $compress -eq 1 ]]; then + local temp_name="temp_${RANDOM}" + # 1 arg = use GPU + compress-video 1 "$filename" "$temp_name" extension="${filename##*.}" - mv "$filename" uncompressed_original.$extension - mv temp.$extension "$filename" + mv "$filename" "orig_$filename.$extension" + 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" fi - cd .. + if [[ $make_folder == "1" ]]; then + cd .. + fi +} + +# Download Vimeo videos. +dl_vimeo_vid() { + local format="$1" + local shortname="$2" + local compress="$3" + local make_folder="$4" + local url="$5" + shift 5 + local opts="$@" + + if [[ $url == "" ]]; then + error "Format: $0 \n" + return + fi + + if [[ $compress -eq 0 ]]; then + printf "${BOLD}Downloading Vimeo vid with no compression.${NORMAL}\n" + else + printf "${BOLD}Downloading Vimeo vid with compression.${NORMAL}.\n" + fi + + if [[ $make_folder == "1" ]]; then + make_vid_dir_and_cd_into $url "" $opts + if [[ $? -ne 0 ]]; then + return + fi + fi + + if [[ $shortname -eq 0 ]]; then + local name_format="%(upload_date)s-%(title)s-vimeo-%(id)s" + else + local name_format="%(upload_date)s-shortname-vimeo-%(id)s" + fi + + # Download the video. + local filename=$(youtube-dl.exe --get-filename -o "$name_format.%(ext)s" $opts $url) + filename="${filename:0:4}-${filename:4:2}-${filename:6}" + + youtube-dl.exe -f "$format" -o "$filename" $opts $url + + error=$? + if [[ $error -eq 0 ]]; then + if [[ $compress -eq 1 ]]; then + local temp_name="temp_${RANDOM}" + # 1 arg = use GPU + compress-video 1 "$filename" "$temp_name" + extension="${filename##*.}" + mv "$filename" "orig_$filename.$extension" + 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" + fi + + if [[ $make_folder == "1" ]]; then + cd .. + fi } # Download MP4 video. @@ -642,12 +726,22 @@ alias vu='vagrant up' alias vimrc='vim ~/.vimrc' alias weather='curl wttr.in/toronto -A "curl"' -alias yt='dl_youtube_vid "" 0' -alias yt-shortname='dl_youtube_vid "" 1' -alias yt-1080='dl_youtube_vid "137+140" 0' -alias yt-1080-shortname='dl_youtube_vid "137+140" 1' -alias yt-720='dl_youtube_vid "136+140" 0' -alias yt-720-shortname='dl_youtube_vid "136+140" 1' +# +# Downloading +# + +COMPRESSION_ON=1 +COMPRESSION_OFF=0 +SHORTNAME_ON=1 +SHORTNAME_OFF=0 + +# 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-playlist='dl_youtube_playlist ""' alias yt-playlist-1080='dl_youtube_playlist "137+140"' @@ -657,47 +751,68 @@ alias yt-audio='youtube-dl.exe -f "140"' alias yt-and-hflip='dl_youtube_vid_and_hflip "137+140"' # 1080p alias ig-download-and-hflip='dl_instagram_vid_and_hflip ' -compression_quality=27 # 27 for gpu; 25 for cpu +# Twitch Vid DL +alias tw-src='dl_twitch_vid "Source" $SHORTNAME_OFF $COMPRESSION_OFF' -alias tw-src='dl_twitch_vid "Source" 0 0' - -alias tw='dl_twitch_vid "1080p" 0 0' -alias tw-compressed='dl_twitch_vid "1080p" 0 $compression_quality' -alias tw-shortname='dl_twitch_vid "1080p" 1 0' -alias tw-shortname-compressed='dl_twitch_vid "1080p" 1 $compression_quality' +alias tw='dl_twitch_vid "1080p" $SHORTNAME_OFF $COMPRESSION_OFF' +alias tw-compressed='dl_twitch_vid "1080p" $SHORTNAME_OFF $COMPRESSION_ON' +alias tw-shortname='dl_twitch_vid "1080p" $SHORTNAME_ON $COMPRESSION_OFF' +alias tw-shortname-compressed='dl_twitch_vid "1080p" $SHORTNAME_ON $COMPRESSION_ON' alias tw-custom='dl_twitch_vid ' alias tw-chat='dl_twitch_chat' -alias tw-1080='dl_twitch_vid "1080" 0 0' -alias tw-1080-compressed='dl_twitch_vid "1080" 0 $compression_quality' -alias tw-1080-shortname='dl_twitch_vid "1080" 1 0' -alias tw-1080-shortname-compressed='dl_twitch_vid "1080" 1 $compression_quality' +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-1080p60='dl_twitch_vid "1080p60" 0 0' -alias tw-1080p50='dl_twitch_vid "1080p50" 0 0' -alias tw-1080p60-compressed='dl_twitch_vid "1080p60" 0 $compression_quality' -alias tw-1080p50-compressed='dl_twitch_vid "1080p50" 0 $compression_quality' -alias tw-1080p60-shortname='dl_twitch_vid "1080p60" 1 0' -alias tw-1080p50-shortname='dl_twitch_vid "1080p50" 1 0' -alias tw-1080p60-shortname-compressed='dl_twitch_vid "1080p60" 1 $compression_quality' -alias tw-1080p50-shortname-compressed='dl_twitch_vid "1080p50" 1 $compression_quality' +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' -alias tw-720='dl_twitch_vid "720p" 0 0' -alias tw-720-compressed='dl_twitch_vid "720p-1" 0 $compression_quality' -alias tw-720-shortname='dl_twitch_vid "720p-1" 1 0' -alias tw-720-60='dl_twitch_vid "720p60" 0 0' -alias tw-720-60-shortname='dl_twitch_vid "720p60" 1 0' +alias tw-720='dl_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_OFF' +alias tw-720-compressed='dl_twitch_vid "720p-1" $SHORTNAME_OFF $COMPRESSION_ON' +alias tw-720-shortname='dl_twitch_vid "720p-1" $SHORTNAME_ON $COMPRESSION_OFF' +alias tw-720-60='dl_twitch_vid "720p60" $SHORTNAME_OFF $COMPRESSION_OFF' +alias tw-720-60-shortname='dl_twitch_vid "720p60" $SHORTNAME_ON $COMPRESSION_OFF' -alias tw-4k='dl_twitch_vid "2160p" 0 0' -alias tw-4k-compressed='dl_twitch_vid "2160p" 0 $compression_quality' -alias tw-4k-shortname='dl_twitch_vid "2160p" 1 0' -alias tw-4k-shortname-compressed='dl_twitch_vid "2160p" 1 $compression_quality' +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' -alias tw-source='dl_twitch_vid "Source" 0 0' +alias tw-source='dl_twitch_vid "Source" $SHORTNAME_OFF $COMPRESSION_OFF' +# Vimeo Vid DL +alias vimeo='dl_vimeo_vid "Original" $SHORTNAME_OFF $COMPRESSION_OFF' +alias vimeo-compressed='dl_vimeo_vid "Original" $SHORTNAME_OFF $COMPRESSION_ON' + +# Misc alias download-mp4='dl_mp4' alias download-from-m3u8='dl_from_m3u8' +# Video Compression + +function _compress_video_hard() { + local crf=35 + local name="$1" + local out="$2" + if [[ name == "" || out == "" ]]; then + error "Format: cmd \n" + return + fi + # 1 arg = use GPU + compress-video-with-crf 1 $crf "$name" "$out" +} + +alias compress-video-hard='_compress_video_hard' + + #################################################################################################### # Git #################################################################################################### diff --git a/bin/compress-video b/bin/compress-video index fd656ec..08e761d 100644 --- a/bin/compress-video +++ b/bin/compress-video @@ -24,50 +24,48 @@ else fi if [[ $1 == "" ]]; then - printf "\n${BOLD}Usage: $0 \n - If you want to encode a range of CRF values then use -1 as the crf value.${NORMAL}\n" + printf "${BOLD}${RED}Usage: $0 ${NORMAL}\n" exit 1 fi -filename=$(basename -- "$1") +use_gpu=$1 + +filename=$(basename -- "$2") extension="${filename##*.}" filename="${filename%.*}" -use_crf=$2 -default_crf=25 # Programming vids have pretty crisp text @ crf 25. output_name="$3" -use_cpu=$4 + +use_crf=25 # Found the following to work best with vids containing text (e.g. programming vid): 25 for CPU encoding and 27 for GPU. +if [[ $use_gpu -eq 1 ]]; then + use_crf=27 +fi function encode() { crf=$1 if [[ $output_name == "" ]]; then - output="${filename}_REDUCED_CRF-${crf}.$extension" + output="${filename}_COMPRESSED_CRF-${crf}.$extension" else output="${output_name}.$extension" fi - printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' with CRF $crf | output: $output${NORMAL}\n" + printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' | GPU: $use_gpu | CRF $crf | output: $output${NORMAL}\n" - if [[ $use_cpu -eq 1 ]]; then - ffmpeg -i "$filename.$extension" -c:v libx264 -crf $crf -preset veryfast -profile:v baseline -level 3.0 -strict -2 "$output" - else + 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. ffmpeg -y -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 -i "$filename.$extension" -c:v libx264 -crf $crf -preset veryfast -profile:v baseline -level 3.0 -strict -2 "$output" fi - printf "\n${GREEN}${BOLD}Done encoding '$filename.$extension' with CRF $crf${NORMAL}\n\n" + printf "\n${GREEN}${BOLD}Done encoding '$filename.$extension' (CRF $crf) | output name '$output'${NORMAL}\n\n" } -if [[ $use_crf == "" ]]; then - use_crf=$default_crf -fi +encode $use_crf -if [[ $use_crf == -1 ]]; then - printf "\n${YELLOW}${BOLD}Encoding using a range of CRF values.${NORMAL}\n" +#printf "\n${YELLOW}${BOLD}Encoding using a range of CRF values.${NORMAL}\n" +## Bigger crf values == bigger compression. +#for crf in {25..28} +#do +# encode $crf +#done - # Bigger crf values == bigger compression. - for crf in {25..28} - do - encode $crf - done -else - encode $use_crf -fi diff --git a/bin/compress-video-with-crf b/bin/compress-video-with-crf new file mode 100644 index 0000000..d9638e7 --- /dev/null +++ b/bin/compress-video-with-crf @@ -0,0 +1,69 @@ +#!/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 \n\nIf you want to encode a range of CRF values then use -1 as the crf value.${NORMAL}\n" + exit 1 +fi + +use_gpu=$1 +use_crf=$2 + +filename=$(basename -- "$3") +extension="${filename##*.}" +filename="${filename%.*}" + +output_name="$4" + +function encode() { + crf=$1 + if [[ $output_name == "" ]]; then + output="${filename}_COMPRESSED_CRF-${crf}.$extension" + else + output="${output_name}.$extension" + fi + + printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' | GPU: $use_gpu | CRF $crf | output: $output${NORMAL}\n" + + 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. + ffmpeg -y -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 -i "$filename.$extension" -c:v libx264 -crf $crf -preset veryfast -profile:v baseline -level 3.0 -strict -2 "$output" + fi + printf "\n${GREEN}${BOLD}Done encoding '$filename.$extension' (CRF $crf) | output name '$output'${NORMAL}\n\n" +} + +if [[ $use_crf -ne -1 ]]; then + encode $use_crf +else + printf "\n${YELLOW}${BOLD}Encoding using a range of CRF values.${NORMAL}\n" + + # Bigger crf values == bigger compression. + for crf in {25..28} + do + encode $crf + done +fi diff --git a/configs/firefox/README.txt b/configs/firefox/README.txt new file mode 100644 index 0000000..e69de29 diff --git a/configs/firefox/userChrome.css b/configs/firefox/userChrome.css new file mode 100644 index 0000000..e5bbe82 --- /dev/null +++ b/configs/firefox/userChrome.css @@ -0,0 +1,10 @@ +/* Hide the top tabs toolbar. + To install this: + * Go to your Firefox profile folder (look in %appdata%/Mozilla/Firefox/Profiles) + * Create a 'chrome' folder and place this there. + * In Firefox, go to about:config and set `toolkit.legacyUserProfileCustomizations.stylesheets` to true. + * Restart the browser. +*/ +#TabsToolbar { + display: none !important; +} \ No newline at end of file diff --git a/vimrc b/vimrc index 5296cae..030c661 100644 --- a/vimrc +++ b/vimrc @@ -56,10 +56,11 @@ let g:campo_light_theme = 'campo-light-simple' let g:campo_theme_use_rainbow_parens = 1 "-------------------------------------------- -" You can further customize things in a private vimrc. I use this -" for things that I don't want included in my public dotfiles repo -" such as temp file settings. -source ~/.vimrc.private +" You can further customize things in a private vimrc. I use this for things +" that I don't want included in my public dotfiles repo such as temp file settings. +if filereadable($HOME . "/.vimrc.private") + source $HOME/.vimrc.private +endif "################################################################ "################################################################ @@ -467,9 +468,12 @@ augroup campoCmds autocmd BufReadPre *.asm let g:asmsyntax = "fasm" " Auto reload VIM when settings changed. - autocmd BufWritePost .vimrc so $MYVIMRC - autocmd BufWritePost *.vim so $MYVIMRC - autocmd BufWritePost ~/.vimrc.private so $MYVIMRC + " @fixme Reload lvimrc after sourcing this file on a save. I tried calling + " a function that does the source and a call to lvimrc's API but got an + " error complaining that the function cannot be created while it's in use. + autocmd BufWritePost .vimrc source $MYVIMRC + autocmd BufWritePost *.vim source $MYVIMRC + autocmd BufWritePost ~/.vimrc.private source $MYVIMRC function! s:RunCtags() " The ampersand at the end is to make this run in the background. I had to @@ -532,7 +536,7 @@ nmap z " Open the vimrc file for editing / reload vimrc file. nmap ev :vsp $MYVIMRC nmap pv :vsp ~/.vimrc.private -nmap rv :so $MYVIMRC +nmap rv :source $MYVIMRC " Type %/ in the command bar to have it replaced with the current buffer's " path if the file is on disk. One thing I noticed is that you have to type @@ -1070,8 +1074,8 @@ nnoremap :cp """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Search using ripgrep (first install with Rust: cargo install ripgrep). -function! Search(case_sensitive) - let l:helper = "[" . (a:case_sensitive ? "case-sensitive" : "case-insensitive") . "] search: " +function! Search(case_sensitive, search_args) + let l:helper = "Search [" . a:search_args . " | " . (a:case_sensitive ? "case-sensitive" : "case-insensitive") . "]: " let l:term = input(l:helper) if empty(l:term) return @@ -1079,7 +1083,7 @@ function! Search(case_sensitive) "@note --pretty (i.e. colors) is not enabled in vim-ripgrep because the "quickfix window doesn't seem to parse the ansi color codes. - let l:rg_args = "--column --line-number --no-heading --fixed-strings --no-ignore --hidden --follow --trim -g \"!tags\" " . g:campo_custom_search_args + let l:rg_args = "--column --line-number --no-heading --fixed-strings --no-ignore --hidden --follow --trim -g \"!tags\" " . a:search_args if !a:case_sensitive let l:rg_args .= " --ignore-case" @@ -1087,8 +1091,14 @@ function! Search(case_sensitive) exec 'Rg ' . l:rg_args . ' "' . l:term . '"' endfunction -map s :call Search(0) -map ss :call Search(1) + +" Case insensitive +map s :call Search(0, g:campo_custom_search_args) +noremap :call Search(0, g:campo_custom_search_args_2) + +" Case sensitive +map ss :call Search(1, g:campo_custom_search_args) +noremap :call Search(1, g:campo_custom_search_args_2) " Navigation for the vim-ripgrep search results. " Hit o on a result line to open the file at that line. diff --git a/windows/Adobe Bridge - Startup Scripts/AlwaysShowSubfolderThumbs.jsx b/windows/Adobe Bridge - Startup Scripts/AlwaysShowSubfolderThumbs.jsx new file mode 100644 index 0000000..fc0fa7e --- /dev/null +++ b/windows/Adobe Bridge - Startup Scripts/AlwaysShowSubfolderThumbs.jsx @@ -0,0 +1,67 @@ +//////////////////////////////////////////////////////////////////////////// +// ADOBE SYSTEMS INCORPORATED +// Copyright 2008-2017 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the +// terms of the Adobe license agreement accompanying it. If you have received this file from a +// source other than Adobe, then your use, modification, or distribution of it requires the prior +// written permission of Adobe. +///////////////////////////////////////////////////////////////////////////// + +// Works around the lack of a permanently enabled "Show Items from Subfolders" option (aka flat view). +// The default behaviour is to turn off the option when changing folders. This extension enables the +// flat view when the app starts and then keeps it enabled when changing folders. You can disable this +// behaviour by disabling the "Always Show Items from Subfolders" option. + +function AlwaysFlatViewSetting() { + this.requiredContext = "\tAdobe Bridge must be running.\n"; + this.menuID = "alwaysFlatViewSetting"; +} + +AlwaysFlatViewSetting.prototype.run = function() { + if (!this.canRun()) return false; + + var toggleFlatView = function(enable) { + var task = 'MenuElement.find("FlatView").checked = ' + (enable ? 'true' : 'false'); + app.scheduleTask(task, 0, false); + } + + var label = "Always Show Items from Subfolders"; + var menuItem = new MenuElement( "command", label, "after FlatView"); + menuItem.canBeChecked = true; + menuItem.checked = true; + menuItem.onSelect = function() { + menuItem.checked = !menuItem.checked; + toggleFlatView(menuItem.checked); + } + + // Triggered when changing folders or selecting some menu option. + onSelectItem = function(event) { + if (event.object instanceof Document && event.type == "selectionsChanged") { + if (menuItem.checked) { + toggleFlatView(true); + } + return {handled:false}; // continue handling all other event handlers + } + } + app.eventHandlers.push({handler: onSelectItem}); + + return true; +} + +AlwaysFlatViewSetting.prototype.canRun = function() { + if (BridgeTalk.appName == "bridge") { + if (MenuElement.find(this.menuID)) { + return false; // Item already exists. + } + return true; + } + $.writeln("ERROR:: Cannot run AlwaysFlatViewSetting"); + $.writeln(this.requiredContext); + return false; +} + +if (typeof(AlwaysFlatViewSetting_unitTest ) == "undefined") { + new AlwaysFlatViewSetting().run(); +} diff --git a/windows/disable-windows-error-reporting-dialog.bat b/windows/disable-windows-error-reporting-dialog.bat new file mode 100644 index 0000000..b4d3e33 --- /dev/null +++ b/windows/disable-windows-error-reporting-dialog.bat @@ -0,0 +1,2 @@ +reg add "HKLM\Software\Microsoft\Windows\Windows Error Reporting" /v "Disabled" /t REG_DWORD /d 1 /f +reg add "HKLM\System\CurrentControlSet\Services\WerSvc" /v "Start" /t REG_DWORD /d 4 /f \ No newline at end of file diff --git a/windows/readme.md b/windows/readme.md index 580b81c..447735f 100644 --- a/windows/readme.md +++ b/windows/readme.md @@ -19,6 +19,9 @@ * AFAIK this only works for Intel CPUs; not sure how to do the same thing on AMD. * In the power plan set the processor min/max speed to 99%. +* Disable Windows error reporting dialog so that when stuff crashes you can get to a debugger faster. + * Open an admin cmd prompt and run the file `disable-windows-error-reporting-dialog.bat` from this directory. + * Optional: disable Windows Defender real-time protection: * This can speed up compilation times since Defender will scan every file written to disk. I was able to shave off ~2-5 seconds in a particular project. @@ -106,8 +109,11 @@ processor time and is generally useless. * Install the Windows SDK https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk * Download [O&O ShutUp10](https://www.oo-software.com/en/shutup10) and disable things. -## Setup up Unix-like Shell +## Setup Terminal * Install [MSYS2 w/ MinGW-w64](http://www.msys2.org/) to `C:\msys64` + * MinGW is intended for developing native Windows applications. MSYS is for developing software + that runs inside of the MSYS2 posix-like env with FHS style filesystem naming (i.e. MSYS2 + tools/packages). * Open `C:\msys64\mingw64.exe` * Run `pacman -Syu`, then restart the terminal and run `pacman -Su`. * Run `pacman -S base-devel mingw-w64-x86_64-toolchain git bc`