Compare commits
66 Commits
new-setup-
...
9f5cfd9469
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f5cfd9469 | |||
| dca90109a9 | |||
| 76f24a700c | |||
| 3d5b394e23 | |||
| 6136c20390 | |||
| 2184b8bf40 | |||
| c773b46cbd | |||
| 079cec8402 | |||
| c1c6fec29c | |||
| 740fc319db | |||
| 3bff9be48a | |||
| 172396583f | |||
| cefab517a5 | |||
| 159c8cff90 | |||
| 67bd7e4454 | |||
| 606096c674 | |||
| 19f90233de | |||
| 5715367556 | |||
| 9216d7cee5 | |||
| 9876fcf4cd | |||
| e175fefa18 | |||
| 2a6522b4b7 | |||
| dc88f6cc36 | |||
| 65500a66ea | |||
| a2c5c8a4d6 | |||
| 7d928a25ea | |||
| 4b6d506d7b | |||
| 05c46303c8 | |||
| bc21059ea6 | |||
| 3971799926 | |||
| d7823294b5 | |||
| 02593ec5f6 | |||
| 928cc915dd | |||
| 137efc71a6 | |||
| 98c74416e8 | |||
| 95b05d5944 | |||
| 34d1a0ea04 | |||
| e921e6b9eb | |||
| b399a9e2c9 | |||
| 6889755330 | |||
| 2beccaeeb3 | |||
| 8ad4d67d84 | |||
| abbcd76178 | |||
| f9a06756ca | |||
| 851dc77481 | |||
| f0f2a0f38d | |||
| 208ba7278a | |||
| 4fb7e6cf37 | |||
| 19b3701a95 | |||
| 6555d9d355 | |||
| 27a08fb402 | |||
| bb26b8ceff | |||
| ba9a776867 | |||
| 90c312e954 | |||
| e759f8c3cd | |||
| fb2773ca19 | |||
| 62fa34ca20 | |||
| d7977096a7 | |||
| e3812590a2 | |||
| 7ac31b295f | |||
| 3ea85786ce | |||
| 9b5159e705 | |||
| f636229f5c | |||
| 515a9f479a | |||
| 12a11b2435 | |||
| e602fc281c |
262
.aliases
262
.aliases
@@ -63,6 +63,7 @@ expand_path() {
|
|||||||
ret=$(readlink -m "$ret")
|
ret=$(readlink -m "$ret")
|
||||||
echo $ret
|
echo $ret
|
||||||
}
|
}
|
||||||
|
|
||||||
is_absolute_unix_path() {
|
is_absolute_unix_path() {
|
||||||
if [[ $1 =~ ^/ ]]; then echo 1; else echo 0; fi
|
if [[ $1 =~ ^/ ]]; then echo 1; else echo 0; fi
|
||||||
}
|
}
|
||||||
@@ -119,6 +120,16 @@ open_explorer_here() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove_extra_spaces() {
|
||||||
|
# Replace consecutive spaces with a single space.
|
||||||
|
#
|
||||||
|
# We're using this in the various vid/audio download functions because
|
||||||
|
# Windows seems to strip extra spaces when creating a file, so we need
|
||||||
|
# to match this behaviour in order to do post-processing after downloading.
|
||||||
|
ret=$(echo "$1" | tr -s ' ')
|
||||||
|
echo "$ret"
|
||||||
|
}
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# Building code
|
# Building code
|
||||||
##################
|
##################
|
||||||
@@ -189,6 +200,11 @@ alias ls='ls -F --color'
|
|||||||
alias l='ls -lh'
|
alias l='ls -lh'
|
||||||
alias ll='ls -lha'
|
alias ll='ls -lha'
|
||||||
|
|
||||||
|
mkcd() {
|
||||||
|
mkdir -p "${1}"
|
||||||
|
cd "${1}"
|
||||||
|
}
|
||||||
|
|
||||||
alias aliases='vim ~/.aliases'
|
alias aliases='vim ~/.aliases'
|
||||||
alias al='aliases'
|
alias al='aliases'
|
||||||
|
|
||||||
@@ -233,22 +249,22 @@ alias cls=clear
|
|||||||
alias cpr='cp -r'
|
alias cpr='cp -r'
|
||||||
alias dc='gdc'
|
alias dc='gdc'
|
||||||
alias duh='du -csh'
|
alias duh='du -csh'
|
||||||
|
|
||||||
|
dos2unix_all() {
|
||||||
|
local path="$1"
|
||||||
|
if [[ $path == "" ]]; then
|
||||||
|
path="$PWD"
|
||||||
|
fi
|
||||||
|
find $path -type f -exec dos2unix '{}' '+'
|
||||||
|
}
|
||||||
|
alias d2u='dos2unix_all'
|
||||||
|
|
||||||
alias e='open_explorer_here "$PWD"'
|
alias e='open_explorer_here "$PWD"'
|
||||||
alias exp='echo "Use e instead."'
|
alias exp='echo "Use e instead."'
|
||||||
alias f='fg'
|
alias f='fg'
|
||||||
alias hist='history'
|
alias hist='history'
|
||||||
alias histroy='history'
|
alias histroy='history'
|
||||||
alias irb='irb --readline -r irb/completion'
|
|
||||||
alias lcc='lein clean'
|
|
||||||
alias lca='lein cljsbuild auto dev'
|
|
||||||
alias ldi='lein deps install'
|
|
||||||
alias lsd='lein start-dev'
|
|
||||||
alias moon='curl wttr.in/moon -A "curl"'
|
alias moon='curl wttr.in/moon -A "curl"'
|
||||||
alias reguard='killall -9 ruby ; guard'
|
|
||||||
alias rb='rbenv'
|
|
||||||
alias rbg='rbenv gemset active'
|
|
||||||
alias rbp='cd $RBENV_PATH/versions/$(rbenv version | sed -e "s/ (set.*$//")'
|
|
||||||
alias rbl='cd $RBENV_PATH/versions/$(rbenv version | sed -e "s/ (set.*$//")/lib/ruby'
|
|
||||||
alias rc='rclone'
|
alias rc='rclone'
|
||||||
alias rcc='rclone copy'
|
alias rcc='rclone copy'
|
||||||
alias restart='sudo shutdown now -r'
|
alias restart='sudo shutdown now -r'
|
||||||
@@ -262,9 +278,6 @@ alias t='tree'
|
|||||||
alias tag='ctags -R .'
|
alias tag='ctags -R .'
|
||||||
alias v='vim'
|
alias v='vim'
|
||||||
alias vi='vim'
|
alias vi='vim'
|
||||||
alias vh='vagrant halt'
|
|
||||||
alias vs='vagrant ssh'
|
|
||||||
alias vu='vagrant up'
|
|
||||||
alias vimrc='vim ~/.vimrc'
|
alias vimrc='vim ~/.vimrc'
|
||||||
alias weather='curl wttr.in/toronto -A "curl"'
|
alias weather='curl wttr.in/toronto -A "curl"'
|
||||||
|
|
||||||
@@ -337,6 +350,8 @@ make_vid_dir_and_cd_into() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
dir_name=$(remove_extra_spaces "$dir_name")
|
||||||
|
|
||||||
printf "${BOLD}Creating directory ${YELLOW}'$dir_name'${NORMAL}\n"
|
printf "${BOLD}Creating directory ${YELLOW}'$dir_name'${NORMAL}\n"
|
||||||
mkdir "$dir_name" 2>/dev/null
|
mkdir "$dir_name" 2>/dev/null
|
||||||
cd "$dir_name"
|
cd "$dir_name"
|
||||||
@@ -353,32 +368,52 @@ make_vid_dir_and_cd_into() {
|
|||||||
function my_transcribe_video() {
|
function my_transcribe_video() {
|
||||||
file="$1"
|
file="$1"
|
||||||
output="$2"
|
output="$2"
|
||||||
|
include_small=$3
|
||||||
|
start_time="$4"
|
||||||
|
end_time="$5"
|
||||||
|
|
||||||
if [[ $file == "" ]]; then
|
if [[ $file == "" ]]; then
|
||||||
printf "Usage: <input video> <optional output name>\n"
|
error "Usage: <input video> <optional output name> <optional include small model (1 or 0)> <optional start time> <optional end time>"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [[ $output == "" ]]; then
|
if [[ $output == "" ]]; then
|
||||||
output="${1%.*}" # just use the input name without the extension.
|
output="${1%.*}" # just use the input name without the extension.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $start_time == "" ]]; then start_time="0"; fi
|
||||||
|
if [[ $end_time == "" ]]; then end_time="0"; fi
|
||||||
|
|
||||||
# Tiny is fast and semi-accurate, so whatever.
|
# Tiny is fast and semi-accurate, so whatever.
|
||||||
# Base is pretty good overall. It has good punctuation inserting and
|
# Base is pretty good overall. It has good punctuation inserting and
|
||||||
# catches most words. Small and medium can do better word detection at
|
# catches most words. Small and medium can do better word detection at
|
||||||
# times, but suffer from bad punctuation. Medium is particularly bad and
|
# times, but suffer from bad punctuation. Medium is particularly bad and
|
||||||
# not adding commas and periods.
|
# not adding commas and periods.
|
||||||
transcribe-video "$file" "$output" tiny base
|
if [[ $include_small -eq 1 ]]; then
|
||||||
|
transcribe-video "$file" "$output" $start_time $end_time tiny base small
|
||||||
|
else
|
||||||
|
transcribe-video "$file" "$output" $start_time $end_time tiny base
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function my_transcribe_video_all_models() {
|
function my_transcribe_video_all_models() {
|
||||||
file="$1"
|
file="$1"
|
||||||
output="$2"
|
output="$2"
|
||||||
|
start_time="$3"
|
||||||
|
end_time="$4"
|
||||||
|
|
||||||
if [[ $file == "" ]]; then
|
if [[ $file == "" ]]; then
|
||||||
printf "Usage: <input video> <optional output name>\n"
|
error "Usage: <input video> <optional output name> <optional start time> <optional end time>"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $output == "" ]]; then
|
if [[ $output == "" ]]; then
|
||||||
output="${1%.*}" # just use the input name without the extension.
|
output="${1%.*}" # just use the input name without the extension.
|
||||||
fi
|
fi
|
||||||
transcribe-video "$file" "$output" tiny base small medium
|
|
||||||
|
if [[ $start_time == "" ]]; then start_time="0"; fi
|
||||||
|
if [[ $end_time == "" ]]; then end_time="0"; fi
|
||||||
|
|
||||||
|
transcribe-video "$file" "$output" $start_time $end_time tiny base small medium
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -431,9 +466,10 @@ download_youtube_vid() {
|
|||||||
|
|
||||||
# Get the video filename.
|
# Get the video filename.
|
||||||
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
|
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
|
||||||
|
filename=$(remove_extra_spaces "$filename")
|
||||||
printf "filename: $filename\n"
|
printf "filename: $filename\n"
|
||||||
|
|
||||||
# Download
|
# Download the video.
|
||||||
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
|
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
|
||||||
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
||||||
error=$?
|
error=$?
|
||||||
@@ -456,15 +492,22 @@ download_youtube_vid() {
|
|||||||
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
|
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# You can control which videos are downloaded using the opts param:
|
||||||
|
# --playlist-start NUMBER (1-indexed)
|
||||||
|
# --playlist-end NUMBER
|
||||||
|
# --playlist-items ITEMS (Can be something like 1,2,5 or a range like 1-3,7,10-20)
|
||||||
|
#
|
||||||
download_youtube_playlist() {
|
download_youtube_playlist() {
|
||||||
local format="$1"
|
local format="$1"
|
||||||
local url="$2"
|
local url="$2"
|
||||||
local dir_name="$3"
|
local dir_name="$3"
|
||||||
shift 3
|
shift 3
|
||||||
local opts="$@"
|
local opts="$@ --write-sub --sub-lang en --embed-subs"
|
||||||
|
|
||||||
if [[ $url == "" ]]; then
|
if [[ $url == "" || $dir_name == "" ]]; then
|
||||||
error "Usage: <url> <directory name (optional)> <optional args>"
|
error "Usage: <url> <directory name> <optional args>"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -477,22 +520,18 @@ download_youtube_playlist() {
|
|||||||
opts+=" --merge-output-format mp4"
|
opts+=" --merge-output-format mp4"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
opts+=" --write-sub --sub-lang en --embed-subs"
|
make_vid_dir_and_cd_into $url "$dir_name"
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
if [[ $dir_name != "" ]]; then
|
return
|
||||||
make_vid_dir_and_cd_into $url "$dir_name"
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local cmd="yt-dlp.exe -f $format -o \"v%(playlist_index)03d--%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s.%(ext)s\" $opts $url"
|
local cmd="yt-dlp.exe -f $format -o \"%(playlist_index)03d--%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s.%(ext)s\" $opts $url"
|
||||||
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
||||||
|
|
||||||
# Removing any trailing subtitle files
|
# Removing any trailing subtitle files
|
||||||
rm *.vtt *.srt 2>/dev/null
|
rm *.vtt *.srt 2>/dev/null
|
||||||
|
|
||||||
if [[ $dir_name == "1" ]]; then cd ..; fi
|
cd ..
|
||||||
|
|
||||||
printf "${BOLD}Finished downloading the playlist\n${NORMAL}"
|
printf "${BOLD}Finished downloading the playlist\n${NORMAL}"
|
||||||
}
|
}
|
||||||
@@ -544,10 +583,55 @@ download_youtube_uploads_list() {
|
|||||||
printf "${BOLD}Finished downloading the upload list\n${NORMAL}"
|
printf "${BOLD}Finished downloading the upload list\n${NORMAL}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function download_youtube_audio() {
|
||||||
|
local make_folder="$1"
|
||||||
|
local url="$2"
|
||||||
|
shift 2
|
||||||
|
local opts="$@"
|
||||||
|
|
||||||
|
if [[ $url == "" ]]; then
|
||||||
|
error "Usage: <make folder?> <url> <optional args>"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "${BOLD}Downloading Youtube audio\n\n${NORMAL}"
|
||||||
|
|
||||||
|
if [[ $make_folder == "1" ]]; then
|
||||||
|
make_vid_dir_and_cd_into $url ""
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local format="140"
|
||||||
|
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s"
|
||||||
|
|
||||||
|
# Get the audio filename.
|
||||||
|
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
|
||||||
|
filename=$(remove_extra_spaces "$filename")
|
||||||
|
printf "filename: $filename\n"
|
||||||
|
|
||||||
|
# Download the audio.
|
||||||
|
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
|
||||||
|
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
||||||
|
error=$?
|
||||||
|
|
||||||
|
if [[ $error -ne 0 ]]; then
|
||||||
|
error "Error: Failed to download '$url'"
|
||||||
|
if [[ $make_folder == "1" ]]; then cd ..; fi
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $make_folder == "1" ]]; then cd ..; fi
|
||||||
|
|
||||||
|
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
|
||||||
|
}
|
||||||
|
|
||||||
# Download Twitch chat transcript
|
# Download Twitch chat transcript
|
||||||
actually_download_twitch_chat() {
|
actually_download_twitch_chat() {
|
||||||
local url="$1"
|
local url="$1"
|
||||||
local filename="$2"
|
local filename="$2"
|
||||||
|
filename=$(remove_extra_spaces "$filename")
|
||||||
|
|
||||||
rechat.exe -d $url "$filename.json"
|
rechat.exe -d $url "$filename.json"
|
||||||
if [[ -f "$filename.json" ]]; then
|
if [[ -f "$filename.json" ]]; then
|
||||||
@@ -661,16 +745,18 @@ download_twitch_vid() {
|
|||||||
|
|
||||||
# Get the video filename.
|
# Get the video filename.
|
||||||
local filename=$(yt-dlp.exe --get-filename -f $yt_dlp_format -o "$name_format.%(ext)s" $opts $url)
|
local filename=$(yt-dlp.exe --get-filename -f $yt_dlp_format -o "$name_format.%(ext)s" $opts $url)
|
||||||
|
filename=$(remove_extra_spaces "$filename")
|
||||||
|
printf "filename: $filename\n"
|
||||||
|
|
||||||
# Download
|
# Download the video.
|
||||||
if [[ $subscriber_vod == "0" ]]; then
|
if [[ $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\""
|
printf "${YELLOW}${BOLD}\nUsing streamlink to download...${NORMAL}\n"
|
||||||
|
local cmd="streamlink.exe --twitch-low-latency --twitch-disable-ads --twitch-disable-hosting --force --progress=force $opts $url $streamlink_format -O | ffmpeg -i pipe:0 -c copy \"$filename\""
|
||||||
else
|
else
|
||||||
|
printf "${YELLOW}${BOLD}\nUsing yt-dlp to download...${NORMAL}\n"
|
||||||
local cmd="yt-dlp.exe -f $yt_dlp_format -o \"$filename\" $opts $url"
|
local cmd="yt-dlp.exe -f $yt_dlp_format -o \"$filename\" $opts $url"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "${YELLOW}${BOLD}Downloading video\n${NORMAL}"
|
|
||||||
|
|
||||||
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
||||||
error=$?
|
error=$?
|
||||||
|
|
||||||
@@ -682,9 +768,9 @@ download_twitch_vid() {
|
|||||||
|
|
||||||
if [[ $compress == "1" ]]; then
|
if [[ $compress == "1" ]]; then
|
||||||
local temp_name="temp_${RANDOM}"
|
local temp_name="temp_${RANDOM}"
|
||||||
|
extension="${filename##*.}"
|
||||||
# 0=cpu, 1=gpu
|
# 0=cpu, 1=gpu
|
||||||
compress-video "$filename" "$temp_name" 0
|
compress-video "$filename" "$temp_name" 0
|
||||||
extension="${filename##*.}"
|
|
||||||
mv "$filename" "orig_$filename"
|
mv "$filename" "orig_$filename"
|
||||||
mv $temp_name.$extension "$filename"
|
mv $temp_name.$extension "$filename"
|
||||||
printf "${BOLD}Make sure to delete the original video file\n${NORMAL}"
|
printf "${BOLD}Make sure to delete the original video file\n${NORMAL}"
|
||||||
@@ -741,9 +827,12 @@ download_vimeo_vid() {
|
|||||||
local name_format="%(upload_date>%Y-%m-%d)s-shortname-vimeo-%(id)s"
|
local name_format="%(upload_date>%Y-%m-%d)s-shortname-vimeo-%(id)s"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download the video.
|
# Get the video filename.
|
||||||
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
|
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
|
||||||
|
filename=$(remove_extra_spaces "$filename")
|
||||||
|
printf "filename: $filename\n"
|
||||||
|
|
||||||
|
# Download the video.
|
||||||
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
|
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
|
||||||
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
||||||
|
|
||||||
@@ -787,13 +876,14 @@ download_twitter_vid() {
|
|||||||
|
|
||||||
printf "${BOLD}Downloading Twitter vid.${NORMAL}\n"
|
printf "${BOLD}Downloading Twitter vid.${NORMAL}\n"
|
||||||
|
|
||||||
|
local opts=""
|
||||||
|
|
||||||
if [[ $vid_name == "" ]]; then
|
if [[ $vid_name == "" ]]; then
|
||||||
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-twitter-%(id)s"
|
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-twitter-%(id)s"
|
||||||
local opts=""
|
|
||||||
else
|
else
|
||||||
local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-twitter-%(id)s"
|
local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-twitter-%(id)s"
|
||||||
shift 4
|
shift 4
|
||||||
local opts="$@"
|
opts="$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $make_folder == "1" ]]; then
|
if [[ $make_folder == "1" ]]; then
|
||||||
@@ -808,9 +898,12 @@ download_twitter_vid() {
|
|||||||
format="b"
|
format="b"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download the video.
|
# Get the video filename.
|
||||||
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
|
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
|
||||||
|
filename=$(remove_extra_spaces "$filename")
|
||||||
|
printf "filename: $filename\n"
|
||||||
|
|
||||||
|
# Download the video.
|
||||||
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
|
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
|
||||||
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
||||||
|
|
||||||
@@ -839,13 +932,14 @@ download_instagram_vid() {
|
|||||||
|
|
||||||
printf "${BOLD}Downloading Instagram vid.${NORMAL}\n"
|
printf "${BOLD}Downloading Instagram vid.${NORMAL}\n"
|
||||||
|
|
||||||
|
local opts=""
|
||||||
|
|
||||||
if [[ $vid_name == "" ]]; then
|
if [[ $vid_name == "" ]]; then
|
||||||
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-ig-%(id)s"
|
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-ig-%(id)s"
|
||||||
local opts=""
|
|
||||||
else
|
else
|
||||||
local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-ig-%(id)s"
|
local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-ig-%(id)s"
|
||||||
shift 4
|
shift 4
|
||||||
local opts="$@"
|
opts="$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $make_folder == "1" ]]; then
|
if [[ $make_folder == "1" ]]; then
|
||||||
@@ -857,9 +951,12 @@ download_instagram_vid() {
|
|||||||
|
|
||||||
format="b" # best available
|
format="b" # best available
|
||||||
|
|
||||||
# Download the video.
|
# Get the video filename.
|
||||||
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
|
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
|
||||||
|
filename=$(remove_extra_spaces "$filename")
|
||||||
|
printf "filename: $filename\n"
|
||||||
|
|
||||||
|
# Download the video.
|
||||||
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
|
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
|
||||||
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
||||||
|
|
||||||
@@ -903,7 +1000,19 @@ download_mp4() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Download from m3u8 stream to mp4.
|
# Download from m3u8 stream to mp4.
|
||||||
download_from_m3u8() {
|
# You can supply a local file or a URL to the m3u8 file. If the request requires cookies then the easiest way to do it is to
|
||||||
|
# run the ffmpeg command yourself using this as the example format:
|
||||||
|
#
|
||||||
|
# ffmpeg -protocol_whitelist file,https,crypto,tls,tcp -headers $'Cookie: CloudFront-Policy=ayJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly92aWRlby5zdGVsbGFydGlja2V0cy5jb20vb3JnYW5pemF0aW9ucy8yYWQ0YTBhYi1iZWM3LTQ4NjMtYTBmMS0zNjI0N2NjODNkMjMvdHJhbnNjb2RlZC85MWFmYjI4MS0wNy0yMC0yM19LcmF6YW1fUHJlc2VudHMqIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNjkwNDk4ODAwfSwiSXBBZGRyZXNzIjp7IkFXUzpTb3VyY2VJcCI6IjY0LjEzNy4xNDkuMTkzLzMyIn19LCJTdHJlYW1Ub2tlbklkIjoiOTJlMTg2ZjUtZWZiMS00ZDAzLWE0NGQtZTg3YzQ3NzFiODI2IiwiU3RyZWFtVG9rZW5WaWV3ZXJJZCI6Ijg3NzFlMTBhLTcxNjUtNDcxOS1iMjFiLTkwNjljZDgzNzdhYyIsIlN0cmVhbVRva2VuVmlld2VyVHlwZSI6IkN1c3RvbWVyIiwiU3RyZWFtVG9rZW5SZXNvdXJjZUlkIjoiZDY3Mzc4NWMtNDEzNy00MDRhLTkzZjctNjQxN2Q4MmY2NmUxIiwiU3RyZWFtVG9rZW5SZXNvdXJjZVR5cGUiOiJWaWRlb09uRGVtYW5kIn1dfQ__; CloudFront-Signature=H0RwSHRX9y4PIqbAmxtEoGEPbO5da%7EW764sbHBXcPwnSSuq5PcjPM2UuP1YKL%7E92WcRTEiJ9FMDVbxNtPDZea2lCk9txvpHdmn7BBy6JNwKd-%7ED9RKq3SSqB00O8P1VkztKtkALYgn8lq3ihk7Nss0wYE9WxgvNNU30umcP-wSHFtuiGsbArivbWvu639Ku5bkfwm8azXI9hvz5D7OtwSyo3z%7E8trw3rALDwCgHZiqQrEQtfN4NYAWZ%7EuzdcGRgdUVmMQotBHG0WpPDItqBR9RLVel%7EWB0mQOO3Dax9DnGHlBaBs5mdR28NqOj8XCY4pAhguJQlERcANIK2WXm56dA__; CloudFront-Key-Pair-Id=APK3IWIJLRLBNXI2PR4Q\r\n' -i https://video.stellartickets.com/organizations/2ad4a0ac-bec7-4863-a0f1-36247cc83d23/transcoded/91afb281-07-20-23_Krazam_Presents_index_1080p_20230721T024151_1.m3u8 -acodec copy -vcodec copy krazam.mp4
|
||||||
|
#
|
||||||
|
# You can get the cookie header value from the browser's dev tools network
|
||||||
|
# page. I tried adding support to this function so that you can just pass the
|
||||||
|
# cookie value as an arg but it would not work and I don't want to waste more
|
||||||
|
# time on it.
|
||||||
|
#
|
||||||
|
# If you need to debug the http request then add "-v trace" to the command above.
|
||||||
|
#
|
||||||
|
download_mp4_from_m3u8() {
|
||||||
local m3u8_path="$1"
|
local m3u8_path="$1"
|
||||||
local filename="$2"
|
local filename="$2"
|
||||||
|
|
||||||
@@ -913,7 +1022,28 @@ download_from_m3u8() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
printf "${BOLD}Downloading: ${YELLOW}$filename${NORMAL}\n"
|
printf "${BOLD}Downloading: ${YELLOW}$filename${NORMAL}\n"
|
||||||
ffmpeg.exe -protocol_whitelist file,https,crypto,tls,tcp -i $m3u8_path -acodec copy -vcodec copy "${filename}.mp4"
|
ffmpeg.exe -protocol_whitelist file,data,https,crypto,tls,tcp -allowed_extensions ALL -i $m3u8_path -acodec copy -vcodec copy "${filename}.mp4"
|
||||||
|
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
error "Error: failed to download."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Same notes from above regarding cookies/headers.
|
||||||
|
download_aac_from_m3u8() {
|
||||||
|
local m3u8_path="$1"
|
||||||
|
local filename="$2"
|
||||||
|
|
||||||
|
if [[ $m3u8_path == "" || $filename == "" ]]; then
|
||||||
|
error "Usage: <m3u8 path> <filename>"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "${BOLD}Downloading: ${YELLOW}$filename${NORMAL}\n"
|
||||||
|
ffmpeg.exe -protocol_whitelist file,https,crypto,tls,tcp -i $m3u8_path -acodec copy "${filename}.aac"
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
error "Error: failed to download."
|
error "Error: failed to download."
|
||||||
@@ -932,6 +1062,9 @@ alias yt-list-desc='download_youtube_uploads_list 1 '
|
|||||||
|
|
||||||
alias yt='download_youtube_vid "" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
alias yt='download_youtube_vid "" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||||
alias yt-shortname='download_youtube_vid "" $SHORTNAME_ON $TRANSCRIBE_OFF'
|
alias yt-shortname='download_youtube_vid "" $SHORTNAME_ON $TRANSCRIBE_OFF'
|
||||||
|
alias yt-1440='download_youtube_vid "620+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||||
|
alias yt-1440p60='download_youtube_vid "400+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||||
|
alias yt-1440-shortname='download_youtube_vid "620+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||||
alias yt-1080='download_youtube_vid "137+140" $SHORTNAME_OFF $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-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='download_youtube_vid "136+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||||
@@ -939,17 +1072,22 @@ alias yt-720-shortname='download_youtube_vid "136+140" $SHORTNAME_ON $TRANSC
|
|||||||
#TRANSCRIPTION ON
|
#TRANSCRIPTION ON
|
||||||
alias ytt='download_youtube_vid "" $SHORTNAME_OFF $TRANSCRIBE_ON'
|
alias ytt='download_youtube_vid "" $SHORTNAME_OFF $TRANSCRIBE_ON'
|
||||||
alias yt-shortname-t='download_youtube_vid "" $SHORTNAME_ON $TRANSCRIBE_ON'
|
alias yt-shortname-t='download_youtube_vid "" $SHORTNAME_ON $TRANSCRIBE_ON'
|
||||||
|
alias yt-1440-t='download_youtube_vid "620+140" $SHORTNAME_OFF $TRANSCRIBE_ON'
|
||||||
|
alias yt-1440-shortname-t='download_youtube_vid "620+140" $SHORTNAME_ON $TRANSCRIBE_ON'
|
||||||
alias yt-1080-t='download_youtube_vid "137+140" $SHORTNAME_OFF $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-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-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-720-shortname-t='download_youtube_vid "136+140" $SHORTNAME_ON $TRANSCRIBE_ON'
|
||||||
#---------------------------
|
#---------------------------
|
||||||
alias yt-playlist='download_youtube_playlist ""'
|
alias yt-playlist='download_youtube_playlist ""'
|
||||||
|
alias yt-playlist-audio='download_youtube_playlist "140"'
|
||||||
|
alias yt-playlist-1440='download_youtube_playlist "620+140"'
|
||||||
|
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-playlist-list='download_youtube_playlist_list '
|
alias yt-playlist-list='download_youtube_playlist_list '
|
||||||
alias yt-playlist-1080='download_youtube_playlist "137+140"'
|
#---------------------------
|
||||||
alias yt-playlist-720='download_youtube_playlist "136+140"'
|
alias yt-audio='download_youtube_audio'
|
||||||
alias yt-playlist-tiny='download_youtube_playlist "160+140"'
|
|
||||||
alias yt-audio='yt-dlp.exe -f "140"'
|
|
||||||
|
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
# Twitch Vid DL
|
# Twitch Vid DL
|
||||||
@@ -1047,7 +1185,8 @@ alias twitter='download_twitter_vid "" '
|
|||||||
# Misc
|
# Misc
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
alias download-mp4='download_mp4'
|
alias download-mp4='download_mp4'
|
||||||
alias download-from-m3u8='download_from_m3u8'
|
alias download-from-m3u8='download_mp4_from_m3u8'
|
||||||
|
alias download-audio-from-m3u8='download_aac_from_m3u8'
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
# Video Compression
|
# Video Compression
|
||||||
@@ -1067,6 +1206,15 @@ function _compress_video_hard() {
|
|||||||
|
|
||||||
alias compress-video-hard='_compress_video_hard'
|
alias compress-video-hard='_compress_video_hard'
|
||||||
|
|
||||||
|
alias cv='compress-video'
|
||||||
|
alias cvh='compress-video-hard'
|
||||||
|
alias jv='join-video'
|
||||||
|
alias av='analyze-volume'
|
||||||
|
alias aa='analyze-volume'
|
||||||
|
alias nv='normalize-volume'
|
||||||
|
alias na='normalize-volume'
|
||||||
|
alias tv='trim-video'
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
# Git
|
# Git
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
@@ -1077,6 +1225,11 @@ if [[ '${platform,,}' == *'ming'* ]]; then
|
|||||||
alias git="PATH=/usr/bin git"
|
alias git="PATH=/usr/bin git"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Performs a commit amend with the nocheckin prehook disabled.
|
||||||
|
git_amend_nocheckin() {
|
||||||
|
eval "DISABLE_NOCHECKIN=1 git commit --amend"
|
||||||
|
}
|
||||||
|
|
||||||
git_cmd_wrapper() {
|
git_cmd_wrapper() {
|
||||||
# If no args are provided then run `git status -s`
|
# If no args are provided then run `git status -s`
|
||||||
if [[ $# > 0 ]]; then
|
if [[ $# > 0 ]]; then
|
||||||
@@ -1102,6 +1255,7 @@ git_commit_signed() {
|
|||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Performs a commit amend to the head with the nocheckin prehook disabled.
|
||||||
git_fix_nocheckin() {
|
git_fix_nocheckin() {
|
||||||
eval "DISABLE_NOCHECKIN=1 git commit --amend -C HEAD"
|
eval "DISABLE_NOCHECKIN=1 git commit --amend -C HEAD"
|
||||||
}
|
}
|
||||||
@@ -1123,10 +1277,9 @@ git_create_stash_patch() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
alias am='git commit --amend'
|
alias am='git commit --amend'
|
||||||
|
alias amno='git_amend_nocheckin'
|
||||||
alias ama='git commit --amend -C head --author'
|
alias ama='git commit --amend -C head --author'
|
||||||
alias ams='git commit -S --amend' # signed
|
alias ams='git commit -S --amend' # signed
|
||||||
alias ammend='echo "use am instead"'
|
|
||||||
alias amend='echo "use am instead"'
|
|
||||||
alias g='git_cmd_wrapper'
|
alias g='git_cmd_wrapper'
|
||||||
alias ga='git add -A'
|
alias ga='git add -A'
|
||||||
alias gaa='git add -A; gdcc'
|
alias gaa='git add -A; gdcc'
|
||||||
@@ -1170,6 +1323,7 @@ alias gfo='git fetch origin'
|
|||||||
alias gfu='git fetch up'
|
alias gfu='git fetch up'
|
||||||
alias gfm='git fetch origin master'
|
alias gfm='git fetch origin master'
|
||||||
alias gfup='git fetch upstream'
|
alias gfup='git fetch upstream'
|
||||||
|
alias ggcf='git gc --prune=now'
|
||||||
alias ggrep='git log --all --oneline | grep '
|
alias ggrep='git log --all --oneline | grep '
|
||||||
alias gla='git lg --all'
|
alias gla='git lg --all'
|
||||||
alias gl='git lg -30'
|
alias gl='git lg -30'
|
||||||
@@ -1194,9 +1348,10 @@ alias gpo='git push origin'
|
|||||||
alias gpom='git push origin master'
|
alias gpom='git push origin master'
|
||||||
alias gpr='git pull --rebase'
|
alias gpr='git pull --rebase'
|
||||||
alias gpt='git push --tags'
|
alias gpt='git push --tags'
|
||||||
|
alias gptf='git push --tags -f'
|
||||||
alias gpu='git push --set-upstream origin HEAD'
|
alias gpu='git push --set-upstream origin HEAD'
|
||||||
alias gr='git reset'
|
alias gr='git reset'
|
||||||
alias gr1='git reset HEAD^1'
|
alias gr1='git reset HEAD^1; gl'
|
||||||
alias grb='git rebase --autostash'
|
alias grb='git rebase --autostash'
|
||||||
alias grba='git rebase --abort'
|
alias grba='git rebase --abort'
|
||||||
alias grbc='git rebase --continue'
|
alias grbc='git rebase --continue'
|
||||||
@@ -1230,6 +1385,7 @@ alias gsd='git stash drop'
|
|||||||
alias gsl='git stash list'
|
alias gsl='git stash list'
|
||||||
alias gsi='git stash -p'
|
alias gsi='git stash -p'
|
||||||
alias gsp='git stash pop'
|
alias gsp='git stash pop'
|
||||||
|
alias gspm='git stash pop --merge'
|
||||||
alias gsp0='git stash pop stash@{0}'
|
alias gsp0='git stash pop stash@{0}'
|
||||||
alias gsp1='git stash pop stash@{1}'
|
alias gsp1='git stash pop stash@{1}'
|
||||||
alias gsp2='git stash pop stash@{2}'
|
alias gsp2='git stash pop stash@{2}'
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
||||||
"
|
"
|
||||||
" " On-demand loading
|
" " On-demand loading
|
||||||
" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
|
" Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
|
||||||
" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
||||||
"
|
"
|
||||||
" " Using a non-default branch
|
" " Using a non-default branch
|
||||||
|
|||||||
@@ -15,29 +15,32 @@ endif
|
|||||||
|
|
||||||
set background=dark
|
set background=dark
|
||||||
hi clear
|
hi clear
|
||||||
syntax reset
|
if exists("syntax_on")
|
||||||
|
syntax reset
|
||||||
|
endif
|
||||||
|
|
||||||
source $HOME/.vim/colors/utils
|
source $HOME/.vim/colors/utils
|
||||||
let g:colors_name = "campo-dark-blue"
|
let g:colors_name = "campo-dark-blue"
|
||||||
|
|
||||||
" Shared colors
|
" Shared colors
|
||||||
let s:blue = "3699cc"
|
let s:blue = "3699cc"
|
||||||
let s:purple = "ce93d8"
|
let s:purple = "ce93d8"
|
||||||
let s:grey = "b0bec5"
|
let s:grey = "b0bec5"
|
||||||
let s:orange = "ffb74d"
|
let s:orange = "ffb74d"
|
||||||
let s:yellow = "fff176"
|
let s:yellow = "fff176"
|
||||||
let s:green = "88b888"
|
let s:green = "88b888"
|
||||||
let s:red = "ef2929"
|
let s:red = "ef2929"
|
||||||
let s:text = "f1f1e8" " A majority of the syntax will use this.
|
let s:text = "f1f1e8" " A majority of the syntax will use this.
|
||||||
let s:bg = "072730"
|
let s:bg = "072730"
|
||||||
let s:select = "546e8f"
|
let s:select = "546e8f"
|
||||||
let s:window = "37474f"
|
let s:window = "37474f"
|
||||||
let s:comment = "5dea82"
|
let s:comment = "5dea82"
|
||||||
let s:tab = "03404a"
|
let s:annotated_note = "8dea82"
|
||||||
let s:error = "e40e0e"
|
let s:tab = "03404a"
|
||||||
let s:proc = "0eefcb"
|
let s:error = "e40e0e"
|
||||||
let s:warn = "dcd53e"
|
let s:proc = "0eefcb"
|
||||||
let s:spell = "aaf53e"
|
let s:warn = "dcd53e"
|
||||||
|
let s:spell = "aaf53e"
|
||||||
|
|
||||||
" Vim
|
" Vim
|
||||||
call X("Normal", s:text, s:bg, "")
|
call X("Normal", s:text, s:bg, "")
|
||||||
@@ -83,7 +86,7 @@ call X("Identifier", s:grey, "", "none")
|
|||||||
call X("Statement", s:text, "", "") " 'return', 'goto', 'case', 'break', etc
|
call X("Statement", s:text, "", "") " 'return', 'goto', 'case', 'break', etc
|
||||||
call X("Conditional", s:text, "", "")
|
call X("Conditional", s:text, "", "")
|
||||||
call X("Repeat", s:text, "", "") " 'for' and 'while'
|
call X("Repeat", s:text, "", "") " 'for' and 'while'
|
||||||
call X("Structure", "ae90ea", "", "")
|
call X("Structure", "ae90ea", "", "") " enum, struct, union
|
||||||
call X("Function", s:proc, "", "")
|
call X("Function", s:proc, "", "")
|
||||||
call X("Constant", s:text, "", "") " Constants, e.g. SOME_CONST
|
call X("Constant", s:text, "", "") " Constants, e.g. SOME_CONST
|
||||||
call X("Boolean", s:text, "", "") " true, false
|
call X("Boolean", s:text, "", "") " true, false
|
||||||
@@ -96,11 +99,12 @@ call X("Define", "a5bce4", "", "none")
|
|||||||
call X("Include", s:text, "", "") " #include in C/C++
|
call X("Include", s:text, "", "") " #include in C/C++
|
||||||
call X("Number", s:text, "", "")
|
call X("Number", s:text, "", "")
|
||||||
|
|
||||||
" Notes
|
" Notes and annotated comment text
|
||||||
call X("Todo", "b8fbb0", s:bg, "underline")
|
call X("MyTitle", s:text, "", "bold") " // # Some Title
|
||||||
call X("Bugs", "d8fbb0", s:bg, "standout")
|
call X("MyAnnotatedNote", s:text, "", "bold") " // @incomplete
|
||||||
call X("Notes", "ffffff", s:bg, "standout")
|
call X("MyNote", s:annotated_note, "", "standout") " // NOTE:, IDEA:, TODO:
|
||||||
call X("Notices", s:warn, s:bg, "bold")
|
call X("MyEmphasis", s:yellow, "", "bold") " // WARNING:, IMPORTANT:
|
||||||
|
call X("MyBug", s:red, "", "standout") " // FIXME:, BUG:, DEPRECATED:
|
||||||
|
|
||||||
" Build markers
|
" Build markers
|
||||||
call X("BuildError", s:error, s:bg, "bold")
|
call X("BuildError", s:error, s:bg, "bold")
|
||||||
@@ -123,31 +127,6 @@ call X("cStorageClass", s:text, "", "")
|
|||||||
call X("cConditional", s:text, "", "")
|
call X("cConditional", s:text, "", "")
|
||||||
call X("cRepeat", s:text, "", "")
|
call X("cRepeat", s:text, "", "")
|
||||||
|
|
||||||
" Python Highlighting
|
|
||||||
call X("pythonInclude", s:red, "", "")
|
|
||||||
call X("pythonStatement", s:blue, "", "")
|
|
||||||
call X("pythonConditional", s:purple, "", "")
|
|
||||||
call X("pythonRepeat", s:purple, "", "")
|
|
||||||
call X("pythonException", s:purple, "", "")
|
|
||||||
call X("pythonFunction", s:proc, "", "")
|
|
||||||
call X("pythonSelf", s:grey, "", "")
|
|
||||||
call X("pythonOperator", s:purple, "", "")
|
|
||||||
call X("pythonExtraOperator", s:purple, "", "")
|
|
||||||
call X("pythonClass", s:proc, "", "")
|
|
||||||
call X("pythonDecorator", s:orange, "", "")
|
|
||||||
call X("pythonDocstring", s:comment, "", "")
|
|
||||||
call X("pythonBuiltinObj", s:yellow, "", "")
|
|
||||||
call X("pythonBuiltinType", s:orange, "", "")
|
|
||||||
call X("pythonNumber", s:orange, "", "")
|
|
||||||
|
|
||||||
" JS Highlighting
|
|
||||||
call X("javaScriptBraces", s:text, "", "")
|
|
||||||
call X("javaScriptFunction", s:purple, "", "")
|
|
||||||
call X("javaScriptConditional", s:purple, "", "")
|
|
||||||
call X("javaScriptRepeat", s:purple, "", "")
|
|
||||||
call X("javaScriptNumber", s:orange, "", "")
|
|
||||||
call X("javaScriptMember", s:orange, "", "")
|
|
||||||
|
|
||||||
" HTML Highlighting
|
" HTML Highlighting
|
||||||
call X("htmlTag", s:text, "", "")
|
call X("htmlTag", s:text, "", "")
|
||||||
call X("htmlTagName", s:text, "", "")
|
call X("htmlTagName", s:text, "", "")
|
||||||
|
|||||||
136
.vim/colors/campo-dark-earth.vim
Normal file
136
.vim/colors/campo-dark-earth.vim
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
" A simple dark earth-tone vim colorscheme.
|
||||||
|
" Created by Michael Campagnaro (https://git.michael.is)
|
||||||
|
|
||||||
|
if has('termguicolors')
|
||||||
|
" Supports 24-bit color range
|
||||||
|
set termguicolors
|
||||||
|
else
|
||||||
|
echoerr "This theme requires 'termguicolors' support!"
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !has("gui_running") && &t_Co != 88 && &t_Co != 256
|
||||||
|
echoerr "Don't have expected color support!"
|
||||||
|
endif
|
||||||
|
|
||||||
|
set background=dark
|
||||||
|
hi clear
|
||||||
|
if exists("syntax_on")
|
||||||
|
syntax reset
|
||||||
|
endif
|
||||||
|
|
||||||
|
source $HOME/.vim/colors/utils
|
||||||
|
let g:colors_name = "campo-dark-earth"
|
||||||
|
|
||||||
|
" Shared colors
|
||||||
|
let s:blue = "3699cc"
|
||||||
|
let s:purple = "ce93d8"
|
||||||
|
let s:grey = "b0bec5"
|
||||||
|
let s:orange = "ffb74d"
|
||||||
|
let s:yellow = "fff176"
|
||||||
|
let s:green = "88b888"
|
||||||
|
let s:red = "ef2929"
|
||||||
|
let s:text = "e5d8d0" " A majority of the syntax will use this.
|
||||||
|
let s:bg = "24252a"
|
||||||
|
let s:select = "614853"
|
||||||
|
let s:window = "1f2126"
|
||||||
|
let s:comment = "888984"
|
||||||
|
let s:annotated_note = "aaaba6"
|
||||||
|
let s:tab = "3d2a38"
|
||||||
|
let s:error = "e40e0e"
|
||||||
|
let s:proc = s:text
|
||||||
|
let s:warn = "dcd53e"
|
||||||
|
let s:spell = "aaf53e"
|
||||||
|
let s:soft_red = "9a5d6e"
|
||||||
|
let s:cursor_line = "2a2a2d"
|
||||||
|
|
||||||
|
" Vim
|
||||||
|
call X("Normal", s:text, s:bg, "")
|
||||||
|
call X("LineNr", s:comment, "", "")
|
||||||
|
call X("NonText", s:text, "", "")
|
||||||
|
call X("SpecialKey", s:blue, "", "")
|
||||||
|
call X("Search", s:text, s:select, "")
|
||||||
|
call X("TabLineSel", s:text, s:bg, "bold")
|
||||||
|
call X("TabLine", "dddddd", s:tab, "none")
|
||||||
|
call X("TabLineFill", "", s:tab, "none") " The tab line region that doesn't contain tab entries.
|
||||||
|
call X("StatusLine", s:window, s:text, "reverse")
|
||||||
|
call X("StatusLineNC", s:window, s:comment, "reverse")
|
||||||
|
call X("VertSplit", s:window, s:window, "none")
|
||||||
|
call X("Visual", "", s:select, "")
|
||||||
|
call X("Directory", s:blue, "", "")
|
||||||
|
call X("ModeMsg", s:green, "", "")
|
||||||
|
call X("MoreMsg", s:green, "", "")
|
||||||
|
call X("Question", s:green, "", "")
|
||||||
|
call X("MatchParen", "", s:select, "")
|
||||||
|
call X("Folded", s:comment, s:bg, "")
|
||||||
|
call X("FoldColumn", s:comment, s:bg, "")
|
||||||
|
call X("SpellBad", s:spell, s:bg, "bold")
|
||||||
|
call X("SpellCap", s:text, s:bg, "") " A word that should start with a capital
|
||||||
|
call X("SpellLocal", s:spell, s:bg, "bold") " Correctly spelled but used in another region.
|
||||||
|
call X("SpellRare", s:text, s:bg, "") " A correctly spelled that is hardly ever used. Don't care about this.
|
||||||
|
call X("ErrorMsg", s:error, s:bg, "bold")
|
||||||
|
if version >= 700
|
||||||
|
call X("PMenu", s:text, s:select, "none") " Autocompletion menu
|
||||||
|
call X("PMenuSel", s:text, "926975", "bold") " Selected autocompletion item
|
||||||
|
call X("SignColumn", "", s:bg, "none")
|
||||||
|
call X("CursorLine", "", s:cursor_line, "none") " Horizontal line at the cursor.
|
||||||
|
call X("CursorColumn", "", s:cursor_line, "none") " Vertical line at the cursor.
|
||||||
|
end
|
||||||
|
if version >= 703
|
||||||
|
call X("ColorColumn", "", s:cursor_line, "none") " Vertical line set by colorcolumn option.
|
||||||
|
end
|
||||||
|
|
||||||
|
" Standard Highlighting
|
||||||
|
call X("Comment", s:comment, "", "")
|
||||||
|
call X("Title", s:comment, "", "")
|
||||||
|
call X("Cursor", "", s:text, "")
|
||||||
|
call X("Identifier", s:soft_red, "", "none")
|
||||||
|
call X("Statement", s:soft_red, "", "") " 'return', 'goto', 'case', 'break', etc
|
||||||
|
call X("Conditional", s:soft_red, "", "")
|
||||||
|
call X("Repeat", s:text, "", "") " 'for' and 'while'
|
||||||
|
call X("Structure", s:soft_red, "", "") " enum, struct, union
|
||||||
|
call X("Function", s:proc, "", "")
|
||||||
|
call X("Constant", s:text, "", "") " Constants, e.g. SOME_CONST
|
||||||
|
call X("Boolean", s:text, "", "") " true, false
|
||||||
|
call X("String", "bba76a", "", "")
|
||||||
|
call X("Special", s:text, "", "")
|
||||||
|
call X("PreProc", s:text, "", "")
|
||||||
|
call X("Operator", s:text, "", "none")
|
||||||
|
call X("Type", s:text, "", "") " Data types
|
||||||
|
call X("Define", s:text, "", "none")
|
||||||
|
call X("Include", s:text, "", "") " #include in C/C++
|
||||||
|
call X("Number", s:soft_red, "", "")
|
||||||
|
|
||||||
|
" Notes and annotated comment text
|
||||||
|
call X("MyTitle", s:annotated_note, "", "bold") " // # Some Title
|
||||||
|
call X("MyAnnotatedNote", s:annotated_note, "", "bold") " // @incomplete
|
||||||
|
call X("MyNote", s:soft_red, "", "standout") " // NOTE:, IDEA:, TODO:
|
||||||
|
call X("MyEmphasis", s:yellow, "", "bold") " // WARNING:, IMPORTANT:
|
||||||
|
call X("MyBug", s:red, "", "standout") " // FIXME:, BUG:, DEPRECATED:
|
||||||
|
|
||||||
|
" Build markers
|
||||||
|
call X("BuildError", s:error, s:bg, "bold")
|
||||||
|
call X("BuildWarn", s:warn, s:bg, "bold")
|
||||||
|
call X("BuildInfo", s:text, s:bg, "bold")
|
||||||
|
|
||||||
|
" Jai Highlighting
|
||||||
|
call X("jaiVariableDeclaration", s:text, "", "")
|
||||||
|
call X("jaiDirective", s:soft_red, "", "")
|
||||||
|
|
||||||
|
" airblade/vim-gitgutter
|
||||||
|
call X("GitGutterAdd", s:green, "", "")
|
||||||
|
call X("GitGutterDelete", s:red, "", "")
|
||||||
|
call X("GitGutterChange", s:yellow, "", "")
|
||||||
|
call X("GitGutterChangeDelete", s:orange, "", "")
|
||||||
|
|
||||||
|
" C Highlighting
|
||||||
|
call X("cType", s:text, "", "")
|
||||||
|
call X("cStorageClass", s:text, "", "")
|
||||||
|
call X("cConditional", s:text, "", "")
|
||||||
|
call X("cRepeat", s:text, "", "")
|
||||||
|
|
||||||
|
" Diff Highlighting
|
||||||
|
call X("DiffAdd", s:window, s:green, "none")
|
||||||
|
call X("DiffDelete", s:window, s:red, "none")
|
||||||
|
call X("DiffChange", s:window, s:yellow, "none")
|
||||||
|
call X("DiffText", s:bg, s:yellow, "none")
|
||||||
|
|
||||||
@@ -5,6 +5,8 @@
|
|||||||
" The theme file original copied from the Tomorrow theme.
|
" The theme file original copied from the Tomorrow theme.
|
||||||
" See https://github.com/chriskempson/vim-tomorrow-theme.git for it.
|
" See https://github.com/chriskempson/vim-tomorrow-theme.git for it.
|
||||||
" Hex color conversion functions borrowed from the theme "Desert256".
|
" Hex color conversion functions borrowed from the theme "Desert256".
|
||||||
|
"
|
||||||
|
" @todo convert to new format (see campo-dark-blue.vim)
|
||||||
|
|
||||||
if has('termguicolors')
|
if has('termguicolors')
|
||||||
" Supports 24-bit color range
|
" Supports 24-bit color range
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
" Hex color conversion functions borrowed from the theme "Desert256".
|
" Hex color conversion functions borrowed from the theme "Desert256".
|
||||||
|
|
||||||
" @TODO port these colors over to a copy of campo-dark-greyscale so that I
|
" @TODO port these colors over to a copy of campo-dark-greyscale so that I
|
||||||
" have better control over the C syntax highlighting.
|
" have better control over the C syntax highlighting. And use the improved
|
||||||
|
" format used in campo-dark-blue.vim
|
||||||
|
|
||||||
|
|
||||||
if has('termguicolors')
|
if has('termguicolors')
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
" Version: 1.0
|
" Version: 1.0
|
||||||
"
|
"
|
||||||
" Hex color conversion functions borrowed from the theme "Desert256".
|
" Hex color conversion functions borrowed from the theme "Desert256".
|
||||||
|
"
|
||||||
|
" @todo convert to new format (see campo-dark-blue.vim)
|
||||||
|
|
||||||
if has('termguicolors')
|
if has('termguicolors')
|
||||||
" Supports 24-bit color range
|
" Supports 24-bit color range
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
" A very simple light colorscheme.
|
" A very simple light colorscheme.
|
||||||
" Maintainer: Michael Campagnaro <mikecampo@gmail.com>
|
" Maintainer: Michael Campagnaro <mikecampo@gmail.com>
|
||||||
" Version: 1.0
|
" Version: 1.0
|
||||||
|
"
|
||||||
|
|
||||||
if has('termguicolors')
|
if has('termguicolors')
|
||||||
" Supports 24-bit color range
|
" Supports 24-bit color range
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
" The theme file original copied from the Tomorrow theme.
|
" The theme file original copied from the Tomorrow theme.
|
||||||
" See https://github.com/chriskempson/vim-tomorrow-theme.git for it.
|
" See https://github.com/chriskempson/vim-tomorrow-theme.git for it.
|
||||||
" Hex color conversion functions borrowed from the theme "Desert256".
|
" Hex color conversion functions borrowed from the theme "Desert256".
|
||||||
|
"
|
||||||
|
" @todo convert to new format (see campo-dark-blue.vim)
|
||||||
|
|
||||||
let g:campo_theme_use_rainbow_parens = 1
|
let g:campo_theme_use_rainbow_parens = 1
|
||||||
|
|
||||||
@@ -13,7 +15,7 @@ let s:foreground = "263238"
|
|||||||
let s:background = "fbfbfb"
|
let s:background = "fbfbfb"
|
||||||
let s:selection = "e3fc8d"
|
let s:selection = "e3fc8d"
|
||||||
let s:line = "d5d5d5"
|
let s:line = "d5d5d5"
|
||||||
let s:comment = "7c7c7c"
|
let s:comment = "4c4c4c"
|
||||||
let s:red = "d62a28"
|
let s:red = "d62a28"
|
||||||
let s:orange = "ff7800"
|
let s:orange = "ff7800"
|
||||||
let s:yellow = "eab700"
|
let s:yellow = "eab700"
|
||||||
@@ -294,13 +296,14 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256
|
|||||||
call <SID>X("Number", s:black, "", "")
|
call <SID>X("Number", s:black, "", "")
|
||||||
"call <SID>X("Ignore", "666666", "", "")
|
"call <SID>X("Ignore", "666666", "", "")
|
||||||
|
|
||||||
" Custom TODO/NOTE colors
|
" Notes and annotated comment text
|
||||||
call <SID>X("Todo", s:red, s:background, "underline")
|
call <SID>X("MyTitle", s:foreground, "", "bold") " // # Some Title
|
||||||
call <SID>X("Bugs", s:red, s:background, "standout")
|
call <SID>X("MyAnnotatedNote", s:foreground, "", "bold") " // @incomplete
|
||||||
call <SID>X("Notes","666666", "ffffff","bold")
|
call <SID>X("MyNote", "", s:black, "standout") " // NOTE:, IDEA:, TODO:
|
||||||
call <SID>X("Notices","dcd53e",s:background,"bold")
|
call <SID>X("MyEmphasis", s:orange, "", "bold,standout") " // WARNING:, IMPORTANT:
|
||||||
call <SID>X("ErrorMsg", s:error_msg_foreground, s:error_msg_background, "underline")
|
call <SID>X("MyBug", s:red, "", "standout") " // FIXME:, BUG:, DEPRECATED:
|
||||||
|
|
||||||
|
call <SID>X("ErrorMsg", s:error_msg_foreground, s:error_msg_background, "underline")
|
||||||
|
|
||||||
" Vim Highlighting
|
" Vim Highlighting
|
||||||
call <SID>X("vimCommand", s:blue, "", "none")
|
call <SID>X("vimCommand", s:blue, "", "none")
|
||||||
|
|||||||
621
.vimrc
621
.vimrc
@@ -13,7 +13,9 @@
|
|||||||
" @incomplete Add setup steps (plugins, cache setup, search tool, etc).
|
" @incomplete Add setup steps (plugins, cache setup, search tool, etc).
|
||||||
"-----------------------------------------------------------------------------------------------------------------------
|
"-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
let g:campo_vimrc_initialized = 0 " Will be set to 1 at the end of the file. Can be used to avoid changes on subsequent vimrc reloads.
|
if !exists("g:campo_vimrc_initialized")
|
||||||
|
let g:campo_vimrc_initialized = 0 " Will be set to 1 at the end of the file. Can be used to avoid changes on subsequent vimrc reloads.
|
||||||
|
endif
|
||||||
|
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
" @note If the file contains a BOM then vim will automatically set `bomb` for the buffer so that the BOM is written out again.
|
" @note If the file contains a BOM then vim will automatically set `bomb` for the buffer so that the BOM is written out again.
|
||||||
@@ -27,7 +29,10 @@ let g:vim_dir = $HOME . "/.vim"
|
|||||||
let mapleader=","
|
let mapleader=","
|
||||||
|
|
||||||
fu! IsWindows()
|
fu! IsWindows()
|
||||||
if s:uname =~ "mingw" || s:uname =~ "msys"
|
if s:uname =~? "mingw" || s:uname =~? "msys"
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
if has("win64") || has("win32") || has("win16")
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
return 0
|
return 0
|
||||||
@@ -83,7 +88,6 @@ let g:quickfix_pane_height = 20
|
|||||||
let g:campo_light_dark_mode = 'dark' " Start vim with the dark theme. Set to 'light' for the light theme.
|
let g:campo_light_dark_mode = 'dark' " Start vim with the dark theme. Set to 'light' for the light theme.
|
||||||
let g:campo_dark_theme = 'campo-dark-simple' "'campo-dark-blue'
|
let g:campo_dark_theme = 'campo-dark-simple' "'campo-dark-blue'
|
||||||
let g:campo_light_theme = 'campo-light-simple' "'campo-light'
|
let g:campo_light_theme = 'campo-light-simple' "'campo-light'
|
||||||
let g:campo_theme_use_rainbow_parens = 1
|
|
||||||
|
|
||||||
|
|
||||||
"##################################################################################
|
"##################################################################################
|
||||||
@@ -140,7 +144,6 @@ let g:campo_files_to_force_stripping_trailing_whitespace = []
|
|||||||
" let g:campo_custom_search_args = \"-g \"!3rd_party/*\" -tc"
|
" let g:campo_custom_search_args = \"-g \"!3rd_party/*\" -tc"
|
||||||
let g:campo_custom_search_args = ""
|
let g:campo_custom_search_args = ""
|
||||||
|
|
||||||
|
|
||||||
"##################################################################################
|
"##################################################################################
|
||||||
" CTAGS
|
" CTAGS
|
||||||
"##################################################################################
|
"##################################################################################
|
||||||
@@ -162,7 +165,7 @@ let g:campo_extensions_that_run_ctags = ['c','cpp','h','hpp','inc','cs','py','as
|
|||||||
" recursive crawl.
|
" recursive crawl.
|
||||||
" @note The CreateCtags function will always ignore .git and node_modules
|
" @note The CreateCtags function will always ignore .git and node_modules
|
||||||
" regardless of this variable's value.
|
" regardless of this variable's value.
|
||||||
let g:campo_ctags_exclude = ['*.txt', '*.config', '.cache']
|
let g:campo_ctags_exclude = ['*.txt', '*.config', '.cache', 'run_tree', 'build']
|
||||||
|
|
||||||
" This is included in the ctags autocmd args. You can use this to customize
|
" This is included in the ctags autocmd args. You can use this to customize
|
||||||
" how ctags are built.
|
" how ctags are built.
|
||||||
@@ -171,8 +174,10 @@ let g:campo_ctags_exclude = ['*.txt', '*.config', '.cache']
|
|||||||
" * Create tags for specific langauges: `let g:campo_custom_ctags_args = '--languages=C,C++,Elixir'
|
" * Create tags for specific langauges: `let g:campo_custom_ctags_args = '--languages=C,C++,Elixir'
|
||||||
" * You can see a list of languages with `ctags --list-languages`
|
" * You can see a list of languages with `ctags --list-languages`
|
||||||
" * For C# you have to escape the ampersand like so: `--languages=C\\#`
|
" * For C# you have to escape the ampersand like so: `--languages=C\\#`
|
||||||
" * Exclude a directory with `let g:campo_custom_ctags_args = '--exclude=3rd_party'`
|
" * Exclude directories using g:campo_ctags_exclude
|
||||||
let g:campo_custom_ctags_args = ""
|
"
|
||||||
|
" We'll do it recursively by default.
|
||||||
|
let g:campo_custom_ctags_args = "-R"
|
||||||
|
|
||||||
|
|
||||||
" Set extra paths to use when searching for ctags files. By default the current
|
" Set extra paths to use when searching for ctags files. By default the current
|
||||||
@@ -222,69 +227,49 @@ let g:campo_jai_metaprogram_args = ''
|
|||||||
|
|
||||||
call plug#begin('~/.vim/plugged')
|
call plug#begin('~/.vim/plugged')
|
||||||
|
|
||||||
"##################################################################################
|
" I've locked the plugins to stable commits. No need to upgrade them unless there are bug fixes.
|
||||||
" MISC
|
|
||||||
"##################################################################################
|
|
||||||
|
|
||||||
Plug 'vim-airline/vim-airline' " Enhanced status/tabline.
|
"""""""""""""""""""
|
||||||
Plug 'embear/vim-localvimrc' " Add a .lvimrc to a folder to override .vimrc config.
|
" # MISC
|
||||||
Plug 'tpope/vim-obsession' " Continuously updated session files (tracks window positions, open folds, etc).
|
"""""""""""""""""""
|
||||||
Plug 'tpope/vim-fugitive' " Git wrapper (I particularly like :Gblame, which I've wrapped as :Blame)
|
Plug 'sir-pinecone/errormarker.vim' " Build error highlighting (requires skywind3000/asyncrun.vim).
|
||||||
Plug 'sir-pinecone/vim-ripgrep' " Fast grep-like search. Requires ripgrep; install Rust package: `cargo install ripgrep`.
|
Plug 'sir-pinecone/vim-ripgrep' " Fast grep-like search. Requires ripgrep; install Rust package: `cargo install ripgrep`.
|
||||||
Plug 'itchyny/vim-cursorword' " Underlines all instances of the symbol under the cursor.
|
Plug 'sir-pinecone/vim-qargs', " For the GlobalReplaceIt function (i.e. search and replace).
|
||||||
Plug 'airblade/vim-gitgutter' " Displays a git diff in the vim gutter and allows staging/unstaging of hunks.
|
Plug 'sir-pinecone/AnsiEsc.vim' " Ansi escape sequences concealed, but highlighted as specified.
|
||||||
Plug 'ctrlpvim/ctrlp.vim' " Fuzzy file, buffer, mru, tag, etc finder.
|
Plug 'sir-pinecone/ctrlp.vim', " Fuzzy file, buffer, mru, tag, etc finder.
|
||||||
Plug 'majutsushi/tagbar' " Display ctags in a window, ordered by scope.
|
Plug 'sir-pinecone/ctrlp-py-matcher' " Significantly speed up ctrlp's fuzzy matcher.
|
||||||
Plug 'tommcdo/vim-lion' " For text alignment, use gl= and gL=
|
Plug 'vim-airline/vim-airline', { 'commit': 'c7460aa' } " Enhanced status/tabline.
|
||||||
Plug 'tpope/tpope-vim-abolish' " Easily search for, substitute, and abbreviate multiple variants of a word. Add them to `vim/after/plugin/abolish.vim`
|
Plug 'embear/vim-localvimrc', { 'commit': '0206f5f' } " Add a .lvimrc to a folder to override .vimrc config.
|
||||||
Plug 'sir-pinecone/errormarker.vim' " Build error highlighting (requires skywind3000/asyncrun.vim).
|
Plug 'tpope/vim-fugitive', { 'commit': '46eaf89' } " Git wrapper (I particularly like :Gblame, which I've wrapped as :Blame)
|
||||||
Plug 'skywind3000/asyncrun.vim' " Async commands.
|
Plug 'tpope/tpope-vim-abolish', { 'commit': 'dcbfe06' } " Search for, substitute, and abbreviate multiple variants of a word. Add to `after/plugin/abolish.vim`
|
||||||
Plug 'nelstrom/vim-qargs' " For the GlobalReplaceIt function (i.e. search and replace).
|
Plug 'tpope/vim-obsession', { 'commit': 'fe9d3e1' } " @flagged for removal. Continuously updated session files (tracks window positions, open folds, etc).
|
||||||
Plug 'editorconfig/editorconfig-vim' " Adds support for .editorconfig files.
|
Plug 'itchyny/vim-cursorword', { 'commit': '74a97c4' } " Underlines all instances of the symbol under the cursor. Requires a ctags file.
|
||||||
|
Plug 'skywind3000/asyncrun.vim', { 'commit': '61cc308' } " (prev stable: 58d23e7) Async commands.
|
||||||
|
Plug 'airblade/vim-gitgutter', { 'commit': 'fe0e8a2' } " Displays a git diff in the vim gutter and allows staging/unstaging of hunks.
|
||||||
|
Plug 'majutsushi/tagbar', { 'commit': '5d6990e' } " Generates ctags on-demand and shows the current file's symbols. Doesn't support existing ctag files, so no Jai support.
|
||||||
|
Plug 'tommcdo/vim-lion', { 'commit': 'ce46593' } " For text alignment, use gl= and gL=
|
||||||
|
Plug 'editorconfig/editorconfig-vim', { 'commit': '95cb75e' } " Adds support for .editorconfig files.
|
||||||
|
|
||||||
" @flagged for removal
|
"""""""""""""""""""
|
||||||
Plug 'sir-pinecone/AnsiEsc.vim' " Ansi escape sequences concealed, but highlighted as specified.
|
" # SYNTAX
|
||||||
|
"""""""""""""""""""
|
||||||
|
Plug 'sir-pinecone/jai.vim' " Jai
|
||||||
|
Plug 'sir-pinecone/fasm.vim' " Flat Assembler
|
||||||
|
Plug 'bfrg/vim-cpp-modern', { 'commit': 'cc7019b' } " C/C++
|
||||||
|
Plug 'elixir-editors/vim-elixir', { 'commit': '6dd03f8' } " Elixir
|
||||||
|
Plug 'pprovost/vim-ps1', { 'commit': '308aac5' } " PowerShell
|
||||||
|
Plug 'tpope/vim-markdown', { 'commit': 'f2b82b7' } " Markdown
|
||||||
|
"Plug 'vim-ruby/vim-ruby' { 'commit': 'f06f069' } " Ruby
|
||||||
|
|
||||||
if IsWindows()
|
"""""""""""""""""""
|
||||||
Plug 'suxpert/vimcaps' " Disable capslock (useful if the OS isn't configured to do so).
|
" # THEMES
|
||||||
endif
|
"""""""""""""""""""
|
||||||
|
Plug 'vim-airline/vim-airline-themes', { 'commit': '04fa4fc' }
|
||||||
"##################################################################################
|
Plug 'dracula/vim', { 'commit': '6495b4f', 'as': 'dracula' }
|
||||||
" COLORS
|
|
||||||
"##################################################################################
|
|
||||||
|
|
||||||
Plug 'luochen1990/rainbow', { 'commit': '1c45e0f' } " Rainbow parens. Locked to an older commit that still works fine on my PC.
|
|
||||||
Plug 'vim-airline/vim-airline-themes'
|
|
||||||
|
|
||||||
if IsWindows()
|
|
||||||
Plug 'godlygeek/csapprox' " Try to make gvim themes look decent on Windows.
|
|
||||||
endif
|
|
||||||
|
|
||||||
Plug 'dracula/vim', { 'as': 'dracula' }
|
|
||||||
|
|
||||||
"/////////////////////////////////////////////////
|
|
||||||
" SYNTAX HIGHLIGHTING
|
|
||||||
"/////////////////////////////////////////////////
|
|
||||||
|
|
||||||
Plug 'rluba/jai.vim' " Jai
|
|
||||||
Plug 'bfrg/vim-cpp-modern' " C/C++
|
|
||||||
Plug 'fedorenchik/fasm.vim' " Flat Assembler
|
|
||||||
Plug 'elixir-editors/vim-elixir' " Elixir
|
|
||||||
Plug 'pprovost/vim-ps1' " PowerShell
|
|
||||||
Plug 'tpope/vim-markdown' " Markdown
|
|
||||||
"Plug 'vim-ruby/vim-ruby' " Ruby
|
|
||||||
"Plug 'fatih/vim-go' " Go
|
|
||||||
"Plug 'rust-lang/rust.vim' " Rust
|
|
||||||
"Plug 'jdonaldson/vaxe' " Haxe
|
|
||||||
|
|
||||||
"
|
|
||||||
"
|
|
||||||
"
|
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
|
|
||||||
|
|
||||||
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||
" #2 BASE CONFIG
|
" #2 BASE CONFIG
|
||||||
@@ -372,14 +357,19 @@ set complete+=kspell " Spell checking autocomplete.
|
|||||||
set complete-=i " Don't scan all included files since it's really slow.
|
set complete-=i " Don't scan all included files since it's really slow.
|
||||||
|
|
||||||
set termguicolors
|
set termguicolors
|
||||||
syntax on " Enable highlighting for syntax
|
|
||||||
|
|
||||||
let g:netrw_dirhistmax = 0 " Disable netrw
|
" Disabled this because it clears my custom syntax highlights (see campoSyntax augroup)
|
||||||
|
" when the vimrc file is resourced. I guess I don't need to set this to have
|
||||||
|
" syntax highlighting. It's probably being enabled by a plugin.
|
||||||
|
"set syntax on
|
||||||
|
|
||||||
set wildmenu
|
set wildmenu
|
||||||
set wildmode=longest,list,full
|
set wildmode=longest,list,full
|
||||||
set wildignore+=*/log/*,*.so,*.swp,*.zip,*/rdoc/*
|
set wildignore+=*/log/*,*.so,*.swp,*.zip,*/rdoc/*
|
||||||
|
|
||||||
|
" Allow <tab> inserts in the command bar to autocomplete, e.g. see <leader>e
|
||||||
|
set wildcharm=<tab>
|
||||||
|
|
||||||
if executable('rg')
|
if executable('rg')
|
||||||
set grepprg=rg\ --vimgrep\ --hidden " Requires ripgrep to be installed.
|
set grepprg=rg\ --vimgrep\ --hidden " Requires ripgrep to be installed.
|
||||||
endif
|
endif
|
||||||
@@ -389,11 +379,10 @@ set listchars=tab:»\ ,trail:·,extends:>,precedes:<,nbsp:+
|
|||||||
|
|
||||||
set timeoutlen=250 ttimeoutlen=0 " Don't set it too low otherwise you won't be able to type use multi-key sequences.
|
set timeoutlen=250 ttimeoutlen=0 " Don't set it too low otherwise you won't be able to type use multi-key sequences.
|
||||||
|
|
||||||
" @fixme might be broken if lowered to 100 from original value of 4000. Will
|
" Keeping this a bit low to make git-gutter updates faster. The original value
|
||||||
" first try 500 and tweak from there.
|
" was 4000. I tried 250 and eventually started seeing some plugin errors
|
||||||
" UPDATE: I lowered this to 250 and eventually started seeing some plugin
|
" related to paren formatting. 800 seems to be the sweet spot.
|
||||||
" errors related to paren formatting. I think 800 might be the sweet spot.
|
set updatetime=800
|
||||||
set updatetime=800 " I lowered this to make git-gutter updates faster.
|
|
||||||
|
|
||||||
" Fix vim's background colour erase - http://snk.tuxfamily.org/log/vim-256color-bce.html
|
" Fix vim's background colour erase - http://snk.tuxfamily.org/log/vim-256color-bce.html
|
||||||
if &term =~ '256color'
|
if &term =~ '256color'
|
||||||
@@ -472,7 +461,7 @@ augroup campoCmds
|
|||||||
" @fixme Reload lvimrc after sourcing this file on a save. I tried calling
|
" @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
|
" 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.
|
" error complaining that the function cannot be created while it's in use.
|
||||||
autocmd BufWritePost .vimrc silent! source $MYVIMRC
|
autocmd BufWritePost $MYVIMRC silent! source $MYVIMRC
|
||||||
autocmd BufWritePost *.vim silent! source $MYVIMRC
|
autocmd BufWritePost *.vim silent! source $MYVIMRC
|
||||||
autocmd BufWritePost ~/.vimrc.private silent! source $MYVIMRC
|
autocmd BufWritePost ~/.vimrc.private silent! source $MYVIMRC
|
||||||
autocmd BufWritePost ~/.vimrc_templates.private silent! source $MYVIMRC
|
autocmd BufWritePost ~/.vimrc_templates.private silent! source $MYVIMRC
|
||||||
@@ -573,9 +562,6 @@ augroup END
|
|||||||
" Suspend vim process and return to the shell. Can return to vim with `fg`.
|
" Suspend vim process and return to the shell. Can return to vim with `fg`.
|
||||||
nnoremap <leader>z <c-z>
|
nnoremap <leader>z <c-z>
|
||||||
|
|
||||||
" Edit a file
|
|
||||||
nnoremap <leader>e :e
|
|
||||||
|
|
||||||
" Open the vimrc file for editing / reload vimrc file.
|
" Open the vimrc file for editing / reload vimrc file.
|
||||||
nnoremap <silent> <leader>ev :vsp $MYVIMRC<cr>
|
nnoremap <silent> <leader>ev :vsp $MYVIMRC<cr>
|
||||||
nnoremap <silent> <leader>pv :vsp ~/.vimrc.private<cr>
|
nnoremap <silent> <leader>pv :vsp ~/.vimrc.private<cr>
|
||||||
@@ -617,22 +603,34 @@ noremap <c-h> <c-w><Left>
|
|||||||
noremap <leader>m :vsplit<cr>
|
noremap <leader>m :vsplit<cr>
|
||||||
noremap <leader>mm :split<cr>
|
noremap <leader>mm :split<cr>
|
||||||
|
|
||||||
" Faster way to activate the 'a' register. This is useful for putting different
|
" Disable treating special characters as regex when doing searches as it's so
|
||||||
" lines of text into the 'a' register and then pasting it as a group.
|
" fucking annoying having to escape them, particularly periods and asterisk.
|
||||||
" You need to first use `<leader>a` and then subsequent use is <leader>A.
|
" This is done by setting the 'very nomagic' setting \V.
|
||||||
" The paste command will use this content until you do something with a
|
nnoremap / /\V
|
||||||
" different register. You can later paste the 'a' contents using `<leader>a p`
|
|
||||||
|
"-----------------------------------------------------
|
||||||
|
" 'a' register helpers
|
||||||
|
"
|
||||||
|
" Faster way to activate the 'a' named register. These registers can be used
|
||||||
|
" for various operations like yanking (copying), deleting, and pasting text.
|
||||||
|
" Each register is identified by a single character. For example, there are
|
||||||
|
" named registers 'a' to 'z', where text yanked or deleted can be specifically
|
||||||
|
" stored and later retrieved.
|
||||||
|
"
|
||||||
|
" First activate the register with <leader>a and then do your yank, delete or
|
||||||
|
" paste. Subsequent yanks into <leader>a will overwrite existing data. You can
|
||||||
|
" append to the register by using <leader>aa
|
||||||
|
"
|
||||||
|
|
||||||
" This overwrites the contents of a.
|
" This overwrites the contents of a.
|
||||||
noremap <leader>a "a
|
noremap <leader>a "a
|
||||||
|
|
||||||
" This appends to a.
|
" This appends to a.
|
||||||
noremap <leader>aa "A
|
noremap <leader>aa "A
|
||||||
|
"-----------------------------------------------------
|
||||||
|
|
||||||
" Backward replace word including cursor character.
|
" Backward replace word including cursor character.
|
||||||
noremap <leader>d cvb
|
noremap <leader>d cvb
|
||||||
" Forward replace word.
|
|
||||||
noremap <leader>e cw
|
|
||||||
|
|
||||||
" Allow fast pasting by accessing the system clipboard register.
|
" Allow fast pasting by accessing the system clipboard register.
|
||||||
noremap <leader>p "+p
|
noremap <leader>p "+p
|
||||||
@@ -658,7 +656,7 @@ vnoremap p "_dP
|
|||||||
|
|
||||||
" Switch between C++ source and header files.
|
" Switch between C++ source and header files.
|
||||||
noremap <leader>v :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR>
|
noremap <leader>v :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR>
|
||||||
"noremap <leader>vv :e %:p:s,.h$,.X123X,:s,.c$,.h,:s,.X123X$,.c,<CR>
|
noremap <leader>vv :e %:p:s,.h$,.X123X,:s,.c$,.h,:s,.X123X$,.c,<CR>
|
||||||
"noremap <leader>vvv :e %:p:s,.h$,.X123X,:s,.cc$,.h,:s,.X123X$,.cc,<CR>
|
"noremap <leader>vvv :e %:p:s,.h$,.X123X,:s,.cc$,.h,:s,.X123X$,.cc,<CR>
|
||||||
|
|
||||||
" Replace all instances of the highlighted text with whatever you enter.
|
" Replace all instances of the highlighted text with whatever you enter.
|
||||||
@@ -688,17 +686,19 @@ fu! CreateCtags()
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Abort if we're editing a text file. This won't be an exhaustive
|
" Abort if the file is in a root drive directory because we don't want to recurse across the entire drive!
|
||||||
" filter. We can restrict what goes into the tag file
|
|
||||||
" First determine if we're in a root drive directory. If we are then
|
|
||||||
" we bail because we don't want to recurse across the entire drive!
|
|
||||||
let l:path = expand('%:p:h')
|
let l:path = expand('%:p:h')
|
||||||
let l:path_without_slashes = substitute(l:path, "/", "", "g")
|
if IsRootDrive(l:path)
|
||||||
if (strchars(l:path) - strchars(l:path_without_slashes)) <= 1
|
|
||||||
call PrintError("Not going to run ctags because the file is in a root drive directory")
|
call PrintError("Not going to run ctags because the file is in a root drive directory")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Abort if the file is in the home directory for the same reason as above.
|
||||||
|
if l:path == expand('$HOME')
|
||||||
|
call PrintError("Not going to run ctags because the file is in the home directory")
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
" Always ignore .git and node_modules
|
" Always ignore .git and node_modules
|
||||||
let g:campo_ctags_exclude = g:campo_ctags_exclude + ['.git', 'node_modules']
|
let g:campo_ctags_exclude = g:campo_ctags_exclude + ['.git', 'node_modules']
|
||||||
let l:exclude_list = ""
|
let l:exclude_list = ""
|
||||||
@@ -764,6 +764,14 @@ call Cabbrev('wq', 'call WriteCurrentFileAndCreateCtagsThenQuit()')
|
|||||||
call Cabbrev('Wq', 'call WriteCurrentFileAndCreateCtagsThenQuit()')
|
call Cabbrev('Wq', 'call WriteCurrentFileAndCreateCtagsThenQuit()')
|
||||||
call Cabbrev('WQ', 'call WriteCurrentFileAndCreateCtagsThenQuit()')
|
call Cabbrev('WQ', 'call WriteCurrentFileAndCreateCtagsThenQuit()')
|
||||||
|
|
||||||
|
" Faster way to open a file in the same directory.
|
||||||
|
" <tab> will autocomplete the expansion here because we set wildcharm to <tab>.
|
||||||
|
nnoremap <leader>e :e %:p:h/<tab>
|
||||||
|
" Jai folders
|
||||||
|
nnoremap <leader>ee :e <C-r>=g:campo_jai_path<CR>/<tab>
|
||||||
|
nnoremap <leader>em :e <C-r>=g:campo_jai_path<CR>/modules/<tab>
|
||||||
|
nnoremap <leader>eh :e <C-r>=g:campo_jai_path<CR>/how_to/<tab>
|
||||||
|
|
||||||
nnoremap <leader>w :call WriteCurrentFileAndCreateCtags()<cr>
|
nnoremap <leader>w :call WriteCurrentFileAndCreateCtags()<cr>
|
||||||
nnoremap <leader>x :call WriteCurrentFileAndCreateCtagsThenQuit()<cr>
|
nnoremap <leader>x :call WriteCurrentFileAndCreateCtagsThenQuit()<cr>
|
||||||
nnoremap <leader>q :q<cr>
|
nnoremap <leader>q :q<cr>
|
||||||
@@ -915,6 +923,8 @@ noremap <leader>gm :call CtrlP_JaiSearch('modules')<cr> " Search in Jai modules
|
|||||||
noremap <leader>gh :call CtrlP_JaiSearch('how_to')<cr> " Search in Jai how_to
|
noremap <leader>gh :call CtrlP_JaiSearch('how_to')<cr> " Search in Jai how_to
|
||||||
noremap <leader>ge :call CtrlP_JaiSearch('examples')<cr> " Search in Jai examples
|
noremap <leader>ge :call CtrlP_JaiSearch('examples')<cr> " Search in Jai examples
|
||||||
|
|
||||||
|
" @note we're using a modified version of ctrlp that removes duplicate tags
|
||||||
|
" when using multiple tag files. See https://github.com/sir-pinecone/ctrlp.vim/commit/5cceab
|
||||||
let g:ctrlp_map = '<leader>f'
|
let g:ctrlp_map = '<leader>f'
|
||||||
let g:ctrlp_cmd = 'CtrlPTag' " Search tags by default.
|
let g:ctrlp_cmd = 'CtrlPTag' " Search tags by default.
|
||||||
let g:ctrlp_by_filename = 1 " File search by filename as opposed to full path.
|
let g:ctrlp_by_filename = 1 " File search by filename as opposed to full path.
|
||||||
@@ -925,6 +935,7 @@ let g:ctrlp_working_path_mode = 'ra' " Search from nearest ancestor of the curre
|
|||||||
let g:ctrlp_switch_buffer = 'et' " If a file is already open, open it again in a new pane instead of switching to the existing pane
|
let g:ctrlp_switch_buffer = 'et' " If a file is already open, open it again in a new pane instead of switching to the existing pane
|
||||||
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
|
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
|
||||||
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard'] " If a git repo, use checked in files (ignore things in .gitignore); fallback to globpath()
|
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard'] " If a git repo, use checked in files (ignore things in .gitignore); fallback to globpath()
|
||||||
|
let g:ctrlp_match_func = { 'match': 'pymatcher#PyMatch' }
|
||||||
|
|
||||||
"##################################################################################
|
"##################################################################################
|
||||||
" GIT
|
" GIT
|
||||||
@@ -948,41 +959,6 @@ let g:clojure_fuzzy_indent_blacklist = ['-fn$', '\v^with-%(meta|out-str|loading-
|
|||||||
"##################################################################################
|
"##################################################################################
|
||||||
"let g:rustfmt_autosave = 1 " auto run rust formatter when saving
|
"let g:rustfmt_autosave = 1 " auto run rust formatter when saving
|
||||||
|
|
||||||
"##################################################################################
|
|
||||||
" RAINBOW
|
|
||||||
"##################################################################################
|
|
||||||
let g:rainbow_active = 1 " Always on
|
|
||||||
let s:light_rainbow = ['red', 'green', 'magenta', 'cyan', 'yellow', 'white', 'gray', 'blue']
|
|
||||||
let s:dark_rainbow = ['darkblue', 'red', 'black', 'darkgreen', 'darkyellow', 'darkred', 'darkgray']
|
|
||||||
let s:rainbow_theme = g:campo_light_dark_mode
|
|
||||||
|
|
||||||
fu! UpdateRainbowConf()
|
|
||||||
let g:rainbow_conf = {
|
|
||||||
\ 'ctermfgs': (s:rainbow_theme == "light"? s:dark_rainbow : s:light_rainbow)
|
|
||||||
\}
|
|
||||||
"\ 'separately': {
|
|
||||||
"\ '*': 0, " Disable all
|
|
||||||
"\ 'c++': {} " Only enable c++
|
|
||||||
"\ }
|
|
||||||
endfu
|
|
||||||
|
|
||||||
call UpdateRainbowConf()
|
|
||||||
|
|
||||||
fu! ReloadRainbow()
|
|
||||||
if g:campo_theme_use_rainbow_parens
|
|
||||||
if exists(':RainbowToggle')
|
|
||||||
call UpdateRainbowConf()
|
|
||||||
call rainbow#clear() | call rainbow#hook()
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let g:rainbow_active = 0
|
|
||||||
if exists(':RainbowToggle')
|
|
||||||
call UpdateRainbowConf()
|
|
||||||
call rainbow#clear()
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfu
|
|
||||||
|
|
||||||
|
|
||||||
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||
@@ -995,8 +971,25 @@ endfu
|
|||||||
" COLORS
|
" COLORS
|
||||||
"###########################################################################
|
"###########################################################################
|
||||||
|
|
||||||
exec "autocmd ColorScheme " . g:campo_dark_theme . " call ReloadRainbow()"
|
" Custom notes highlights. These are used in my color schemes.
|
||||||
exec "autocmd ColorScheme " . g:campo_light_theme . " call ReloadRainbow()"
|
"
|
||||||
|
" @incomplete I can't get these to only match in comments. Not a big deal but
|
||||||
|
" would be nice to fix.
|
||||||
|
augroup campoSyntax
|
||||||
|
autocmd!
|
||||||
|
|
||||||
|
autocmd Syntax * syntax match MyAnnotatedNote /@\S\+/ containedin=.*Comment,vimCommentTitle display
|
||||||
|
autocmd Syntax * syntax match MyTitle /#\+ .\+$/ containedin=.*Comment,vimCommentTitle display
|
||||||
|
autocmd Syntax * syntax match MyNote /\v<(NOTE|IDEA|TODO):/ containedin=.*Comment,vimCommentTitle display
|
||||||
|
autocmd Syntax * syntax match MyEmphasis /\v<(WARNING|IMPORTANT):/ containedin=.*Comment,vimCommentTitle display
|
||||||
|
autocmd Syntax * syntax match MyBug /\v<(FIXME|BUG|DEPRECATED):/ containedin=.*Comment,vimCommentTitle display
|
||||||
|
|
||||||
|
highlight link MyAnnotatedNote CampoAnnotatedNote
|
||||||
|
highlight link MyTitle CampoTitle
|
||||||
|
highlight link MyNote CampoNote
|
||||||
|
highlight link MyEmphasis CampoEmphasis
|
||||||
|
highlight link MyBug CampoBug
|
||||||
|
augroup END
|
||||||
|
|
||||||
" Toggle between light and dark themes.
|
" Toggle between light and dark themes.
|
||||||
noremap <leader>l :call ToggleLightDarkTheme()<cr>
|
noremap <leader>l :call ToggleLightDarkTheme()<cr>
|
||||||
@@ -1013,18 +1006,13 @@ endfu
|
|||||||
|
|
||||||
fu! ChangeLightDarkMode(mode, onlySetTheme)
|
fu! ChangeLightDarkMode(mode, onlySetTheme)
|
||||||
if a:mode == 'light'
|
if a:mode == 'light'
|
||||||
let s:rainbow_theme = 'light'
|
|
||||||
let s:theme = g:campo_light_theme
|
let s:theme = g:campo_light_theme
|
||||||
exe 'colorscheme ' . s:theme
|
exe 'colorscheme ' . s:theme
|
||||||
set background=light
|
set background=light
|
||||||
else
|
else
|
||||||
let s:rainbow_theme = 'dark'
|
|
||||||
let s:theme = g:campo_dark_theme
|
let s:theme = g:campo_dark_theme
|
||||||
" We have to set the theme twice in order to get its correct dark-theme colors.
|
|
||||||
" Weird stuff.
|
|
||||||
exe 'colorscheme ' . s:theme
|
exe 'colorscheme ' . s:theme
|
||||||
set background=dark
|
set background=dark
|
||||||
exe 'colorscheme ' . s:theme
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let s:current_light_dark_mode = a:mode
|
let s:current_light_dark_mode = a:mode
|
||||||
@@ -1053,51 +1041,6 @@ endfu
|
|||||||
|
|
||||||
command -nargs=0 EditColorScheme call EditColorScheme()
|
command -nargs=0 EditColorScheme call EditColorScheme()
|
||||||
|
|
||||||
"##################################################################################
|
|
||||||
" HIGHLIGHTS - TODO, NOTE, FIXME, etc
|
|
||||||
"##################################################################################
|
|
||||||
|
|
||||||
" NOTE: These depend on custom color names (Bugs, Notes and Notices) defined
|
|
||||||
" in the campo color themes. Since most themes won't define these, you can
|
|
||||||
" use WildMenu as substitution.
|
|
||||||
"
|
|
||||||
" FIXME: the custom Bugs, Notes and Notices highlighting for campo-light isn't
|
|
||||||
" working...
|
|
||||||
|
|
||||||
augroup vimrc_bugs
|
|
||||||
autocmd!
|
|
||||||
autocmd Syntax * syn match MyBugs /\v<(FIXME|BUG|DEPRECATED):/
|
|
||||||
\ containedin=.*Comment,vimCommentTitle
|
|
||||||
augroup END
|
|
||||||
hi def link MyBugs Bugs
|
|
||||||
|
|
||||||
augroup vimrc_notes
|
|
||||||
autocmd!
|
|
||||||
autocmd Syntax * syn match MyNotes /\v<(IDEA|NOTE|QUESTION|WARNING|IMPORTANT):/
|
|
||||||
\ containedin=.*Comment,vimCommentTitle
|
|
||||||
augroup END
|
|
||||||
hi def link MyNotes Notes
|
|
||||||
|
|
||||||
augroup vimrc_notices
|
|
||||||
autocmd!
|
|
||||||
autocmd Syntax * syn match MyNotices /\v<(WARNING|IMPORTANT):/
|
|
||||||
\ containedin=.*Comment,vimCommentTitle
|
|
||||||
augroup END
|
|
||||||
hi def link MyNotices Notices
|
|
||||||
|
|
||||||
augroup vimrc_annotated_todo
|
|
||||||
autocmd!
|
|
||||||
" This was a major pain in the ass to get working...
|
|
||||||
autocmd Syntax * syn match cTodo /@\S\+/
|
|
||||||
\ containedin=.*Comment,vimCommentTitle
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
augroup vimrc_annotated_notes
|
|
||||||
autocmd!
|
|
||||||
autocmd Syntax * syn match cTodo /#\+ .\+$/
|
|
||||||
\ containedin=.*Comment,vimCommentTitle
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
|
|
||||||
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||
@@ -1105,6 +1048,52 @@ augroup END
|
|||||||
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||
|
|
||||||
|
fu! IsRootDrive(path) abort
|
||||||
|
let l:path_without_slashes = substitute(a:path, "/", "", "g")
|
||||||
|
return strchars(l:path_without_slashes) <= 1
|
||||||
|
endfu
|
||||||
|
|
||||||
|
fu! IsPathContained(path1, path2) abort
|
||||||
|
let l:normalized_path1 = substitute(fnamemodify(a:path1, ':p'), '\', '/', 'g')
|
||||||
|
let l:normalized_path2 = substitute(fnamemodify(a:path2, ':p'), '\', '/', 'g')
|
||||||
|
|
||||||
|
" Ensure paths end with a directory separator.
|
||||||
|
if l:normalized_path1[-1:] != '/'
|
||||||
|
let l:normalized_path1 .= '/'
|
||||||
|
endif
|
||||||
|
if l:normalized_path2[-1:] != '/'
|
||||||
|
let l:normalized_path2 .= '/'
|
||||||
|
endif
|
||||||
|
|
||||||
|
echo l:normalized_path1
|
||||||
|
echo l:normalized_path2
|
||||||
|
|
||||||
|
return match(l:normalized_path1, '^' . escape(l:normalized_path2, '\')) != -1
|
||||||
|
endfu
|
||||||
|
|
||||||
|
fu! CountChar(str, char) abort
|
||||||
|
" Remove all characters that are not the target character.
|
||||||
|
let l:filtered = substitute(a:str, '[^' . a:char . ']', '', 'g')
|
||||||
|
return strlen(l:filtered)
|
||||||
|
endfu
|
||||||
|
|
||||||
|
fu! WindowsToUnixPath(str) abort
|
||||||
|
let l:result = substitute(a:str, '\\', '/', 'g')
|
||||||
|
return l:result
|
||||||
|
endfu
|
||||||
|
|
||||||
|
fu! ConvertQuickfixPathsToUnixSlashes()
|
||||||
|
let l:qflist = getqflist()
|
||||||
|
for i in range(len(l:qflist))
|
||||||
|
let l:bufnr = l:qflist[i]['bufnr']
|
||||||
|
if l:bufnr != -1 && bufexists(l:bufnr)
|
||||||
|
let l:filename = bufname(l:bufnr)
|
||||||
|
let l:filename = substitute(l:filename, '\\', '/', 'g')
|
||||||
|
let l:qflist[i]['module'] = l:filename
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
call setqflist(l:qflist)
|
||||||
|
endfu
|
||||||
|
|
||||||
"##################################################################################
|
"##################################################################################
|
||||||
" COMPILING CODE
|
" COMPILING CODE
|
||||||
@@ -1207,7 +1196,14 @@ fu! StopRunTask()
|
|||||||
call HideAsyncResults()
|
call HideAsyncResults()
|
||||||
endfu
|
endfu
|
||||||
|
|
||||||
fu! Build(optimized=0, silent=0)
|
" @incomplete use the same path searching from RunProgram
|
||||||
|
" @incomplete use the same path searching from RunProgram
|
||||||
|
" @incomplete use the same path searching from RunProgram
|
||||||
|
" @incomplete use the same path searching from RunProgram
|
||||||
|
" @incomplete use the same path searching from RunProgram
|
||||||
|
" @incomplete use the same path searching from RunProgram
|
||||||
|
" @incomplete use the same path searching from RunProgram
|
||||||
|
fu! Build(optimized=0, silent=0) abort
|
||||||
let l:async_cmd = "AsyncRun! "
|
let l:async_cmd = "AsyncRun! "
|
||||||
if a:silent
|
if a:silent
|
||||||
let l:async_cmd .= "-post=call\\ HideAsyncResults() "
|
let l:async_cmd .= "-post=call\\ HideAsyncResults() "
|
||||||
@@ -1215,6 +1211,7 @@ fu! Build(optimized=0, silent=0)
|
|||||||
|
|
||||||
let l:is_jai = 0
|
let l:is_jai = 0
|
||||||
let l:has_jai_build_file = 0
|
let l:has_jai_build_file = 0
|
||||||
|
let l:has_jai_first_file = 0
|
||||||
|
|
||||||
let l:ext = tolower(expand('%:e'))
|
let l:ext = tolower(expand('%:e'))
|
||||||
let l:current_dir = expand('%:p:h')
|
let l:current_dir = expand('%:p:h')
|
||||||
@@ -1225,24 +1222,41 @@ fu! Build(optimized=0, silent=0)
|
|||||||
if l:ext == "jai"
|
if l:ext == "jai"
|
||||||
let l:is_jai = 1
|
let l:is_jai = 1
|
||||||
|
|
||||||
" Check for a build file in the current directory or one directory back
|
" Check for a build file in the current directory or one directory back when one directory back isn't the root of a drive.
|
||||||
" (e.g. we're in modules/ or src/, code/, etc)
|
" (e.g. we're in modules/ or src/, code/, etc)
|
||||||
if filereadable(l:current_dir . "/build.jai") || filereadable(l:one_dir_back . "/build.jai")
|
if filereadable(l:current_dir . "/build.jai") || filereadable(l:current_dir . "/first.jai") || ((l:one_dir_back != "/") && (filereadable(l:one_dir_back . "/build.jai") || filereadable(l:one_dir_back . "/first.jai")))
|
||||||
let l:has_jai_build_file = 1
|
let l:has_jai_build_file = 1
|
||||||
|
|
||||||
if filereadable(l:current_dir . "/build.jai") == 1
|
if filereadable(l:current_dir . "/build.jai")
|
||||||
let l:cmd = "jai ". l:current_dir . "/build.jai"
|
let l:cmd = "jai ". l:current_dir . "/build.jai"
|
||||||
|
elseif filereadable(l:current_dir . "/first.jai")
|
||||||
|
let l:cmd = "jai ". l:current_dir . "/first.jai"
|
||||||
|
let l:has_jai_first_file = 1
|
||||||
else
|
else
|
||||||
" It's one directory back. We don't want to include '../' in
|
" It's one directory back. We don't want to include '../' in
|
||||||
" the cmd because then our reported paths in the program get
|
" the cmd because then our reported paths in the program get
|
||||||
" botched, e.g. path shown in an assert error.
|
" botched, e.g. path shown in an assert error.
|
||||||
let l:cmd = "jai " . l:one_dir_back . "/build.jai"
|
if filereadable(l:one_dir_back . "/build.jai")
|
||||||
|
let l:cmd = "jai " . l:one_dir_back . "/build.jai"
|
||||||
|
else
|
||||||
|
let l:cmd = "jai " . l:one_dir_back . "/first.jai"
|
||||||
|
let l:has_jai_first_file = 1
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let l:cmd = "jai % "
|
let l:cmd = "jai % "
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let l:cmd .= './build* '
|
if filereadable("build") && !isdirectory("build")
|
||||||
|
let l:cmd .= './build '
|
||||||
|
elseif filereadable("build.sh")
|
||||||
|
let l:cmd .= './build.sh '
|
||||||
|
elseif filereadable("build.bat")
|
||||||
|
let l:cmd .= './build.bat '
|
||||||
|
else
|
||||||
|
let l:cmd .= './build* '
|
||||||
|
endif
|
||||||
|
|
||||||
if a:optimized == 1
|
if a:optimized == 1
|
||||||
let l:cmd .= ' -o'
|
let l:cmd .= ' -o'
|
||||||
endif
|
endif
|
||||||
@@ -1253,18 +1267,23 @@ fu! Build(optimized=0, silent=0)
|
|||||||
let l:set_metaprogram_args = 0
|
let l:set_metaprogram_args = 0
|
||||||
|
|
||||||
if l:has_jai_build_file
|
if l:has_jai_build_file
|
||||||
|
let l:filename = "build.jai"
|
||||||
|
if l:has_jai_first_file
|
||||||
|
let l:filename = "first.jai"
|
||||||
|
endif
|
||||||
|
|
||||||
if a:optimized == 1
|
if a:optimized == 1
|
||||||
echo "Compiling release build.jai"
|
echo "Compiling release " . l:filename
|
||||||
" @note We pass 'release' as a user metaprogram arg for the
|
" @note We pass 'release' as a user metaprogram arg for the
|
||||||
" build file to parse in case it cares about that. -release is
|
" build file to parse in case it cares about that. -release is
|
||||||
" a compiler arg that we also include because some build
|
" a compiler arg that we also include because some build
|
||||||
" scripts won't be looking at the user metaprogram args.
|
" scripts won't be looking at the user metaprogram args.
|
||||||
" We also don't bother adding an import directory for local modules
|
" We also don't bother adding an import directory for local modules
|
||||||
" because the build file should manage that sort of thing for us.
|
" because the build file should manage that sort of thing for us.
|
||||||
let l:cmd .= " -release - release"
|
let l:cmd .= " -release - -release"
|
||||||
let l:set_metaprogram_args = 1
|
let l:set_metaprogram_args = 1
|
||||||
else
|
else
|
||||||
echo "Compiling debug build.jai"
|
echo "Compiling debug " . l:filename
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
if a:optimized == 1
|
if a:optimized == 1
|
||||||
@@ -1273,11 +1292,6 @@ fu! Build(optimized=0, silent=0)
|
|||||||
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 isdirectory(l:current_dir . "/modules")
|
|
||||||
let l:cmd .= " -import_dir modules"
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if g:campo_jai_metaprogram_args != ""
|
if g:campo_jai_metaprogram_args != ""
|
||||||
@@ -1296,66 +1310,179 @@ fu! Build(optimized=0, silent=0)
|
|||||||
exec l:async_cmd . l:cmd
|
exec l:async_cmd . l:cmd
|
||||||
endfu
|
endfu
|
||||||
|
|
||||||
fu! RunProgram()
|
fu! RunProgram() abort
|
||||||
let l:ran = 0
|
if tolower(expand('%:e')) == "py"
|
||||||
|
exec "AsyncRun! python %"
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Sometimes vim mixes unix and windows slashes so we need to normalize and
|
||||||
|
" use this in future fnamemodify calls (can't use expand with a string
|
||||||
|
" that doesn't contain wildcards).
|
||||||
|
let l:full_path = WindowsToUnixPath(expand('%'))
|
||||||
|
|
||||||
|
let l:file_exe_name = fnamemodify(l:full_path, ':t:r').'.exe' " Just the filename without the path
|
||||||
|
|
||||||
|
" Easy case is the current file has an exe with the same name in the
|
||||||
|
" same directory. We run that if found.
|
||||||
|
if filereadable(fnamemodify(l:full_path, ':p:h') . '/' . l:file_exe_name)
|
||||||
|
exec 'AsyncRun! ' . fnamemodify(l:full_path, ':p:h') . '/' . l:file_exe_name
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
" We start by looking for something to run relative to the current file's
|
||||||
|
" path. If nothing is found then we start over looking in the current
|
||||||
|
" working directory (the directory vim was opened in).
|
||||||
|
let l:current_path = fnamemodify(l:full_path, ':p:h')
|
||||||
|
|
||||||
|
if !RunProgramInDirectory(l:current_path, l:file_exe_name)
|
||||||
|
let l:cwd = getcwd()
|
||||||
|
if !RunProgramInDirectory(l:cwd, l:file_exe_name)
|
||||||
|
call PrintError("No exe or run script found in current file path '" . l:current_path . "' or working directory '". l:cwd ."'")
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfu
|
||||||
|
|
||||||
|
|
||||||
|
fu! RunProgramInDirectory(starting_path, file_exe_name) abort
|
||||||
|
let l:search_path = a:starting_path
|
||||||
let l:ext = tolower(expand('%:e'))
|
let l:ext = tolower(expand('%:e'))
|
||||||
let l:path_to_use = ""
|
let l:also_search_for_cpp_run_script = 0 " Covers the case of having a run-cpp file in a jai project.
|
||||||
|
|
||||||
if l:ext == "jai"
|
if l:ext == "jai"
|
||||||
" Maybe the current file has an exe, i.e. wasn't compiled with a build script.
|
" Check if we're editing inside a modules file and if so then get a
|
||||||
if filereadable(expand('%:p:r') . '.exe')
|
" path that takes us outside of it. We'll use that path for finding an
|
||||||
let l:ran = 1
|
" exe or run script.
|
||||||
exec "AsyncRun! " . expand('%:p:r') . ".exe"
|
let l:pos = match(l:search_path, "modules")
|
||||||
elseif tolower(expand('%:h:t')) == "modules" || tolower(expand('%:h:h:t')) == "modules"
|
if l:pos != -1
|
||||||
" This is likely a jai module inside a project. We will want to do the exe/run script checks in the parent project folder.
|
" e.g. if the current path is
|
||||||
" The :h:h tests for a module inside a folder, e.g. modules/Basic/module.jai
|
" /z/jai/examples/wasm/modules/Blah/blah.jai then this is /z/jai/examples/wasm/
|
||||||
echo "module"
|
let l:module_root_path = l:search_path[:l:pos-1]
|
||||||
if tolower(expand('%:h:t')) == "modules"
|
|
||||||
let l:path_to_use = "/.."
|
" We don't want to proceed if the path is in the jai compiler's modules folder.
|
||||||
else
|
let l:jai_path = tolower(g:campo_jai_path)
|
||||||
let l:path_to_use = "/../.."
|
if l:jai_path[-1:] != '/'
|
||||||
|
let l:jai_path .= '/'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
"echo 'modules root path: ' . l:module_root_path . ' | jai path: ' . l:jai_path
|
||||||
|
if tolower(l:module_root_path) == l:jai_path
|
||||||
|
"echo 'inside jai modules. Aborting run'
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:search_path = l:module_root_path
|
||||||
endif
|
endif
|
||||||
elseif l:ext == "py"
|
elseif l:ext == "cpp" || l:ext == "c" || l:ext == "h" || l:ext == "inc"
|
||||||
let l:ran = 1
|
let l:also_search_for_cpp_run_script = 1
|
||||||
exec "AsyncRun! python %"
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if l:ran == 0
|
let l:search_path = fnamemodify(l:search_path, ':p') " Normalize the path just in case.
|
||||||
" First check the current file's directory (and one directory back)
|
|
||||||
" for a run script, falling back to the current working directory (and
|
" Search the current path for a run script, an exe with the current
|
||||||
" one directory back) of the editor.
|
" filename, a bin/filename exe, a run_tree/filename exe - if nothing is
|
||||||
if filereadable(expand('%:h') . '/run')
|
" found then repeat one directory back when the current folder doesn't
|
||||||
echo "file here"
|
" contain a .git/ or it's not a root directory, e.g. /z/.
|
||||||
exec "AsyncRun! " . expand('%:h') . "/run"
|
"
|
||||||
elseif filereadable(expand('%:h') . '/../run')
|
" If nothing is found after exhausting the search then we start over and
|
||||||
" Handles editing a file in a code/ or src/ and there's a run script one directory back.
|
" find the first exe with any name.
|
||||||
echo "file one back"
|
|
||||||
exec "AsyncRun! " . expand('%:h') . "/../run"
|
fu! TryRun(path) abort
|
||||||
elseif filereadable("run")
|
if filereadable(a:path)
|
||||||
echo "cwd here"
|
exec "AsyncRun! " . a:path
|
||||||
exec "AsyncRun! ./run"
|
return 1
|
||||||
elseif filereadable("../run")
|
|
||||||
" Handles editing a file in a code/ or src/ and there's a run script one directory back.
|
|
||||||
echo "cwd one back"
|
|
||||||
exec "AsyncRun! ../run"
|
|
||||||
else
|
|
||||||
" Final attempt is to run any exe that's found nearby.
|
|
||||||
" We start with an exe relative to the open file's path.
|
|
||||||
let l:files = systemlist('ls '.expand('%:h').''.l:path_to_use.'/*.exe 2>/dev/null')
|
|
||||||
if len(l:files) > 0
|
|
||||||
exec "AsyncRun! " . l:files[0]
|
|
||||||
else
|
|
||||||
" Last attempt is any exe in the current working directory.
|
|
||||||
let l:files = systemlist('ls *.exe 2>/dev/null')
|
|
||||||
if len(l:files) > 0
|
|
||||||
exec "AsyncRun! " . l:files[0]
|
|
||||||
else
|
|
||||||
call PrintError("No exe or run script found!")
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
return 0
|
||||||
|
endfu
|
||||||
|
|
||||||
|
let l:current_path = l:search_path
|
||||||
|
while 1
|
||||||
|
" run script
|
||||||
|
if l:also_search_for_cpp_run_script
|
||||||
|
if TryRun(l:current_path . 'run-cpp') | return 1 | endif
|
||||||
|
endif
|
||||||
|
if TryRun(l:current_path . 'run') | return 1 | endif
|
||||||
|
|
||||||
|
" run_tree/run script
|
||||||
|
if l:also_search_for_cpp_run_script
|
||||||
|
if TryRun(l:current_path . 'run_tree/run-cpp') | return 1 | endif
|
||||||
|
endif
|
||||||
|
if TryRun(l:current_path . 'run_tree/run') | return 1 | endif
|
||||||
|
|
||||||
|
" filename exe
|
||||||
|
if TryRun(l:current_path . a:file_exe_name) | return 1 | endif
|
||||||
|
|
||||||
|
" bin/filename exe
|
||||||
|
if TryRun(l:current_path. 'bin/' . a:file_exe_name) | return 1 | endif
|
||||||
|
|
||||||
|
" run_tree/filename exe
|
||||||
|
if TryRun(l:current_path. 'run_tree/' . a:file_exe_name) | return 1 | endif
|
||||||
|
|
||||||
|
" Only go back a directory if the current path doesn't have a .git folder or we're not in a root drive path.
|
||||||
|
if isdirectory(l:current_path . '.git') || IsRootDrive(l:current_path)
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:current_path = fnamemodify(l:current_path."../", ':p')
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
" Start over but look for the first exe. The user will confirm if they
|
||||||
|
" want to run it.
|
||||||
|
"
|
||||||
|
" @improve maybe provide the first 4 or 5 exes found and let them input
|
||||||
|
" which one they want?
|
||||||
|
|
||||||
|
fu! GetFirstExePath(path)
|
||||||
|
let l:files = systemlist('ls '.a:path.'*.exe 2>/dev/null')
|
||||||
|
if len(l:files) > 0
|
||||||
|
return l:files[0]
|
||||||
|
endif
|
||||||
|
return ""
|
||||||
|
endfu
|
||||||
|
|
||||||
|
let l:current_path = l:search_path
|
||||||
|
let l:exe_to_confirm = ""
|
||||||
|
|
||||||
|
while 1
|
||||||
|
let l:exe = GetFirstExePath(l:current_path)
|
||||||
|
if l:exe != ""
|
||||||
|
let l:exe_to_confirm = l:exe
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
|
||||||
|
" bin/filename exe
|
||||||
|
let l:exe = GetFirstExePath(l:current_path."bin/")
|
||||||
|
if l:exe != ""
|
||||||
|
let l:exe_to_confirm = l:exe
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
|
||||||
|
" run_tree/filename exe
|
||||||
|
let l:exe = GetFirstExePath(l:current_path."run_tree/")
|
||||||
|
if l:exe != ""
|
||||||
|
let l:exe_to_confirm = l:exe
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Only go back a directory if the current path doesn't have a .git folder or we're not in a root drive path.
|
||||||
|
if isdirectory(l:current_path . '.git') || IsRootDrive(l:current_path)
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:current_path = fnamemodify(l:current_path."../", ':p')
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
if l:exe_to_confirm != ""
|
||||||
|
let l:confirm = confirm("Found exe ".l:exe_to_confirm." - run this?", "&Yes\n&No")
|
||||||
|
if l:confirm == 1
|
||||||
|
exec "AsyncRun! " . l:exe_to_confirm
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
redraw!
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
return 0
|
||||||
endfu
|
endfu
|
||||||
|
|
||||||
" Show results window the moment the async job starts
|
" Show results window the moment the async job starts
|
||||||
@@ -1370,10 +1497,9 @@ noremap <F11> :call ToggleBuildResults()<cr>
|
|||||||
" Hide build results and clear errors
|
" Hide build results and clear errors
|
||||||
noremap <F10> :call HideBuildResultsAndClearErrors()<cr>
|
noremap <F10> :call HideBuildResultsAndClearErrors()<cr>
|
||||||
|
|
||||||
" Execute build script and keep results.
|
" Execute build script and display results.
|
||||||
nnoremap <silent><leader>b :call Build(0)<cr>
|
nnoremap <silent><leader>b :call Build(0)<cr>
|
||||||
" Execute build and hide results.
|
nnoremap <silent><F8> :call Build(0)<cr>
|
||||||
nnoremap <silent><F8> :call Build(0, 1)<cr>
|
|
||||||
|
|
||||||
" Execute optimized build script
|
" Execute optimized build script
|
||||||
nnoremap <leader>bb :call Build(1)<cr>
|
nnoremap <leader>bb :call Build(1)<cr>
|
||||||
@@ -1418,7 +1544,10 @@ fu! Search(path, search_args, case_insensitive=0)
|
|||||||
|
|
||||||
let l:format = 'Rg ' . l:rg_args . ' ' . a:path . ' -e %s'
|
let l:format = 'Rg ' . l:rg_args . ' ' . a:path . ' -e %s'
|
||||||
let l:cmd = printf(l:format, shellescape(l:escaped_term))
|
let l:cmd = printf(l:format, shellescape(l:escaped_term))
|
||||||
|
|
||||||
exec l:cmd
|
exec l:cmd
|
||||||
|
|
||||||
|
call ConvertQuickfixPathsToUnixSlashes()
|
||||||
endfu
|
endfu
|
||||||
|
|
||||||
fu! SearchExt(path, search_args, case_insensitive=0)
|
fu! SearchExt(path, search_args, case_insensitive=0)
|
||||||
@@ -1507,6 +1636,7 @@ nnoremap <expr> p (&buftype is# "quickfix" ? "<CR>\|:copen<CR>" : "p")
|
|||||||
|
|
||||||
" @warning I've stopped using this because it sometimes locks up vim and I
|
" @warning I've stopped using this because it sometimes locks up vim and I
|
||||||
" have to force exit the process then clean up the swap files.
|
" have to force exit the process then clean up the swap files.
|
||||||
|
"
|
||||||
" @improve Figure out what's causing vim to freeze and fix it. Seems to happen
|
" @improve Figure out what's causing vim to freeze and fix it. Seems to happen
|
||||||
" when it quickly changes and saves a handful of buffers.
|
" when it quickly changes and saves a handful of buffers.
|
||||||
|
|
||||||
@@ -1566,7 +1696,7 @@ fu! GlobalReplaceIt(confirm_replacement) range
|
|||||||
call PrintError("Unable to search since you're not in a git repo!")
|
call PrintError("Unable to search since you're not in a git repo!")
|
||||||
endif
|
endif
|
||||||
endfu
|
endfu
|
||||||
noremap <leader>r :call GlobalReplaceIt(0)<cr>
|
noremap <leader>r :call GlobalReplaceIt(0)<cr>
|
||||||
noremap <leader>rr :call GlobalReplaceIt(1)<cr>
|
noremap <leader>rr :call GlobalReplaceIt(1)<cr>
|
||||||
|
|
||||||
|
|
||||||
@@ -1582,9 +1712,9 @@ fu! RenameFile()
|
|||||||
if l:confirm == 1
|
if l:confirm == 1
|
||||||
exec 'saveas' l:new_name
|
exec 'saveas' l:new_name
|
||||||
exec 'silent! !rm' l:old_name
|
exec 'silent! !rm' l:old_name
|
||||||
redraw!
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
redraw!
|
||||||
endfu
|
endfu
|
||||||
noremap <leader>n :call RenameFile()<cr>
|
noremap <leader>n :call RenameFile()<cr>
|
||||||
|
|
||||||
@@ -1651,3 +1781,4 @@ nnoremap <leader>c :call ToggleSimpleView()<cr>
|
|||||||
"-----------------------------------------------------------------------------------------------------------------------
|
"-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
let g:campo_vimrc_initialized = 1
|
let g:campo_vimrc_initialized = 1
|
||||||
|
|
||||||
|
|||||||
58
dotfiles/bin/add-audio-to-video
Normal file
58
dotfiles/bin/add-audio-to-video
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Re-encodes the video with a new primary audio channel.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
vid_filename=$(basename -- "$1")
|
||||||
|
audio_filename=$(basename -- "$2")
|
||||||
|
output_name="$3"
|
||||||
|
|
||||||
|
if [[ $vid_filename == "" || $audio_filename == "" || $output_name == "" ]]; then
|
||||||
|
printf "${BOLD}${RED}Usage: add-audio-to-video <video filename> <audio filename> <output name>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
vid_extension="${vid_filename##*.}"
|
||||||
|
vid_filename="${vid_filename%.*}"
|
||||||
|
|
||||||
|
audio_extension="${audio_filename##*.}"
|
||||||
|
audio_filename="${audio_filename%.*}"
|
||||||
|
|
||||||
|
output="${output_name}.$vid_extension"
|
||||||
|
|
||||||
|
audio_encoding_opts="-c:a copy"
|
||||||
|
if [[ $audio_extension == "wav" ]]; then
|
||||||
|
# Re-encode the audio.
|
||||||
|
audio_encoding_opts="-c:a aac -b:a 192k"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n${YELLOW}${BOLD}Adding audio '$audio_filename.$audio_extension' to '$vid_filename.$vid_extension' | output: $output${NORMAL}\n"
|
||||||
|
|
||||||
|
# -shortest handles the inputs not being the same duration. Conversion will stop when the shortest input's end is reached.
|
||||||
|
# Alternatively you can loop with "-stream_loop -1"
|
||||||
|
ffmpeg -y -stats -loglevel level+error -i "$vid_filename.$vid_extension" -i "$audio_filename.$audio_extension" -c:v copy -map 0:v:0 -map 1:a:0 $audio_encoding_opts -shortest "$output"
|
||||||
|
|
||||||
|
printf "\n${GREEN}${BOLD}Finished adding audio${NORMAL}\n\n"
|
||||||
|
|
||||||
52
dotfiles/bin/analyze-volume
Normal file
52
dotfiles/bin/analyze-volume
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Use this to get a volume report from a video or audio file. You can use this
|
||||||
|
# info manually normalize or increase/decrease the volume using the
|
||||||
|
# change-volume script, supplying it the volume delta you want. Typically you
|
||||||
|
# use the delta from the analysis report this script provides, e.g. if the
|
||||||
|
# max_volume is -5 db then you would call change-volume with a value of 5. I
|
||||||
|
# find that the two pass normalize-audio script works better than this
|
||||||
|
# approach...but it will take longer to run!
|
||||||
|
#
|
||||||
|
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
|
||||||
|
|
||||||
|
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: analyze-volume <video or audio filename>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
filename="$1"
|
||||||
|
|
||||||
|
printf "\n${YELLOW}${BOLD}Analyzing audio in $filename${NORMAL}\n"
|
||||||
|
|
||||||
|
# -vn, -sn, and -dn tells ffmpeg to ignore non-audio streams during the analysis. This speeds things up.
|
||||||
|
cmd="ffmpeg -i \"$filename\" -af volumedetect -vn -sn -dn -f null /dev/null"
|
||||||
|
printf "\n${BOLD}Running: $cmd\n\n${NORMAL}"
|
||||||
|
eval $cmd
|
||||||
|
|
||||||
|
printf "\n${GREEN}${BOLD}Done analyzing audio in $filename\n${NORMAL}"
|
||||||
|
printf "\n${YELLOW}${BOLD}Look at the reported max_volume value. If != 0 then call the change-volume script, passing it the filename, an output name and the delta to bring the volume to 0.\ne.g. if the max_volume is -5 db, then you would pass 5.${NORMAL}\n\n"
|
||||||
|
|
||||||
@@ -7,8 +7,7 @@ if not "%1"=="am_admin" (
|
|||||||
exit /b
|
exit /b
|
||||||
)
|
)
|
||||||
|
|
||||||
rem USE AT OWN RISK AS IS WITHOUT WARRANTY OF ANY KIND !!!!!
|
rem NOTE: Defender may see this file as malware, so you might need to exclude this before things can be disabled.
|
||||||
rem NOTE: Defender may see this file as malware, so you will likely need to exclude this before things can be disabled.
|
|
||||||
rem
|
rem
|
||||||
rem Modified version of
|
rem Modified version of
|
||||||
rem https://raw.githubusercontent.com/mattreecebentley/win10_disable_defender/main/win10_enable_defender.bat
|
rem https://raw.githubusercontent.com/mattreecebentley/win10_disable_defender/main/win10_enable_defender.bat
|
||||||
@@ -94,7 +93,7 @@ reg add HKLM\SYSTEM\Setup /v DisabledDefenderServices /t REG_DWORD /d 1 /f
|
|||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo Windows Defender has (hopefully) been disabled.
|
echo Windows Defender has (hopefully) been disabled.
|
||||||
echo You should still be able to scan files going forward. Also, the Antimalware Service Executable should immediately stop using CPU cycles.
|
echo You might still be able to scan files going forward depending on your version of Windows. Also, the Antimalware Service Executable should immediately stop using CPU cycles.
|
||||||
echo Please restart your computer to see all changes.
|
echo Please restart your computer to see all changes.
|
||||||
|
|
||||||
goto eof
|
goto eof
|
||||||
|
|||||||
@@ -1,5 +1,30 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Creates a file containing the names of all files in a specific bucket.
|
||||||
|
#
|
||||||
|
# e.g. aws-list-deep-glacier-files my-deep-glacier images image_list
|
||||||
|
#
|
||||||
|
# You'll need the aws cli tools. Download them from https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
|
||||||
|
#
|
||||||
|
# If you see an error like along the lines of "'charmap' codec can't encode
|
||||||
|
# character '\u200e' in position 42: character maps to <undefined>" then that
|
||||||
|
# means a filename has a Unicode codepoint and the dumb aws Python code is
|
||||||
|
# trying to read it using your system's locale, which is very likely not set to
|
||||||
|
# use the Windows UTF-8 beta feature. This is an ongoing issue in this tool
|
||||||
|
# that goes back to 2013!!! There's no way to fix it using environment
|
||||||
|
# variables, at least nothing worked for me. The fix provided by the devs is
|
||||||
|
# heavy handed: you change your system locale to use UTF-8... This has
|
||||||
|
# consequences though like breaking legacy apps that don't have Unicode support
|
||||||
|
# and I'm sure other weird things will happen, such as file corruption. Anyway,
|
||||||
|
# if you're getting this charmap error then I suggest changing your system
|
||||||
|
# locale, run this again, then switch back to your previous locale. If you
|
||||||
|
# don't get the canonical file name then you won't be able to restore it.
|
||||||
|
#
|
||||||
|
# You can enable the UTF-8 locale with:
|
||||||
|
#
|
||||||
|
# win+r -> intl.cpl -> Administrative tab -> Change system locale -> Beta: Use Unicode UTF-8 box.
|
||||||
|
#
|
||||||
|
|
||||||
if which tput >/dev/null 2>&1; then
|
if which tput >/dev/null 2>&1; then
|
||||||
ncolors=$(tput colors)
|
ncolors=$(tput colors)
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,10 +1,49 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# Restores all files/folders inside a particular bucket path,
|
# Restores all files/folders inside a particular bucket path for the next 7 days. This uses the bulk retrieval tier:
|
||||||
# e.g. aws-restore-deep-glacier-folder mcampagnaro-deep-glacier images restored_images
|
#
|
||||||
# will restore all files inside the images folder of the mcampagnaro-deep-glacier bucket, saving
|
# Bulk retrievals are the lowest-cost retrieval option when restoring objects
|
||||||
# temp restoration data in the local "restored_images" directory.
|
# from S3 Glacier Deep Archive. They typically finish within 48 hours for
|
||||||
|
# objects stored in the S3 Glacier Deep Archive storage class or S3
|
||||||
|
# Intelligent-Tiering Deep Archive tier.
|
||||||
|
#
|
||||||
|
# If you need faster access then use the `Expedited` or `Standard` tiers.
|
||||||
|
#
|
||||||
|
# Example usage:
|
||||||
|
#
|
||||||
|
# aws-restore-deep-glacier-folder my-deep-glacier-bucket path/to/images restored_images
|
||||||
|
#
|
||||||
|
# This will create a run.sh script in a folder called "restored_images". Run that to restore all files inside the `path/to/images` folder inside the my-deep-glacier bucket.
|
||||||
|
#
|
||||||
|
# After you run the generated script, you have to wait for AWS to make the files available for download. You can check the status of a file with:
|
||||||
|
#
|
||||||
|
# aws s3api head-object --bucket my-deep-glacier --key path/to/images/photo1.jpg
|
||||||
|
#
|
||||||
|
# (obviously change the bucket and path to suit your needs).
|
||||||
|
#
|
||||||
|
# Once the files are restored you can download them on the S3 website or better yet use RcloneBrowser. I'm sure there's also a way to do it over cli too, I just haven't checked.
|
||||||
|
#
|
||||||
|
# You'll need the aws cli tools for this script. Download them from https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
|
||||||
|
# Once installed, open a new shell and verify that you can run the `aws` command.
|
||||||
|
#
|
||||||
|
# If you see an error like along the lines of "'charmap' codec can't encode
|
||||||
|
# character '\u200e' in position 42: character maps to <undefined>" then that
|
||||||
|
# means a filename has a Unicode codepoint and the dumb aws Python code is
|
||||||
|
# trying to read it using your system's locale, which is very likely not set to
|
||||||
|
# use the Windows UTF-8 beta feature. This is an ongoing issue in this tool
|
||||||
|
# that goes back to 2013!!! There's no way to fix it using environment
|
||||||
|
# variables, at least nothing worked for me. The fix provided by the devs is
|
||||||
|
# heavy handed: you change your system locale to use UTF-8... This has
|
||||||
|
# consequences though like breaking legacy apps that don't have Unicode support
|
||||||
|
# and I'm sure other weird things will happen, such as file corruption. Anyway,
|
||||||
|
# if you're getting this charmap error then I suggest changing your system
|
||||||
|
# locale, run this again, then switch back to your previous locale. If you
|
||||||
|
# don't get the canonical file name then you won't be able to restore it.
|
||||||
|
#
|
||||||
|
# You can enable the UTF-8 locale with:
|
||||||
|
#
|
||||||
|
# win+r -> intl.cpl -> Administrative tab -> Change system locale -> Beta: Use Unicode UTF-8 box.
|
||||||
#
|
#
|
||||||
|
|
||||||
if which tput >/dev/null 2>&1; then
|
if which tput >/dev/null 2>&1; then
|
||||||
@@ -46,7 +85,7 @@ path="$2"
|
|||||||
temp_dir="$3"
|
temp_dir="$3"
|
||||||
number_of_objects_per_file=100
|
number_of_objects_per_file=100
|
||||||
days_available=7
|
days_available=7
|
||||||
restore_tier="Bulk" # Can also be "Standard"
|
restore_tier="Bulk" # Can also be "Standard" or "Expedited"
|
||||||
|
|
||||||
if [[ $bucket == "" || $path == "" || $temp_dir == "" ]]; then
|
if [[ $bucket == "" || $path == "" || $temp_dir == "" ]]; then
|
||||||
error "Usage: aws-restore-deep-glacier-folder <bucket-name> <path-in-bucket> <local-temp-dir>"
|
error "Usage: aws-restore-deep-glacier-folder <bucket-name> <path-in-bucket> <local-temp-dir>"
|
||||||
@@ -61,7 +100,7 @@ pushd "$temp_dir" &>/dev/null
|
|||||||
aws s3api list-objects-v2 --bucket $bucket --prefix $path --query "Contents[?StorageClass=='DEEP_ARCHIVE']" --output text | LC_ALL=C awk '{print substr($0, index($0, $2))}' | awk '{NF-=3};3' > all_objects_list.txt
|
aws s3api list-objects-v2 --bucket $bucket --prefix $path --query "Contents[?StorageClass=='DEEP_ARCHIVE']" --output text | LC_ALL=C awk '{print substr($0, index($0, $2))}' | awk '{NF-=3};3' > all_objects_list.txt
|
||||||
|
|
||||||
# Generate the main script that will kick off the restoration.
|
# Generate the main script that will kick off the restoration.
|
||||||
printf "while read x; do\n printf \"aws s3api restore-object --restore-request '{\\\\\"Days\\\\\":$days_available,\\\\\"GlacierJobParameters\\\\\":{\\\\\"Tier\\\\\":\\\\\"$restore_tier\\\\\"}}' --bucket $bucket --key \\\\\"\$x\\\\\"\\\\n\"\n aws s3api restore-object --restore-request \"{\\\\\"Days\\\\\":$days_available,\\\\\"GlacierJobParameters\\\\\":{\\\\\"Tier\\\\\":\\\\\"$restore_tier\\\\\"}}\" --bucket $bucket --key \"\$x\"\ndone < all_objects_list.txt\nprintf \"\\\\nDone! You can now delete this folder.\\\\n\"\n" > run.sh
|
printf "while read x; do\n printf \"aws s3api restore-object --restore-request '{\\\\\"Days\\\\\":$days_available,\\\\\"GlacierJobParameters\\\\\":{\\\\\"Tier\\\\\":\\\\\"$restore_tier\\\\\"}}' --bucket $bucket --key \\\\\"\$x\\\\\"\\\\n\"\n aws s3api restore-object --restore-request \"{\\\\\"Days\\\\\":$days_available,\\\\\"GlacierJobParameters\\\\\":{\\\\\"Tier\\\\\":\\\\\"$restore_tier\\\\\"}}\" --bucket $bucket --key \"\$x\"\ndone < all_objects_list.txt\nprintf \"\\\\nDone! You can now delete this folder.\\\\nYour files are currently being restored. The time it takes to restore can be found in the AWS docs - just look for the $restore_tier restore tier, which is what you used.\\\\nOnce restored, download the files from the S3 site or better yet use RCloneBrowser.\\\\n\"\n" > run.sh
|
||||||
chmod +x run.sh
|
chmod +x run.sh
|
||||||
|
|
||||||
printf "${BOLD}You can now run ${GREEN}$temp_dir/run.sh${NORMAL}${BOLD} to start the restoration process.\n"
|
printf "${BOLD}You can now run ${GREEN}$temp_dir/run.sh${NORMAL}${BOLD} to start the restoration process.\n"
|
||||||
|
|||||||
59
dotfiles/bin/change-volume
Normal file
59
dotfiles/bin/change-volume
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Re-encodes the audio, modify the volume based on the supplied db delta. If
|
||||||
|
# given a video file then the file is copied as-is. If you want to bring the
|
||||||
|
# max_volume to 0 db then call analyze-volume prior to this and pass a delta
|
||||||
|
# based on the reported max_volume.
|
||||||
|
#
|
||||||
|
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
|
||||||
|
|
||||||
|
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: change-volume <video or audio filename> <output name> <volume delta in db>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
filename=$(basename -- "$1")
|
||||||
|
extension="${filename##*.}"
|
||||||
|
filename="${filename%.*}"
|
||||||
|
|
||||||
|
output_name="$2"
|
||||||
|
delta_db="$3"
|
||||||
|
|
||||||
|
if [[ $output_name == "" ]]; then
|
||||||
|
output="${filename}_normalized_audio.$extension"
|
||||||
|
else
|
||||||
|
output="${output_name}.$extension"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n${YELLOW}${BOLD}Modifying audio volume in $filename.$extension | output: $output | delta: $delta_db${NORMAL}\n"
|
||||||
|
|
||||||
|
# Since we're re-encoding the audio we have to specify a codec to use.
|
||||||
|
cmd="ffmpeg -y -stats -loglevel level+error -i \"$filename.$extension\" -af \"volume=${delta_db}dB\" -c:v copy -c:a aac \"$output\""
|
||||||
|
printf "\n${BOLD}Running: $cmd\n\n${NORMAL}"
|
||||||
|
eval $cmd
|
||||||
|
|
||||||
|
printf "\n${GREEN}${BOLD}Done modifying volume in $filename.$extension | output: $output | delta: $delta_db${NORMAL}\n"
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ fi
|
|||||||
use_gpu=0
|
use_gpu=0
|
||||||
|
|
||||||
if [[ $# < 2 || $# > 3 ]]; then
|
if [[ $# < 2 || $# > 3 ]]; then
|
||||||
printf "${BOLD}${RED}Usage: $0 <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> ${NORMAL}\n"
|
printf "${BOLD}${RED}Usage: compress-video <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> ${NORMAL}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -37,10 +37,10 @@ if [[ $# > 2 ]]; then
|
|||||||
use_gpu=$3
|
use_gpu=$3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Found the following to work best with vids containing text (e.g. programming vid): 25 for CPU encoding and 27 for GPU.
|
# Found the following to work best with vids containing text (e.g. programming vid): 21 for CPU encoding and 28 for GPU (similar bitrates).
|
||||||
use_crf=21
|
use_crf=21
|
||||||
if [[ $use_gpu -eq 1 ]]; then
|
if [[ $use_gpu -eq 1 ]]; then
|
||||||
use_crf=25
|
use_crf=28
|
||||||
fi
|
fi
|
||||||
|
|
||||||
compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu
|
compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ fi
|
|||||||
use_gpu=0
|
use_gpu=0
|
||||||
|
|
||||||
if [[ "$#" < 3 || "$#" > 6 ]]; then
|
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"
|
printf "${BOLD}${RED}Usage: compress-video-with-crf <crf value> <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> <optional: start time HH:MM:SS> <optional: end time HH:MM:SS>\n\nIf you want to encode a range of CRF values then use -1 as the crf value.${NORMAL}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -65,8 +65,6 @@ function encode() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $use_gpu -eq 1 ]]; then
|
if [[ $use_gpu -eq 1 ]]; then
|
||||||
# File will be slightly larger than CPU encoding, but it's much faster to transcode and doesn't max out the CPU cores.
|
|
||||||
|
|
||||||
# RTX 3080
|
# RTX 3080
|
||||||
ffmpeg -y -stats -loglevel level+error $timing_args -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i "$filename.$extension" -c:a copy -c:v h264_nvenc -profile:v high -rc:v vbr_hq -cq:v $crf -b:v 5M -maxrate 5M -max_muxing_queue_size 9999 "$output"
|
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"
|
||||||
|
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# This is for reencoding an AVI video. I wasn't able to play the encoded videos
|
|
||||||
# on my phone when using libx264 and libx265 encoders, but mpeg4 works. Also
|
|
||||||
# I'm using the aac codec because some old avi's were using a codec that's not
|
|
||||||
# supported in the mp4 container.
|
|
||||||
|
|
||||||
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 == "" || $2 == "" ]]; then
|
|
||||||
printf "${BOLD}${RED}Usage: $0 <filename> <bitrate, e.g. \"4000k\"> <optional output name>${NORMAL}\n"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
filename=$(basename -- "$1")
|
|
||||||
extension="${filename##*.}"
|
|
||||||
filename="${filename%.*}"
|
|
||||||
|
|
||||||
bitrate="$2"
|
|
||||||
|
|
||||||
output_name="$3"
|
|
||||||
if [[ $output_name == "" ]]; then
|
|
||||||
output="${filename}_CONVERTED-${bitrate}.mp4"
|
|
||||||
else
|
|
||||||
output="${output_name}.mp4"
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' with target bitrate $bitrate | output: $output${NORMAL}\n"
|
|
||||||
ffmpeg -i "$filename.$extension" -c:a aac -c:v mpeg4 -b:v $bitrate "$output"
|
|
||||||
printf "\n${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output'${NORMAL}\n\n"
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# This is for reencoding an FLV video to mp4 using an mpeg4 encoder.
|
|
||||||
# Can optionally compress the video.
|
|
||||||
|
|
||||||
if which tput >/dev/null 2>&1; then
|
|
||||||
ncolors=$(tput colors)
|
|
||||||
fi
|
|
||||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
|
||||||
RED="$(tput setaf 1)"
|
|
||||||
GREEN="$(tput setaf 2)"
|
|
||||||
YELLOW="$(tput setaf 3)"
|
|
||||||
BLUE="$(tput setaf 4)"
|
|
||||||
MAGENTA="$(tput setaf 5)"
|
|
||||||
CYAN="$(tput setaf 6)"
|
|
||||||
BOLD="$(tput bold)"
|
|
||||||
NORMAL="$(tput sgr0)"
|
|
||||||
else
|
|
||||||
RED=""
|
|
||||||
GREEN=""
|
|
||||||
YELLOW=""
|
|
||||||
BLUE=""
|
|
||||||
MAGENTA=""
|
|
||||||
CYAN=""
|
|
||||||
BOLD=""
|
|
||||||
NORMAL=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $1 == "" || $2 == "" ]]; then
|
|
||||||
printf "${BOLD}${RED}Usage: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
compress="$1"
|
|
||||||
|
|
||||||
filename=$(basename -- "$2")
|
|
||||||
extension="${filename##*.}"
|
|
||||||
filename="${filename%.*}"
|
|
||||||
|
|
||||||
output="$3"
|
|
||||||
if [[ $output == "" ]]; then
|
|
||||||
output="${filename}_CONVERTED"
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' | compress: $compress | output: $output.mp4${NORMAL}\n"
|
|
||||||
|
|
||||||
if [[ $compress -eq 1 ]]; then
|
|
||||||
temp_output="temp_$output.mp4"
|
|
||||||
else
|
|
||||||
temp_output="$output.mp4"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# convert first.
|
|
||||||
# we convert then compress instead of compressing on first pass because this results in a slightly higher bitrate.
|
|
||||||
ffmpeg -y -stats -loglevel level+error -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i "$filename.$extension" -c:a aac -c:v h264_nvenc -b:v 5M "$temp_output"
|
|
||||||
|
|
||||||
if [[ $compress -eq 1 ]]; then
|
|
||||||
compress-video 1 "$temp_output" "$output"
|
|
||||||
rm "$temp_output"
|
|
||||||
else
|
|
||||||
printf "\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output.mp4'${NORMAL}\n\n"
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# This is for reencoding an mkv video to mp4 using an mpeg4 encoder.
|
|
||||||
# Can optionally compress the video.
|
|
||||||
|
|
||||||
if which tput >/dev/null 2>&1; then
|
|
||||||
ncolors=$(tput colors)
|
|
||||||
fi
|
|
||||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
|
||||||
RED="$(tput setaf 1)"
|
|
||||||
GREEN="$(tput setaf 2)"
|
|
||||||
YELLOW="$(tput setaf 3)"
|
|
||||||
BLUE="$(tput setaf 4)"
|
|
||||||
MAGENTA="$(tput setaf 5)"
|
|
||||||
CYAN="$(tput setaf 6)"
|
|
||||||
BOLD="$(tput bold)"
|
|
||||||
NORMAL="$(tput sgr0)"
|
|
||||||
else
|
|
||||||
RED=""
|
|
||||||
GREEN=""
|
|
||||||
YELLOW=""
|
|
||||||
BLUE=""
|
|
||||||
MAGENTA=""
|
|
||||||
CYAN=""
|
|
||||||
BOLD=""
|
|
||||||
NORMAL=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $1 == "" || $2 == "" ]]; then
|
|
||||||
printf "${BOLD}${RED}Usage: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
compress="$1"
|
|
||||||
|
|
||||||
filename=$(basename -- "$2")
|
|
||||||
extension="${filename##*.}"
|
|
||||||
filename="${filename%.*}"
|
|
||||||
|
|
||||||
output="$3"
|
|
||||||
if [[ $output == "" ]]; then
|
|
||||||
output="${filename}_CONVERTED"
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' | compress: $compress | output: $output.mp4${NORMAL}\n"
|
|
||||||
|
|
||||||
if [[ $compress -eq 1 ]]; then
|
|
||||||
temp_output="temp_$output.mp4"
|
|
||||||
else
|
|
||||||
temp_output="$output.mp4"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# convert first.
|
|
||||||
# we convert then compress instead of compressing on first pass because this results in a slightly higher bitrate.
|
|
||||||
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -vcodec copy -acodec copy "$temp_output"
|
|
||||||
|
|
||||||
if [[ $compress -eq 1 ]]; then
|
|
||||||
compress-video 1 "$temp_output" "$output"
|
|
||||||
rm "$temp_output"
|
|
||||||
else
|
|
||||||
printf "\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output.mp4'${NORMAL}\n\n"
|
|
||||||
96
dotfiles/bin/convert-video-to-mp4
Normal file
96
dotfiles/bin/convert-video-to-mp4
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# This is for reencoding a non-mp4 video to mp4 using an mpeg4 encoder.
|
||||||
|
# Can optionally compress the video.
|
||||||
|
|
||||||
|
if which tput >/dev/null 2>&1; then
|
||||||
|
ncolors=$(tput colors)
|
||||||
|
fi
|
||||||
|
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||||
|
RED="$(tput setaf 1)"
|
||||||
|
GREEN="$(tput setaf 2)"
|
||||||
|
YELLOW="$(tput setaf 3)"
|
||||||
|
BLUE="$(tput setaf 4)"
|
||||||
|
MAGENTA="$(tput setaf 5)"
|
||||||
|
CYAN="$(tput setaf 6)"
|
||||||
|
BOLD="$(tput bold)"
|
||||||
|
NORMAL="$(tput sgr0)"
|
||||||
|
else
|
||||||
|
RED=""
|
||||||
|
GREEN=""
|
||||||
|
YELLOW=""
|
||||||
|
BLUE=""
|
||||||
|
MAGENTA=""
|
||||||
|
CYAN=""
|
||||||
|
BOLD=""
|
||||||
|
NORMAL=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
compress="$1"
|
||||||
|
filename="$2"
|
||||||
|
output_name="$3"
|
||||||
|
bitrate="$4"
|
||||||
|
|
||||||
|
if [[ $compress == "" || $filename == "" || $output_name == "" ]]; then
|
||||||
|
printf "${BOLD}${RED}Usage: convert-video-to-mp4 <compress 1|0> <filename> <output name> <optional: bitrate, e.g. \"4000k\", defaults to source>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
filename=$(basename -- "$filename")
|
||||||
|
extension="${filename##*.}"
|
||||||
|
extension="${extension,,}" # go lower-case
|
||||||
|
filename="${filename%.*}"
|
||||||
|
|
||||||
|
output="$output_name.mp4"
|
||||||
|
|
||||||
|
bitrate_args=""
|
||||||
|
|
||||||
|
if [[ $compress -eq 1 ]]; then
|
||||||
|
temp_output="temp_$output"
|
||||||
|
else
|
||||||
|
temp_output="$output"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# convert first.
|
||||||
|
# we convert then compress instead of compressing on first pass because this results in a slightly higher bitrate.
|
||||||
|
|
||||||
|
cmd=""
|
||||||
|
|
||||||
|
if [[ $extension == "mkv" || $extension == "mpg" || $extension == "mov" ]]; then
|
||||||
|
if [[ $bitrate != "" ]]; then
|
||||||
|
bitrate_args="-b:v $bitrate"
|
||||||
|
else
|
||||||
|
bitrate="<source value>"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cmd="ffmpeg -y -stats -loglevel level+error -i \"$filename.$extension\" -vcodec copy -acodec copy $bitrate_args \"$temp_output\""
|
||||||
|
|
||||||
|
elif [[ $extension == "flv" ]]; then
|
||||||
|
if [[ $bitrate == "" ]]; then
|
||||||
|
bitrate="5M"
|
||||||
|
fi
|
||||||
|
bitrate_args="-b:v $bitrate"
|
||||||
|
|
||||||
|
cmd="ffmpeg -y -stats -loglevel level+error -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i \"$filename.$extension\" -c:a aac -c:v h264_nvenc $bitrate_args \"$temp_output\""
|
||||||
|
|
||||||
|
elif [[ $extension == "avi" || $extension == "wmv" ]]; then
|
||||||
|
cmd="ffmpeg -y -stats -loglevel level+error -i \"$filename.$extension\" -c:a aac -c:v mpeg4 $bitrate_args \"$output\""
|
||||||
|
|
||||||
|
else
|
||||||
|
printf "${BOLD}${RED}Don't know how to convert a '$extension' to mp4. Add support!${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' | compress: $compress | output: $output | bitrate: $bitrate${NORMAL}\n"
|
||||||
|
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
if [[ $compress -eq 1 ]]; then
|
||||||
|
compress-video 1 "$temp_output" "$output"
|
||||||
|
rm "$temp_output"
|
||||||
|
else
|
||||||
|
printf "\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output'${NORMAL}\n\n"
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Use this to fix the audio of a video that has audio in only the left or right
|
# Use this to copy audio from the left channel to the right. This does not re-encode the video.
|
||||||
# channel. This does not re-encode the video.
|
|
||||||
|
|
||||||
if which tput >/dev/null 2>&1; then
|
if which tput >/dev/null 2>&1; then
|
||||||
ncolors=$(tput colors)
|
ncolors=$(tput colors)
|
||||||
@@ -27,7 +26,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $1 == "" ]]; then
|
if [[ $1 == "" ]]; then
|
||||||
printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
|
printf "${BOLD}${RED}Usage: copy-left-audio-channel-to-right <filename> <optional output name>${NORMAL}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -43,9 +42,9 @@ else
|
|||||||
output="${output_name}.$extension"
|
output="${output_name}.$extension"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "\n${YELLOW}${BOLD}Repairing audio in $filename.$extension | output: $output${NORMAL}\n"
|
printf "\n${YELLOW}${BOLD}Copy left audio channeel to right channel in $filename.$extension | output: $output${NORMAL}\n"
|
||||||
|
|
||||||
ffmpeg -i "$filename.$extension" -c:v copy -ac 1 "$output"
|
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -c:v copy -af "pan=stereo|c0=c0|c1=c0" -map 0 "$output"
|
||||||
|
|
||||||
printf "\n${GREEN}${BOLD}Done repairing audio in $filename.$extension | output: $output${NORMAL}\n\n"
|
printf "\n${GREEN}${BOLD}Done copying left audio channel to right channel in $filename.$extension | output: $output${NORMAL}\n\n"
|
||||||
|
|
||||||
50
dotfiles/bin/copy-right-audio-channel-to-left
Normal file
50
dotfiles/bin/copy-right-audio-channel-to-left
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Use this to copy audio from the right channel to the left. This does not re-encode the video.
|
||||||
|
|
||||||
|
if which tput >/dev/null 2>&1; then
|
||||||
|
ncolors=$(tput colors)
|
||||||
|
fi
|
||||||
|
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||||
|
RED="$(tput setaf 1)"
|
||||||
|
GREEN="$(tput setaf 2)"
|
||||||
|
YELLOW="$(tput setaf 3)"
|
||||||
|
BLUE="$(tput setaf 4)"
|
||||||
|
MAGENTA="$(tput setaf 5)"
|
||||||
|
CYAN="$(tput setaf 6)"
|
||||||
|
BOLD="$(tput bold)"
|
||||||
|
NORMAL="$(tput sgr0)"
|
||||||
|
else
|
||||||
|
RED=""
|
||||||
|
GREEN=""
|
||||||
|
YELLOW=""
|
||||||
|
BLUE=""
|
||||||
|
MAGENTA=""
|
||||||
|
CYAN=""
|
||||||
|
BOLD=""
|
||||||
|
NORMAL=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $1 == "" ]]; then
|
||||||
|
printf "${BOLD}${RED}Usage: copy-right-audio-channel-to-left <filename> <optional output name>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
filename=$(basename -- "$1")
|
||||||
|
extension="${filename##*.}"
|
||||||
|
filename="${filename%.*}"
|
||||||
|
|
||||||
|
output_name="$2"
|
||||||
|
|
||||||
|
if [[ $output_name == "" ]]; then
|
||||||
|
output="${filename}_repaired_audio.$extension"
|
||||||
|
else
|
||||||
|
output="${output_name}.$extension"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n${YELLOW}${BOLD}Copy right audio channeel to left channel in $filename.$extension | output: $output${NORMAL}\n"
|
||||||
|
|
||||||
|
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -c:v copy -af "pan=stereo|c0=c1|c1=c1" -map 0 "$output"
|
||||||
|
|
||||||
|
printf "\n${GREEN}${BOLD}Done copying right audio channel to left channel in $filename.$extension | output: $output${NORMAL}\n\n"
|
||||||
|
|
||||||
45
dotfiles/bin/create-gif-from-video
Normal file
45
dotfiles/bin/create-gif-from-video
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
filename=$(basename -- "$1")
|
||||||
|
output_name="$2"
|
||||||
|
width="$3"
|
||||||
|
|
||||||
|
if [[ $filename == "" || $output_name == "" ]]; then
|
||||||
|
printf "${BOLD}${RED}Usage: create-gif-from-video <filename> <output name> <optional width, defaults to 240>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
output="${output_name}.gif"
|
||||||
|
if [[ $width == "" ]]; then
|
||||||
|
width=240
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n${YELLOW}${BOLD}Creating a gif from '$filename' | output: $output | width: $width${NORMAL}\n"
|
||||||
|
|
||||||
|
ffmpeg -y -stats -loglevel level+error -i "$filename" -vf "fps=24,scale=$width:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 "$output"
|
||||||
|
|
||||||
|
printf "\n${GREEN}${BOLD}Finished!${NORMAL}\n\n"
|
||||||
|
|
||||||
63
dotfiles/bin/embed-subtitles
Normal file
63
dotfiles/bin/embed-subtitles
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Adds subtitles to a video. You can pass multiple srt files in one go. This
|
||||||
|
# preserves all existing streams, so if you've already added subtitle tracks to
|
||||||
|
# the video then these new ones will be appended. I haven't extensively tested
|
||||||
|
# appending yet (not sure if the mapping arg is correct), so I recommend adding
|
||||||
|
# all of your tracks in one go.
|
||||||
|
|
||||||
|
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")
|
||||||
|
extension="${filename##*.}"
|
||||||
|
filename="${filename%.*}"
|
||||||
|
|
||||||
|
output_name="$2"
|
||||||
|
output="${output_name}.$extension"
|
||||||
|
|
||||||
|
shift 2
|
||||||
|
subtitles=("$@")
|
||||||
|
|
||||||
|
if [[ $filename == "" || $output_name == "" || ${#subtitles[@]} -eq 0 ]]; then
|
||||||
|
printf "${BOLD}${RED}Usage: embed-subtitles <video filename> <output name> <subtitle filenames>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n${YELLOW}${BOLD}Adding subtitles to $filename.$extension | output: $output${NORMAL}\n"
|
||||||
|
|
||||||
|
mapping="-map 0"
|
||||||
|
tracks=""
|
||||||
|
|
||||||
|
map_index=1
|
||||||
|
for track in "$@"; do
|
||||||
|
tracks+="-i \"$track\" "
|
||||||
|
mapping+=" -map $map_index"
|
||||||
|
map_index=$((map_index+1))
|
||||||
|
done
|
||||||
|
|
||||||
|
cmd="ffmpeg -i \"$filename.$extension\" $tracks $mapping -c copy -c:s mov_text \"$output\""
|
||||||
|
printf "\n${BOLD}Running: $cmd\n\n${NORMAL}"
|
||||||
|
eval $cmd
|
||||||
|
|
||||||
|
printf "\n${GREEN}${BOLD}Done adding subtitles to $filename.$extension | output: $output\n${NORMAL}"
|
||||||
@@ -1,50 +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
|
|
||||||
|
|
||||||
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"
|
|
||||||
@@ -1,5 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Extracts audio from a video. It expects you to know what audio codecs the
|
||||||
|
# video container has, e.g. it's an mp4 video with aac and m4a audio. Just set
|
||||||
|
# the format to the appropriate extension.
|
||||||
|
#
|
||||||
|
# If you want to convert to a different format or you want to change the sample
|
||||||
|
# rate, channel count, trim the audio, etc. then use transcode-audio.
|
||||||
|
|
||||||
if which tput >/dev/null 2>&1; then
|
if which tput >/dev/null 2>&1; then
|
||||||
ncolors=$(tput colors)
|
ncolors=$(tput colors)
|
||||||
fi
|
fi
|
||||||
@@ -23,13 +30,13 @@ else
|
|||||||
NORMAL=""
|
NORMAL=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
transcode="$1"
|
filename=$(basename -- "$1")
|
||||||
filename=$(basename -- "$2")
|
format="$2"
|
||||||
format="$3"
|
start_time="$3"
|
||||||
bitrate="$4"
|
end_time="$4"
|
||||||
|
|
||||||
if [[ $1 == "" || $2 == "" || $3 == "" ]]; then
|
if [[ $1 == "" || $2 == "" ]]; then
|
||||||
printf "${BOLD}${RED}Usage: $0 <transcode? 0|1 (needed when container doesn't contain format)> <filename> <format (mp3, m4a, aac, etc)> <optional: bitrate. Uses 64k when not specified, 0 = variable (e.g. 0, 64, 128, etc)>${NORMAL}\n"
|
printf "${BOLD}${RED}Usage: extract-audio-from-video <filename> <format (mp3, m4a, aac, etc)> <optional: start time HH:MM:SS, use empty string or 0 for start> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -37,19 +44,23 @@ extension="${filename##*.}"
|
|||||||
filename="${filename%.*}"
|
filename="${filename%.*}"
|
||||||
output_name="$filename.$format"
|
output_name="$filename.$format"
|
||||||
|
|
||||||
if [[ $bitrate == "" ]]; then
|
timing_args=""
|
||||||
bitrate="64"
|
if [[ $start_time != "" ]]; then
|
||||||
|
timing_args="-ss $start_time "
|
||||||
|
fi
|
||||||
|
if [[ $end_time != "" ]]; then
|
||||||
|
if [[ $start_time == "0" && $end_time == "0" ]]; then
|
||||||
|
# We treat a start and end with 0 values as no op.
|
||||||
|
timing_args=""
|
||||||
|
elif [[ $end_time != "0" ]]; then
|
||||||
|
# Handle having a start time but end time is set to 0, can just ignore it and it'll use the remainder of the video.
|
||||||
|
timing_args+="-to $end_time"
|
||||||
|
fi
|
||||||
fi
|
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 | output: $output_name | start: $start_time | end: $end_time${NORMAL}\n"
|
||||||
|
|
||||||
if [[ $transcode == "1" ]]; then
|
ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -vn -acodec copy "$output_name"
|
||||||
# Transcode audio
|
|
||||||
ffmpeg -i "$filename.$extension" -b:a ${bitrate}k -ac 2 -ar 44100 -map a "$output_name"
|
|
||||||
else
|
|
||||||
# Grab the audio stream from the video.
|
|
||||||
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"
|
||||||
|
|
||||||
|
|||||||
11
dotfiles/bin/file-checksum-md5.bat
Normal file
11
dotfiles/bin/file-checksum-md5.bat
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
if exist %1\* (
|
||||||
|
echo Run on a file
|
||||||
|
) else (
|
||||||
|
if exist "%~1_checksum-md5.txt" (
|
||||||
|
del "%~1_checksum-md5.txt"
|
||||||
|
)
|
||||||
|
certutil.exe -hashfile "%~1" MD5 > "%~1_checksum-md5.txt"
|
||||||
|
start notepad "%~1_checksum-md5.txt"
|
||||||
|
)
|
||||||
11
dotfiles/bin/file-checksum-sha1.bat
Normal file
11
dotfiles/bin/file-checksum-sha1.bat
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
if exist %1\* (
|
||||||
|
echo Run on a file
|
||||||
|
) else (
|
||||||
|
if exist "%~1_checksum-sha1.txt" (
|
||||||
|
del "%~1_checksum-sha1.txt"
|
||||||
|
)
|
||||||
|
certutil.exe -hashfile "%~1" SHA1 > "%~1_checksum-sha1.txt"
|
||||||
|
start notepad "%~1_checksum-sha1.txt"
|
||||||
|
)
|
||||||
11
dotfiles/bin/file-checksum-sha256.bat
Normal file
11
dotfiles/bin/file-checksum-sha256.bat
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
if exist %1\* (
|
||||||
|
echo Run on a file
|
||||||
|
) else (
|
||||||
|
if exist "%~1_checksum-sha256.txt" (
|
||||||
|
del "%~1_checksum-sha256.txt"
|
||||||
|
)
|
||||||
|
certutil.exe -hashfile "%~1" SHA256 > "%~1_checksum-sha256.txt"
|
||||||
|
start notepad "%~1_checksum-sha256.txt"
|
||||||
|
)
|
||||||
11
dotfiles/bin/file-checksum-sha512.bat
Normal file
11
dotfiles/bin/file-checksum-sha512.bat
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
if exist %1\* (
|
||||||
|
echo Run on a file
|
||||||
|
) else (
|
||||||
|
if exist "%~1_checksum-sha512.txt" (
|
||||||
|
del "%~1_checksum-sha512.txt"
|
||||||
|
)
|
||||||
|
certutil.exe -hashfile "%~1" SHA512 > "%~1_checksum-sha512.txt"
|
||||||
|
start notepad "%~1_checksum-sha512.txt"
|
||||||
|
)
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
cd %DEV_TOOLS%\SysinternalsSuite
|
cd /d %DEV_TOOLS%\SysinternalsSuite
|
||||||
|
|
||||||
if exist %1\* (
|
if exist %1\* (
|
||||||
echo Run on a file
|
echo Run on a file
|
||||||
) else (
|
) else (
|
||||||
if exist "%~1_Report.txt" (
|
if exist "%~1_sigcheck_report.txt" (
|
||||||
del "%~1_Report.txt"
|
del "%~1_sigcheck_report.txt"
|
||||||
)
|
)
|
||||||
sigcheck.exe /a "%~1" > "%~1_sigcheck_report.txt"
|
sigcheck64.exe /a "%~1" > "%~1_sigcheck_report.txt"
|
||||||
start notepad "%~1_sigcheck_report.txt"
|
start notepad "%~1_sigcheck_report.txt"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Re-encodes the video to get a more accurate timeline. If you want fast video joining at the expense of accuracy then use join-video-fast.
|
||||||
|
|
||||||
if which tput >/dev/null 2>&1; then
|
if which tput >/dev/null 2>&1; then
|
||||||
ncolors=$(tput colors)
|
ncolors=$(tput colors)
|
||||||
fi
|
fi
|
||||||
@@ -35,7 +37,7 @@ output="${output_name}.mp4"
|
|||||||
|
|
||||||
printf "\n${YELLOW}${BOLD}Joining contents of '$filename'| output: $output${NORMAL}\n"
|
printf "\n${YELLOW}${BOLD}Joining contents of '$filename'| output: $output${NORMAL}\n"
|
||||||
|
|
||||||
ffmpeg -f concat -safe 0 -i "$filename" -c copy "$output"
|
ffmpeg -y -stats -loglevel level+error -f concat -safe 0 -accurate_seek -i "$filename.$extension" -c:v libx264 -c:a copy "$output"
|
||||||
|
|
||||||
printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n"
|
printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n"
|
||||||
|
|
||||||
|
|||||||
46
dotfiles/bin/join-video-fast
Normal file
46
dotfiles/bin/join-video-fast
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# A fast way to join video clips that might result in some weird playback cursor timings,
|
||||||
|
# e.g. video player might show negative seconds at the start of the vid or the
|
||||||
|
# playback time might oscillate a bit. Use join-video for accurate joining at
|
||||||
|
# the cost of a much slower processing time.
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
if [[ $filename == "" || $output_name == "" ]]; then
|
||||||
|
printf "${BOLD}${RED}Usage: create a text file that lists the input video paths on separate lines using the format: file '/path/to/video'. Then call:\n\n$0 <list name> <output name>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
output="${output_name}.mp4"
|
||||||
|
|
||||||
|
printf "\n${YELLOW}${BOLD}Joining contents of '$filename'| output: $output${NORMAL}\n"
|
||||||
|
|
||||||
|
ffmpeg -y -stats -loglevel level+error -f concat -safe 0 -i "$filename" -c copy "$output"
|
||||||
|
|
||||||
|
printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n"
|
||||||
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Use this to normalize the audio of a video using the average loudness, or RMS-based normalization.
|
|
||||||
# This does not re-encode the video.
|
|
||||||
#
|
|
||||||
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
|
|
||||||
|
|
||||||
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}_normalized_audio.$extension"
|
|
||||||
else
|
|
||||||
output="${output_name}.$extension"
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "\n${YELLOW}${BOLD}Normalizing audio in $filename.$extension | output: $output${NORMAL}\n"
|
|
||||||
|
|
||||||
# This is done in two passes. The first pass will compute the mean loudness and
|
|
||||||
# the second pass will normalize the audio using the mean as the target.
|
|
||||||
|
|
||||||
# -vn, -sn, and -dn tells ffmpeg to ignore non-audio streams during the analysis. This speeds things up.
|
|
||||||
ffmpeg -i "$filename.$extension" -af "volumedetect" -vn -sn -dn -f null /dev/null
|
|
||||||
|
|
||||||
#ffmpeg -i "$filename.$extension" -c:v copy -ac 1 "$output"
|
|
||||||
|
|
||||||
printf "\n${GREEN}${BOLD}Done normalizing audio in $filename.$extension | output: $output${NORMAL}\n\n"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------
|
|
||||||
# This seems better. 2 pass using loudnorm filter.
|
|
||||||
|
|
||||||
# 1st pass: ffmpeg -i "$filename.$extension" -pass 1 -filter:a loudnorm=print_format=json -vn -sn -dn -f null /dev/null
|
|
||||||
# 2nd pass: ffmpeg -i "$filename.$extension" -c:v copy -pass 2 -filter:a loudnorm=linear=true:measured_I=$input_i:measured_LRA=$input_lra:measured_tp=$input_tp:measured_thresh=$input_thresh "$output"
|
|
||||||
|
|
||||||
# TODO: extract the $input_i, input_lra, etc from the 1st pass output so that this can be automated.
|
|
||||||
# TODO: stackoverflow said if there are subtitles or multiple vid streams then add "-map 0" before the output name. Test this.
|
|
||||||
# TODO: disable the log file or just delete it after normalizing.
|
|
||||||
77
dotfiles/bin/normalize-volume
Normal file
77
dotfiles/bin/normalize-volume
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Use this to normalize the volume of a video or audio file using the average loudness, or RMS-based normalization. It does a pretty good job!
|
||||||
|
# If you want to modify the volume manually then checkout the analyze-volume and change-volume scripts.
|
||||||
|
#
|
||||||
|
# This does not re-encode video when given a video file.
|
||||||
|
#
|
||||||
|
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
|
||||||
|
|
||||||
|
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: normalize-volume <video or audio 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}_normalized_audio.$extension"
|
||||||
|
else
|
||||||
|
output="${output_name}.$extension"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n${YELLOW}${BOLD}Normalizing audio in $filename.$extension | output: $output${NORMAL}\n"
|
||||||
|
|
||||||
|
# This is done in two passes. The first pass will compute the mean loudness and
|
||||||
|
# the second pass will normalize the audio using the mean as the target.
|
||||||
|
|
||||||
|
temp_file="/tmp/_audio_info_$RANDOM"
|
||||||
|
|
||||||
|
# 1st pass:
|
||||||
|
cmd="ffmpeg -i \"$filename.$extension\" -pass 1 -filter:a loudnorm=print_format=json -vn -sn -dn -f null /dev/null 2>&1 | sed -n '/{/,/}/p' > $temp_file"
|
||||||
|
printf "\n${BOLD}Running 1st pass:\n$cmd\n\n${NORMAL}"
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
printf "${BOLD}${GREEN}Done.\n\n${NORMAL}"
|
||||||
|
|
||||||
|
ii=`grep \"input_i\" $temp_file | cut -d: -f2 | tr -cd [:digit:].-`
|
||||||
|
itp=`grep \"input_tp\" $temp_file | cut -d: -f2 | tr -cd [:digit:].-`
|
||||||
|
ilra=`grep \"input_lra\" $temp_file | cut -d: -f2 | tr -cd [:digit:].-`
|
||||||
|
it=`grep \"input_thresh\" $temp_file | cut -d: -f2 | tr -cd [:digit:].-`
|
||||||
|
to=`grep \"target_offset\" $temp_file | cut -d: -f2 | tr -cd [:digit:].-`
|
||||||
|
|
||||||
|
# 2nd pass:
|
||||||
|
cmd="ffmpeg -y -stats -loglevel level+error -i \"$filename.$extension\" -c:v copy -pass 2 -filter:a loudnorm=linear=true:I=-16:LRA=11:tp=-1.5:measured_I=$ii:measured_LRA=$ilra:measured_tp=$itp:measured_thresh=$it:offset=$to:print_format=summary \"$output\""
|
||||||
|
printf "${BOLD}Re-encoding audio:\n$cmd\n\n${NORMAL}"
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
printf "\n${GREEN}${BOLD}Done normalizing volume in $filename.$extension | output: $output${NORMAL}\n"
|
||||||
|
rm $temp_file
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $1 == "" ]]; then
|
if [[ $1 == "" ]]; then
|
||||||
printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
|
printf "${BOLD}${RED}Usage: remove-audio-from-video <filename> <optional output name>${NORMAL}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ fi
|
|||||||
printf "\n${YELLOW}${BOLD}Removing audio from '$filename.$extension' | output: '$output'${NORMAL}\n"
|
printf "\n${YELLOW}${BOLD}Removing audio from '$filename.$extension' | output: '$output'${NORMAL}\n"
|
||||||
|
|
||||||
# -an removes the audio.
|
# -an removes the audio.
|
||||||
ffmpeg -i "$filename.$extension" -c:v copy -an "$output"
|
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -c:v copy -an -map 0 "$output"
|
||||||
|
|
||||||
printf "\n${GREEN}${BOLD}Done removing audio from '$filename.$extension' | output: '$output'${NORMAL}\n\n"
|
printf "\n${GREEN}${BOLD}Done removing audio from '$filename.$extension' | output: '$output'${NORMAL}\n\n"
|
||||||
|
|
||||||
|
|||||||
71
dotfiles/bin/transcode-audio
Normal file
71
dotfiles/bin/transcode-audio
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Transcodes audio from a video or audio source into a new audio file. If you
|
||||||
|
# just want the audio from a video as-is then use extract-audio-from-video
|
||||||
|
|
||||||
|
if which tput >/dev/null 2>&1; then
|
||||||
|
ncolors=$(tput colors)
|
||||||
|
fi
|
||||||
|
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||||
|
RED="$(tput setaf 1)"
|
||||||
|
GREEN="$(tput setaf 2)"
|
||||||
|
YELLOW="$(tput setaf 3)"
|
||||||
|
BLUE="$(tput setaf 4)"
|
||||||
|
MAGENTA="$(tput setaf 5)"
|
||||||
|
CYAN="$(tput setaf 6)"
|
||||||
|
BOLD="$(tput bold)"
|
||||||
|
NORMAL="$(tput sgr0)"
|
||||||
|
else
|
||||||
|
RED=""
|
||||||
|
GREEN=""
|
||||||
|
YELLOW=""
|
||||||
|
BLUE=""
|
||||||
|
MAGENTA=""
|
||||||
|
CYAN=""
|
||||||
|
BOLD=""
|
||||||
|
NORMAL=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
filename="$1"
|
||||||
|
output_name="$2"
|
||||||
|
sample_rate="$3"
|
||||||
|
channel_count="$4"
|
||||||
|
start_time="$5"
|
||||||
|
end_time="$6"
|
||||||
|
|
||||||
|
output_base=$(basename -- "$output_name")
|
||||||
|
output_extension="${output_base##*.}"
|
||||||
|
|
||||||
|
if [[ $filename == "" || $output_extension == "" || $output_extension == $output_base ]]; then
|
||||||
|
printf "${BOLD}${RED}Usage: transcode-audio <filename> <output name w/ extension> <optional: sample rate. Defaults to 44100> <optional: channel count. Defaults to 2> <optional: start time HH:MM:SS, use empty string or 0 for start> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $sample_rate == "" ]]; then
|
||||||
|
sample_rate="44100"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $channel_count == "" ]]; then
|
||||||
|
channel_count="2"
|
||||||
|
fi
|
||||||
|
|
||||||
|
timing_args=""
|
||||||
|
if [[ $start_time != "" ]]; then
|
||||||
|
timing_args="-ss $start_time "
|
||||||
|
fi
|
||||||
|
if [[ $end_time != "" ]]; then
|
||||||
|
if [[ $start_time == "0" && $end_time == "0" ]]; then
|
||||||
|
# We treat a start and end with 0 values as no op.
|
||||||
|
timing_args=""
|
||||||
|
elif [[ $end_time != "0" ]]; then
|
||||||
|
# Handle having a start time but end time is set to 0, can just ignore it and it'll use the remainder of the video.
|
||||||
|
timing_args+="-to $end_time"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n${YELLOW}${BOLD}Extracting audio from '$filename' | output: '$output_name' | sample rate: $sample_rate | channels: $channel_count | start: $start_time | end: $end_time${NORMAL}\n"
|
||||||
|
|
||||||
|
ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename" -ar $sample_rate -ac $channel_count -map a "$output_name"
|
||||||
|
|
||||||
|
printf "\n${GREEN}${BOLD}Done extracting audio from '$filename' | output '$output_name'${NORMAL}\n\n"
|
||||||
|
|
||||||
@@ -52,11 +52,8 @@ output_name_without_ext="$2"
|
|||||||
model="$3"
|
model="$3"
|
||||||
threads=$4
|
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
|
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"
|
printf "${BOLD}${RED}Usage: transcribe-audio <input.wav> <output name without extension> <model name> <optional: thread count>${NORMAL}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -65,19 +62,27 @@ if [[ ! -f "$input_wav" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $threads == "" ]]; then
|
|
||||||
threads=$default_thread_count
|
|
||||||
fi
|
|
||||||
|
|
||||||
output_name="$output_name_without_ext.${model}"
|
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.
|
# 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.
|
# 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.
|
# 8 threads, 4 cores is good too for tiny,small and 2 threads, 4 cores for medium.
|
||||||
|
|
||||||
threads=31 #keep a thread for me
|
|
||||||
|
# 4 seems to be the sweet spot for most models, except medium might be faster with 8.
|
||||||
|
# But on my 5950x, running 1 core with 31 threads is quite fast.
|
||||||
|
#default_thread_count=4
|
||||||
cores=1
|
cores=1
|
||||||
|
default_thread_count=31
|
||||||
|
|
||||||
|
if [[ $threads == "" ]]; then
|
||||||
|
threads=$default_thread_count
|
||||||
|
|
||||||
|
# This is only useful when not setting the core count and defaulting to 4 threads.
|
||||||
|
#if [[ $model == "medium" || $model == "large" ]]; then
|
||||||
|
# threads=8
|
||||||
|
#fi
|
||||||
|
fi
|
||||||
|
|
||||||
printf "\n${YELLOW}${BOLD}Transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name ${NORMAL}\n"
|
printf "\n${YELLOW}${BOLD}Transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name ${NORMAL}\n"
|
||||||
|
|
||||||
@@ -85,7 +90,12 @@ whisper_fullname="$(expand_path $(which whisper.exe))"
|
|||||||
whisper_path="$(dirname $whisper_fullname)"
|
whisper_path="$(dirname $whisper_fullname)"
|
||||||
models_path="$whisper_path/models"
|
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
|
if [[ $model != "large" ]]; then
|
||||||
|
model="${model}.en"
|
||||||
|
fi
|
||||||
|
|
||||||
|
whisper.exe --processors ${cores} --threads ${threads} -m "$models_path/ggml-${model}.bin" -otxt -osrt -f "$input_wav" -of "$output_name" --print-colors --print-progress
|
||||||
|
|
||||||
error=$?
|
error=$?
|
||||||
if [[ error -eq 0 ]]; then
|
if [[ error -eq 0 ]]; then
|
||||||
printf "${GREEN}${BOLD}Done transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name${NORMAL}\n"
|
printf "${GREEN}${BOLD}Done transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name${NORMAL}\n"
|
||||||
|
|||||||
@@ -25,11 +25,13 @@ fi
|
|||||||
|
|
||||||
input_video="$1"
|
input_video="$1"
|
||||||
output_name_without_ext="$2"
|
output_name_without_ext="$2"
|
||||||
shift 2
|
start_time="$3"
|
||||||
|
end_time="$4"
|
||||||
|
shift 4
|
||||||
models=("$@")
|
models=("$@")
|
||||||
|
|
||||||
if [[ $input_video == "" || $output_name_without_ext == "" || ${#models[@]} -eq 0 ]]; then
|
if [[ $input_video == "" || $output_name_without_ext == "" || $start_time == "" || $end_time == "" || ${#models[@]} -eq 0 ]]; then
|
||||||
printf "${BOLD}${RED}Usage: $0 <input.mp4> <output name without extension> <list of model names to use>${NORMAL}\n"
|
printf "${BOLD}${RED}Usage: transcribe-video <input.mp4> <output name without extension> <start time HH:MM:SS, use 0 for start> <end time HH:MM:SS, use 0 for no value> <list of model names to use>${NORMAL}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -43,17 +45,13 @@ if [[ input_extension != "wav" ]]; then
|
|||||||
wav_name="${wav_name}.wav"
|
wav_name="${wav_name}.wav"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
extract-16bit-wav-from-video "$input_video" "$wav_name"
|
channel_count=1
|
||||||
|
sample_rate=16000
|
||||||
|
transcode-audio "$input_video" "$wav_name" $sample_rate $channel_count $start_time $end_time
|
||||||
if [[ $? == 1 ]]; then exit 1; fi
|
if [[ $? == 1 ]]; then exit 1; fi
|
||||||
|
|
||||||
for model in "$@"; do
|
for model in "$@"; do
|
||||||
# Tweak thread count based on model size.
|
transcribe-audio "$wav_name" "$output_name_without_ext" "${model}"
|
||||||
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
|
if [[ $? == 1 ]]; then
|
||||||
printf "${RED}${BOLD}Saving the audio file \"$wav_name\" in case you want to reuse it for debugging.\n${NORMAL}"
|
printf "${RED}${BOLD}Saving the audio file \"$wav_name\" in case you want to reuse it for debugging.\n${NORMAL}"
|
||||||
|
|||||||
@@ -1,2 +1,37 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
transcribe-video "$1" "$2" "base"
|
|
||||||
|
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 [[ $2 == "" ]]; then
|
||||||
|
printf "${BOLD}${RED}Usage: transcribe-video-base <input.mp4> <output name without extension> <optional: start time HH:MM:SS, use 0 for start> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
start_time="$3"
|
||||||
|
end_time="$4"
|
||||||
|
|
||||||
|
if [[ $start_time == "" ]]; then start_time="0"; fi
|
||||||
|
if [[ $end_time == "" ]]; then end_time="0"; fi
|
||||||
|
|
||||||
|
transcribe-video "$1" "$2" $start_time $end_time "base"
|
||||||
|
|||||||
@@ -1,2 +1,37 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
transcribe-video "$1" "$2" "medium"
|
|
||||||
|
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 [[ $2 == "" ]]; then
|
||||||
|
printf "${BOLD}${RED}Usage: transcribe-video-medium <input.mp4> <output name without extension> <optional: start time HH:MM:SS, use 0 for start> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
start_time="$3"
|
||||||
|
end_time="$4"
|
||||||
|
|
||||||
|
if [[ $start_time == "" ]]; then start_time="0"; fi
|
||||||
|
if [[ $end_time == "" ]]; then end_time="0"; fi
|
||||||
|
|
||||||
|
transcribe-video "$1" "$2" $start_time $end_time "medium"
|
||||||
|
|||||||
@@ -1,2 +1,37 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
transcribe-video "$1" "$2" "small"
|
|
||||||
|
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 [[ $2 == "" ]]; then
|
||||||
|
printf "${BOLD}${RED}Usage: transcribe-video-small <input.mp4> <output name without extension> <optional: start time HH:MM:SS, use 0 for start> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
start_time="$3"
|
||||||
|
end_time="$4"
|
||||||
|
|
||||||
|
if [[ $start_time == "" ]]; then start_time="0"; fi
|
||||||
|
if [[ $end_time == "" ]]; then end_time="0"; fi
|
||||||
|
|
||||||
|
transcribe-video "$1" "$2" $start_time $end_time "small"
|
||||||
|
|||||||
@@ -1,2 +1,37 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
transcribe-video "$1" "$2" "tiny"
|
|
||||||
|
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 [[ $2 == "" ]]; then
|
||||||
|
printf "${BOLD}${RED}Usage: transcribe-video-tiny <input.mp4> <output name without extension> <optional: start time HH:MM:SS, use 0 for start> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
start_time="$3"
|
||||||
|
end_time="$4"
|
||||||
|
|
||||||
|
if [[ $start_time == "" ]]; then start_time="0"; fi
|
||||||
|
if [[ $end_time == "" ]]; then end_time="0"; fi
|
||||||
|
|
||||||
|
transcribe-video "$1" "$2" $start_time $end_time "tiny"
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
#!/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"
|
|
||||||
|
|
||||||
57
dotfiles/bin/trim-audio
Normal file
57
dotfiles/bin/trim-audio
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Re-encodes the audio to get a more accurate seek time.
|
||||||
|
|
||||||
|
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="$1"
|
||||||
|
output_name_with_extension="$2"
|
||||||
|
start_time="$3"
|
||||||
|
end_time="$4"
|
||||||
|
|
||||||
|
if [[ $filename == "" || $output_name_with_extension == "" || $start_time == "" ]]; then
|
||||||
|
printf "${BOLD}${RED}Usage: trim-audio <filename> <output name w/ extension> <start time HH:MM:SS> <optional: end time HH:MM:SS, set to empty string or 0 for no value>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
timing_args=""
|
||||||
|
if [[ $start_time != "" ]]; then
|
||||||
|
timing_args="-ss $start_time "
|
||||||
|
fi
|
||||||
|
if [[ $end_time != "" ]]; then
|
||||||
|
if [[ $start_time == "0" && $end_time == "0" ]]; then
|
||||||
|
# We treat a start and end with 0 values as no op.
|
||||||
|
timing_args=""
|
||||||
|
elif [[ $end_time != "0" ]]; then
|
||||||
|
# Handle having a start time but end time is set to 0, can just ignore it and it'll use the remainder of the video.
|
||||||
|
timing_args+="-to $end_time"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n${YELLOW}${BOLD}Trimming '$filename' | output: $output_name_with_extension | start: $start_time | end: $end_time${NORMAL}\n"
|
||||||
|
|
||||||
|
ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename" -map a "$output_name_with_extension"
|
||||||
|
|
||||||
|
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
|
||||||
|
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Re-encodes the video to get a more accurate seek time. If you want fast trimming at the expense of accuracy then use trim-video-fast.
|
||||||
|
|
||||||
if which tput >/dev/null 2>&1; then
|
if which tput >/dev/null 2>&1; then
|
||||||
ncolors=$(tput colors)
|
ncolors=$(tput colors)
|
||||||
fi
|
fi
|
||||||
@@ -28,19 +30,35 @@ output_name="$2"
|
|||||||
start_time="$3"
|
start_time="$3"
|
||||||
end_time="$4"
|
end_time="$4"
|
||||||
|
|
||||||
if [[ $filename == "" || $output_name == "" || $start_time == "" || $end_time == "" ]]; then
|
if [[ $filename == "" || $output_name == "" || $start_time == "" ]]; then
|
||||||
printf "${BOLD}${RED}Usage: $0 <filename> <output name> <start time HH:MM:SS> <end time HH:MM:SS>${NORMAL}\n"
|
printf "${BOLD}${RED}Usage: trim-video <filename> <output name> <start time HH:MM:SS> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
extension="${filename##*.}"
|
extension="${filename##*.}"
|
||||||
filename="${filename%.*}"
|
filename="${filename%.*}"
|
||||||
output="${output_name}.$extension"
|
output="${output_name}.$extension"
|
||||||
timing_args="-ss $start_time -to $end_time"
|
|
||||||
|
timing_args=""
|
||||||
|
if [[ $start_time != "" ]]; then
|
||||||
|
timing_args="-ss $start_time "
|
||||||
|
fi
|
||||||
|
if [[ $end_time != "" ]]; then
|
||||||
|
if [[ $start_time == "0" && $end_time == "0" ]]; then
|
||||||
|
# We treat a start and end with 0 values as no op.
|
||||||
|
timing_args=""
|
||||||
|
elif [[ $end_time != "0" ]]; then
|
||||||
|
# Handle having a start time but end time is set to 0, can just ignore it and it'll use the remainder of the video.
|
||||||
|
timing_args+="-to $end_time"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time${NORMAL}\n"
|
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 copy "$output"
|
# You might have issues if the file has multiple video streams or embedded subtitles. The -map 0 arg is typically given
|
||||||
|
# when copying a video stream, but I'm not sure if it's appropriate to use here.
|
||||||
|
# Trying out async to keep video and audio synced.
|
||||||
|
ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -async 1 -i "$filename.$extension" -c:v libx264 -c:a copy "$output"
|
||||||
|
|
||||||
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
|
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
|
||||||
|
|
||||||
|
|||||||
66
dotfiles/bin/trim-video-fast
Normal file
66
dotfiles/bin/trim-video-fast
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# A fast video trim that might result in some weird seek timings, e.g. video
|
||||||
|
# player might show negative seconds at the start of the vid or the playback
|
||||||
|
# time might oscillate a bit. Use trim-video for accurate trimming at the cost
|
||||||
|
# of a much slower processing time.
|
||||||
|
|
||||||
|
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 == "" ]]; then
|
||||||
|
printf "${BOLD}${RED}Usage: trim-video-fast <filename> <output name> <start time HH:MM:SS> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
extension="${filename##*.}"
|
||||||
|
filename="${filename%.*}"
|
||||||
|
output="${output_name}.$extension"
|
||||||
|
|
||||||
|
timing_args=""
|
||||||
|
if [[ $start_time != "" ]]; then
|
||||||
|
timing_args="-ss $start_time "
|
||||||
|
fi
|
||||||
|
if [[ $end_time != "" ]]; then
|
||||||
|
if [[ $start_time == "0" && $end_time == "0" ]]; then
|
||||||
|
# We treat a start and end with 0 values as no op.
|
||||||
|
timing_args=""
|
||||||
|
elif [[ $end_time != "0" ]]; then
|
||||||
|
# Handle having a start time but end time is set to 0, can just ignore it and it'll use the remainder of the video.
|
||||||
|
timing_args+="-to $end_time"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time${NORMAL}\n"
|
||||||
|
|
||||||
|
# You might have issues if the file has multiple video streams or embedded subtitles. The -map 0 arg is typically given
|
||||||
|
# when copying a video stream, but I'm not sure if it's appropriate to use here.
|
||||||
|
ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c copy "$output"
|
||||||
|
|
||||||
|
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ if [[ -d "/c/msys64" ]]; then
|
|||||||
shell_is_mingw is_mingw
|
shell_is_mingw is_mingw
|
||||||
if [[ $is_mingw -eq 1 ]]; then
|
if [[ $is_mingw -eq 1 ]]; then
|
||||||
printf "${BOLD}${YELLOW}Updating MinGW Shell${NORMAL}\n"
|
printf "${BOLD}${YELLOW}Updating MinGW Shell${NORMAL}\n"
|
||||||
pacman -Syu
|
pacman --sync --refresh --sysupgrade
|
||||||
printf "${BOLD}${GREEN}Done!${NORMAL}\n"
|
printf "${BOLD}${GREEN}Done!${NORMAL}\n"
|
||||||
printf "\n${BOLD}Re-run this in a new shell if the updater requires the shells to be closed.\n"
|
printf "\n${BOLD}Re-run this in a new shell if the updater requires the shells to be closed.\n"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,13 +1,79 @@
|
|||||||
# Arch Linux
|
# Arch Linux
|
||||||
|
|
||||||
|
ughhhhhh had to reinstall the test vm like 5 times. finally got lxqt with virtualbox driver to load the desktop
|
||||||
|
but networking is not working. Perf is kinda shitty. UI is shitty. QT sucks. I hate linux.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
* Installation guide https://wiki.archlinux.org/title/Installation_guide
|
||||||
|
* Can go through manually or use the new guided installer: `archinstall`
|
||||||
|
|
||||||
|
* use btrfs file system
|
||||||
|
* I guess I should enable compression but I'm not sure how it affects perf.
|
||||||
|
|
||||||
|
* I tried Luks disk encryption in a VirtualBox VM and I couldn't get into the
|
||||||
|
desktop. Locks up on login. Not sure if it's related to this...can try
|
||||||
|
encryption on a real install.
|
||||||
|
|
||||||
|
* desktop environment
|
||||||
|
**VM Test**
|
||||||
|
* lxqt, vmware graphics driver, lightdm-slick-greeter
|
||||||
|
|
||||||
|
* lxqt - X11 based. I was using lxde in the past but it was abandoned by
|
||||||
|
the original team. They made lxqt. It's QT based which is lame but might
|
||||||
|
be fine. This is lightweight and I have my old configs (for LXDE and
|
||||||
|
OpenBox) which might still be usable.
|
||||||
|
|
||||||
|
* sway - Wayland based. Martins uses this. I want to try it but it lacks
|
||||||
|
nvidia driver support and requires something called wlroots? I don't
|
||||||
|
want to mess with this in my testing vm. Maybe later if I do a proper
|
||||||
|
Arch install.
|
||||||
|
* https://github.com/tyqualters/sway-nvidia-guide
|
||||||
|
* https://www.reddit.com/r/archlinux/comments/yuu7ra/whats_the_difference_between_nvidia_and_nvidiaopen/
|
||||||
|
* using seatd for hardware device collection
|
||||||
|
|
||||||
|
## Graphics
|
||||||
|
|
||||||
|
* card family https://nouveau.freedesktop.org/CodeNames.html
|
||||||
|
* nvidia driver install guide https://github.com/korvahannu/arch-nvidia-drivers-installation-guide?tab=readme-ov-file
|
||||||
|
|
||||||
|
|
||||||
|
Martins — 06/17/2024 2:59 PM
|
||||||
|
if you don't want upstream releases then obviously arch is not for you, but
|
||||||
|
they have simple solution for that - aur, you can keep managing your
|
||||||
|
dependencies separately from system packages
|
||||||
|
|
||||||
|
Martins uses Sway:
|
||||||
|
Martins — 04/08/2024 10:41 PM
|
||||||
|
no, .bashrc
|
||||||
|
I have autologin on tty1
|
||||||
|
so whenever .bashrc executes on tty1, it starts sway:
|
||||||
|
|
||||||
|
if [ -z "${WAYLAND_DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then
|
||||||
|
export _JAVA_AWT_WM_NONREPARENTING=1
|
||||||
|
export SDL_VIDEODRIVER=wayland
|
||||||
|
export GDK_BACKEND=wayland
|
||||||
|
export CLUTTER_BACKEND=wayland
|
||||||
|
export QT_QPA_PLATFORM=wayland
|
||||||
|
export BEMENU_BACKEND=wayland
|
||||||
|
export TERMINAL=foot
|
||||||
|
export BROWSER=firefox
|
||||||
|
export MOZ_ENABLE_WAYLAND=1
|
||||||
|
export XDG_SESSION_TYPE=wayland
|
||||||
|
export XDG_CURRENT_DESKTOP=sway
|
||||||
|
exec systemd-cat -- sway
|
||||||
|
fi
|
||||||
|
|
||||||
|
Saw this on reddit: sudo pacman -S wayland xorg-xwayland xorg-xlsclients sway swaybg swaylock waybar wofi -y
|
||||||
|
What is wofi ?
|
||||||
|
|
||||||
|
|
||||||
* `config/` -> map contents to `~/.config`.
|
* `config/` -> map contents to `~/.config`.
|
||||||
* `home/` -> map contents to `~/`.
|
* `home/` -> map contents to `~/`.
|
||||||
|
|
||||||
# Setup
|
|
||||||
|
|
||||||
* Full disk encryption with Veracrypt
|
|
||||||
|
|
||||||
* Store /tmp in RAM
|
* Store /tmp in RAM
|
||||||
|
* 2024: looks like it's done by default. See https://wiki.archlinux.org/title/Tmpfs
|
||||||
|
|
||||||
* Move browser cache directories to /tmp as a means of reducing file writes on SSD
|
* Move browser cache directories to /tmp as a means of reducing file writes on SSD
|
||||||
|
|
||||||
|
|||||||
@@ -375,6 +375,8 @@ make_link() {
|
|||||||
if [[ $dest_has_space -eq 1 ]]; then cmd_dest_path="\"$cmd_dest_path\""; fi
|
if [[ $dest_has_space -eq 1 ]]; then cmd_dest_path="\"$cmd_dest_path\""; fi
|
||||||
link_cmd="cmd //c 'mklink $cmd_dest_path $cmd_source_path'"
|
link_cmd="cmd //c 'mklink $cmd_dest_path $cmd_source_path'"
|
||||||
else
|
else
|
||||||
|
cmd_source_path="$final_src"
|
||||||
|
cmd_dest_path="$final_dest"
|
||||||
if [[ $source_has_space -eq 1 ]]; then cmd_source_path="\"$cmd_source_path\""; fi
|
if [[ $source_has_space -eq 1 ]]; then cmd_source_path="\"$cmd_source_path\""; fi
|
||||||
if [[ $dest_has_space -eq 1 ]]; then cmd_dest_path="\"$cmd_dest_path\""; fi
|
if [[ $dest_has_space -eq 1 ]]; then cmd_dest_path="\"$cmd_dest_path\""; fi
|
||||||
link_cmd="ln -sf $cmd_source_path $cmd_dest_path"
|
link_cmd="ln -sf $cmd_source_path $cmd_dest_path"
|
||||||
|
|||||||
@@ -41,6 +41,11 @@
|
|||||||
127.0.0.1 mpa.autodesk.com #[Autodesk Analytics Client Service]
|
127.0.0.1 mpa.autodesk.com #[Autodesk Analytics Client Service]
|
||||||
127.0.0.1 sv.symcd.com #[Autodesk Download Manager]
|
127.0.0.1 sv.symcd.com #[Autodesk Download Manager]
|
||||||
|
|
||||||
|
# Dangerous polyfill
|
||||||
|
|
||||||
|
127.0.0.1 polyfill.io
|
||||||
|
|
||||||
|
|
||||||
# Very invasive info tracker
|
# Very invasive info tracker
|
||||||
127.0.0.1 static.audienceinsights.net
|
127.0.0.1 static.audienceinsights.net
|
||||||
127.0.0.1 api.behavioralengine.com
|
127.0.0.1 api.behavioralengine.com
|
||||||
@@ -15820,3 +15825,15 @@
|
|||||||
127.0.0.1 spynetalt.microsoft.com
|
127.0.0.1 spynetalt.microsoft.com
|
||||||
# End of en inserted by Spybot Anti-Beacon for Windows 10
|
# End of en inserted by Spybot Anti-Beacon for Windows 10
|
||||||
|
|
||||||
|
# TailscaleHostsSectionStart
|
||||||
|
# This section contains MagicDNS entries for Tailscale.
|
||||||
|
# Do not edit this section manually.
|
||||||
|
|
||||||
|
100.69.212.80 gamma.sir-pinecone.github.beta.tailscale.net.
|
||||||
|
100.69.212.80 gamma.taile86d5.ts.net. gamma
|
||||||
|
100.105.152.57 quark.sir-pinecone.github.beta.tailscale.net.
|
||||||
|
100.105.152.57 quark.taile86d5.ts.net. quark
|
||||||
|
100.90.157.82 samsung-sm-s901w.sir-pinecone.github.beta.tailscale.net.
|
||||||
|
100.90.157.82 samsung-sm-s901w.taile86d5.ts.net. samsung-sm-s901w
|
||||||
|
|
||||||
|
# TailscaleHostsSectionEnd
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
# Windows Setup
|
# Windows Setup
|
||||||
|
|
||||||
* Make a system restore point after a fresh install.
|
* Disable Microsoft's piece of shit Secure Time Seed (STS) because it can result in insane system clock times that wreck havoc.
|
||||||
|
* Open regedit and go to `KEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config`
|
||||||
|
* Set `UtilizeSslTimeDat` to 0 and reboot.
|
||||||
|
|
||||||
* Disable Windows Platform Binary Table
|
* Disable Windows Platform Binary Table
|
||||||
* This is a system Windows made for hardware vendors to inject firmware to the OS drive, running it at boot time.
|
* This is a system Windows made for hardware vendors to inject firmware to the OS drive, running it at boot time.
|
||||||
@@ -9,17 +11,45 @@
|
|||||||
that they're corporate systems have been hacked multiple times in the last year). Anyway, this feature is fucking
|
that they're corporate systems have been hacked multiple times in the last year). Anyway, this feature is fucking
|
||||||
dumb and you can be sure that all mobo vendors are using this stupid shit. I don't blame them though since Microsoft
|
dumb and you can be sure that all mobo vendors are using this stupid shit. I don't blame them though since Microsoft
|
||||||
built this for them. There's no way to stop this from happening other than to disable the platform entirely.
|
built this for them. There's no way to stop this from happening other than to disable the platform entirely.
|
||||||
* Run `disable-windows-platform-binary-table.reg` and reboot.
|
* Open `disable-windows-platform-binary-table.reg` and reboot.
|
||||||
|
|
||||||
* Change PC name and reboot
|
**Make a system restore point before proceeding.**
|
||||||
|
|
||||||
|
* Change PC name
|
||||||
* Open settings -> System -> About -> Rename this PC
|
* Open settings -> System -> About -> Rename this PC
|
||||||
|
* Reboot
|
||||||
|
|
||||||
* Disable the annoying Windows alert sound that plays when doing things like using a terminal, hitting tab to autocomplete and it has no match.
|
* Optionally target a specific Windows release for updates
|
||||||
* Open C:/windows/media
|
* Useful when you want to stay on a specific release or install one that isn't yet available to you, e.g. running Win10 21H1, want 22H2.
|
||||||
* Find `Windows Background.wav`
|
* If you don't care and just want Windows to give you the release when your system is selected then you probably want to disable the policy
|
||||||
* Right-click -> Properties -> Security -> Advanced -> Change Owner from `TrustedInstaller` to your user account -> Apply
|
instead of leaving it as "not configured". I wasn't getting 22H2 and Windows Update claimed this policy was in use. I had to target 22H2
|
||||||
* Back in the previous Security tab, click Edit to change permisisons -> add your user account and grant all permissions
|
to get it and then I left the option disabled. So, you might want to try disabled from the get-go and see how it plays out.
|
||||||
* Now you can delete the file or rename it.
|
* Group policy editor:
|
||||||
|
* Administrative Templates -> Windows Components -> Windows Update -> Windows Update for Business
|
||||||
|
* Enable `Select the target Feature Update version`, set the product to `Windows 10` and the version to `22H2` or whatever you want.
|
||||||
|
* Now check for new Windows updates, should pick up the target version.
|
||||||
|
|
||||||
|
* Review trusted root certificate authorities
|
||||||
|
* Open the Microsoft Management Console (win+r, mmc)
|
||||||
|
* File -> Add/Remove Snap-in -> Certificates -> Add
|
||||||
|
* Choose `Computer Account` -> Next -> select `Local computer` -> Finish -> OK
|
||||||
|
* Expand the cert tree -> click on `Trusted Root Certificate Authorities` -> `Certificates`
|
||||||
|
* Before deleting a certificate, export it as a backup in case it's needed for system operation. Can also make a
|
||||||
|
restore point before making any changes.
|
||||||
|
* Note: I'm putting exports in backups/windows_certificates
|
||||||
|
|
||||||
|
* Maybe disable swapfile
|
||||||
|
* Not a good idea to have this turned on for SSDs since it's extra writes, and writing to an SSD degrades the drive. Probably best to put this on a spinning disk.
|
||||||
|
It's unclear if it's a bad idea to entirely disable on Windows 10 & 11. You likely won't have an issue if you have lots of RAM, but apparently its used for other
|
||||||
|
things like sleeping apps, kernel dumps, etc. It's possible that disabling it will affect your PC performance. Whether that's noticeable is something I'm unsure of.
|
||||||
|
* Advanced System Settings -> Advanced -> Performance settings -> Advanced -> Change paging settings -> set the drives to none
|
||||||
|
* Reboot
|
||||||
|
|
||||||
|
* Download [O&O ShutUp10](https://www.oo-software.com/en/shutup10) and disable things.
|
||||||
|
|
||||||
|
* Download [InControl](https://www.grc.com/incontrol.htm) to stop Microsoft from pushing Windows 11.
|
||||||
|
|
||||||
|
* Install Open-Shell to restore the start menu to the sensible Windows 7 style.
|
||||||
|
|
||||||
* Disable `Enhance Pointer Precision`:
|
* Disable `Enhance Pointer Precision`:
|
||||||
* Mouse Properties -> Pointer Options -> Motion section
|
* Mouse Properties -> Pointer Options -> Motion section
|
||||||
@@ -27,43 +57,6 @@
|
|||||||
* Laptop: change touchpad sensitivity to medium or high in order to prevent mouse movement when palm touches the pad while typing.
|
* Laptop: change touchpad sensitivity to medium or high in order to prevent mouse movement when palm touches the pad while typing.
|
||||||
* If using a Lenovo then disable touchpad lock in the Lenovo Vantage app.
|
* If using a Lenovo then disable touchpad lock in the Lenovo Vantage app.
|
||||||
|
|
||||||
* Map caps key to left-ctrl
|
|
||||||
* If the keyboard supports remapping at the hardware level (e.g. like the Keychron keyboards) then map it there and this should cover all
|
|
||||||
use cases, including Steam Link which for some reason does not respect the various remapping setups (except for PowerTools - see below).
|
|
||||||
* For software based remapping, there are two options:
|
|
||||||
* Use SharpKeys for a simple config change in Windows. You don't have to run any software at startup to get the remapping. The downside is that
|
|
||||||
this doesn't work over Steam Link.
|
|
||||||
* Use Bill Microsoft's [PowerTools](https://github.com/microsoft/PowerToys/releases/). Install it and then go to the key remapper tool in the settings.
|
|
||||||
This works over Steam Link but it requires you to run the program to get the remapping. If you go down this path then be sure to go through the settings
|
|
||||||
and disable the various tools that you don't want.
|
|
||||||
|
|
||||||
* Download [O&O ShutUp10](https://www.oo-software.com/en/shutup10) and disable things.
|
|
||||||
|
|
||||||
* Download [InControl](https://www.grc.com/incontrol.htm) to stop Microsoft from pushing Windows 11.
|
|
||||||
|
|
||||||
* Disable Corana: group policy -> Administrative Templates -> Search -> disable the "Allow Cortana ..." settings.
|
|
||||||
|
|
||||||
* Install Open-Shell to restore the start menu to the sensible Windows 7 style.
|
|
||||||
|
|
||||||
* Pin "This PC" to taskbar
|
|
||||||
* In Win 10 start menu, search for "This PC", right click top result and pin to taskbar
|
|
||||||
|
|
||||||
* Configure Explorer's options
|
|
||||||
* Open file explorer, click on File menu then options or "Change folder and search options"
|
|
||||||
* General tab
|
|
||||||
* `Open File Explorer to: This PC`
|
|
||||||
* Uncheck `Show recently used files in Quick access`
|
|
||||||
* Uncheck `Show frequently used folder in Quick access`
|
|
||||||
* View tab
|
|
||||||
* Check `Show hidden files, folders, or drives`,
|
|
||||||
* Uncheck `Hide extensions for known file types`
|
|
||||||
|
|
||||||
* Disable reopening apps on startup
|
|
||||||
* Windows settings -> Account -> Sign in options -> Privacy section: turn off `Use my sign-in info to automatically finish setting up device`
|
|
||||||
|
|
||||||
* Disable window suggestion when snapping a window
|
|
||||||
* Windows settings -> System -> Multitasking -> uncheck "When I snap a window, show what I can snap next to it"
|
|
||||||
|
|
||||||
* Desktop: turn off hibernation
|
* Desktop: turn off hibernation
|
||||||
* Open admin cmd prompt: `powercfg.exe /hibernate off`
|
* Open admin cmd prompt: `powercfg.exe /hibernate off`
|
||||||
|
|
||||||
@@ -73,12 +66,7 @@
|
|||||||
* Double-click the `Turn off Power Throttling` policy.
|
* Double-click the `Turn off Power Throttling` policy.
|
||||||
* Select Enabled.
|
* Select Enabled.
|
||||||
|
|
||||||
* Disable reserved network bandwidth
|
* Enable Ultimate Power Plan (alternatively make a new plan and set the min/max processor speed to 100%)
|
||||||
* winkey+r -> `gpedit.msc`.
|
|
||||||
* Computer Configuration > Administrative Templates > Network > QoS Packet Scheduler > Limit reservable bandwidth
|
|
||||||
* Enable it and set the % to 0.
|
|
||||||
|
|
||||||
* Enable ultimate power plan (alternatively make a new plan and set the min/max processor speed to 100%)
|
|
||||||
* Open cmd as admin, run `powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61`
|
* Open cmd as admin, run `powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61`
|
||||||
* Can now select the ultimate power plan in power options.
|
* Can now select the ultimate power plan in power options.
|
||||||
|
|
||||||
@@ -88,6 +76,17 @@
|
|||||||
* AFAIK this only works for Intel CPUs; not sure how to do the same thing on AMD.
|
* 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%.
|
* In the power plan set the processor min/max speed to 99%.
|
||||||
|
|
||||||
|
* Disable reserved network bandwidth
|
||||||
|
* winkey+r -> `gpedit.msc`.
|
||||||
|
* Computer Configuration > Administrative Templates > Network > QoS Packet Scheduler > Limit reservable bandwidth
|
||||||
|
* Enable it and set the % to 0.
|
||||||
|
|
||||||
|
* Disable auto folder type discovery to speed up opening folders with a lot of files
|
||||||
|
* Open `disable-folder-type-auto-discovery.reg` from this folder.
|
||||||
|
|
||||||
|
* Turn off drive indexing for all drives since we'll be using Everything app for search and it does its own indexing.
|
||||||
|
* Right-click a drive, under `General` tab uncheck `Allow files on this drive to have contents indiexed ...`
|
||||||
|
|
||||||
* Disable UAC screen dimming
|
* Disable UAC screen dimming
|
||||||
* Open User Account Control settings
|
* Open User Account Control settings
|
||||||
* Drag the slider down to the notch that doesn't dim the screen.
|
* Drag the slider down to the notch that doesn't dim the screen.
|
||||||
@@ -97,17 +96,32 @@
|
|||||||
* Disable Windows error reporting dialog so that when stuff crashes you can get to a debugger faster.
|
* 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.
|
* Open an admin cmd prompt and run the file `disable-windows-error-reporting-dialog.bat` from this directory.
|
||||||
|
|
||||||
|
* Disable Microsoft Compatibility Appraiser (I believe this is for checking if you can run the next major OS; it's a CPU hog)
|
||||||
|
* Open task scheduler.
|
||||||
|
* Go to `Microsoft\Windows\Application Experience` and disable the `Microsoft Compatibility Appraiser` task.
|
||||||
|
|
||||||
* Disable the WinSAT task which is used to figure out your Windows performance score. It eats up
|
* Disable the WinSAT task which is used to figure out your Windows performance score. It eats up
|
||||||
processor time and is generally useless.
|
processor time and is generally useless.
|
||||||
* Open task scheduler.
|
* Open task scheduler.
|
||||||
* **note** If you see an error about a selected task {0} no longer existing then you'll need
|
* **note** If you see an error about a selected task {0} no longer existing then you'll need
|
||||||
to repair the task scheduler. See
|
to repair the task scheduler. See
|
||||||
https://www.thewindowsclub.com/the-selected-task-0-no-longer-exists-error-in-task-scheduler
|
https://www.thewindowsclub.com/the-selected-task-0-no-longer-exists-error-in-task-scheduler
|
||||||
* Go to `Local\Microsoft\Windows\Maintenance` and disable the WinSAT task.
|
* Go to `Microsoft\Windows\Maintenance` and disable the `WinSAT` task.
|
||||||
|
|
||||||
* Disable the Windows Customer Experience Improvement program via group policy
|
* Disable the Windows Customer Experience Improvement program via group policy
|
||||||
https://web.archive.org/web/20200131202352/https://www.ghacks.net/2016/10/26/turn-off-the-windows-customer-experience-program/
|
https://web.archive.org/web/20200131202352/https://www.ghacks.net/2016/10/26/turn-off-the-windows-customer-experience-program/
|
||||||
|
|
||||||
|
* Disable web search in Windows explorer search box (can speed up the horrible search feature, but really just use the Everything app!)
|
||||||
|
* Group policy editor:
|
||||||
|
* Computer Configuration -> Administrative Templates -> Windows Components -> Search
|
||||||
|
* Enable `Do no allow web search` and `Don't search the web or disable web results in Search`
|
||||||
|
* Alternatively, just disable the Windows search service altogether.
|
||||||
|
|
||||||
|
* Disable Cortana:
|
||||||
|
* Group policy editor:
|
||||||
|
* Computer Configuration -> Administrative Templates -> Windows Components -> Search
|
||||||
|
* Disable `Allow Cortana ...` settings.
|
||||||
|
|
||||||
* Increase TDR setting for GPU Driver
|
* Increase TDR setting for GPU Driver
|
||||||
* TDR determines the length of time that a GPU can hang on a computation until the OS restarts
|
* TDR determines the length of time that a GPU can hang on a computation until the OS restarts
|
||||||
the driver. By default this is set to a few seconds so you can experience app crashes when
|
the driver. By default this is set to a few seconds so you can experience app crashes when
|
||||||
@@ -123,7 +137,7 @@ processor time and is generally useless.
|
|||||||
* Go into the Windows security settings and disable `Tamper Protection`.
|
* Go into the Windows security settings and disable `Tamper Protection`.
|
||||||
* winkey+r -> `gpedit.msc`.
|
* winkey+r -> `gpedit.msc`.
|
||||||
* Can now disable either with a policy or some custom batch files.
|
* Can now disable either with a policy or some custom batch files.
|
||||||
* Policy:
|
* Group policy:
|
||||||
* Computer Configuration > Administrative Templates > Windows Components > Microsoft Defender Antivirus -> Real-time Protection
|
* Computer Configuration > Administrative Templates > Windows Components > Microsoft Defender Antivirus -> Real-time Protection
|
||||||
* Double-click the `Turn off real-time protection` policy.
|
* Double-click the `Turn off real-time protection` policy.
|
||||||
* Select Enabled (you may have to restart PC).
|
* Select Enabled (you may have to restart PC).
|
||||||
@@ -143,11 +157,41 @@ processor time and is generally useless.
|
|||||||
* Windows PowerShell 2.0 (current version is 5+ as of 2021-03-05)
|
* Windows PowerShell 2.0 (current version is 5+ as of 2021-03-05)
|
||||||
* Work folders client
|
* Work folders client
|
||||||
|
|
||||||
|
* Turn off various startup processes
|
||||||
|
* ctrl+shift+esc -> startup
|
||||||
|
|
||||||
|
* Disable unneeded services
|
||||||
|
|
||||||
|
* Pin "This PC" to taskbar
|
||||||
|
* In Win 10 start menu, search for "This PC", right click top result and pin to taskbar
|
||||||
|
|
||||||
|
* Disable collection of recently opened files
|
||||||
|
* winkey+r -> `gpedit.msc`.
|
||||||
|
* User Configuration > Administrative Templates > Start Menu and Taskbar
|
||||||
|
* Double-click the `Do no keep history of recently opened documents` policy.
|
||||||
|
* Select Enabled.
|
||||||
|
|
||||||
|
* Configure Explorer's options
|
||||||
|
* Open file explorer, click on File menu then options or "Change folder and search options"
|
||||||
|
* General tab
|
||||||
|
* `Open File Explorer to: This PC`
|
||||||
|
* Uncheck `Show recently used files in Quick access`
|
||||||
|
* Uncheck `Show frequently used folder in Quick access`
|
||||||
|
* View tab
|
||||||
|
* Check `Show hidden files, folders, or drives`,
|
||||||
|
* Uncheck `Hide extensions for known file types`
|
||||||
|
|
||||||
|
* Disable reopening apps on startup
|
||||||
|
* Windows settings -> Account -> Sign in options -> Privacy section: turn off `Use my sign-in info to automatically finish setting up device`
|
||||||
|
|
||||||
|
* Disable window suggestion when snapping a window
|
||||||
|
* Windows settings -> System -> Multitasking -> uncheck "When I snap a window, show what I can snap next to it"
|
||||||
|
|
||||||
* Restore classic Windows Photo Viewer app (the default Win10 photos app is fucking awful):
|
* Restore classic Windows Photo Viewer app (the default Win10 photos app is fucking awful):
|
||||||
* Run photo_viewer.reg from this folder.
|
* Open `photo_viewer.reg` from this folder.
|
||||||
* You'll need to change the default app for the various image extensions. Don't change gif types
|
* You'll need to change the default app for the various image extensions. Don't change gif types
|
||||||
though because photo viewer doesn't support animations.
|
though because photo viewer doesn't support animations.
|
||||||
* Now run disable-are-you-sure-you-want-to-open-with-the-default-program-dialog.reg to stop it
|
* Open `disable-are-you-sure-you-want-to-open-with-the-default-program-dialog.reg` to stop it
|
||||||
from occasionally asking if you still want to use photo viewer.
|
from occasionally asking if you still want to use photo viewer.
|
||||||
|
|
||||||
* Add custom hosts file
|
* Add custom hosts file
|
||||||
@@ -171,12 +215,29 @@ processor time and is generally useless.
|
|||||||
* Disable various web trackers using browserleaks.com as a guide.
|
* Disable various web trackers using browserleaks.com as a guide.
|
||||||
* e.g. disable WebGL, canvas fingerprinting, geolocation, font fingerprint, etc.
|
* e.g. disable WebGL, canvas fingerprinting, geolocation, font fingerprint, etc.
|
||||||
|
|
||||||
* Turn off various startup processes
|
* Disable the annoying Windows alert sound that plays when doing things like using a terminal, hitting tab to autocomplete and it has no match.
|
||||||
* ctrl+shift+esc -> startup
|
* Open C:/windows/media
|
||||||
|
* Find `Windows Background.wav`
|
||||||
|
* Right-click -> Properties -> Security -> Advanced -> Change Owner from `TrustedInstaller` to your user account -> Apply
|
||||||
|
* Back in the previous Security tab, click Edit to change permisisons -> add your user account and grant all permissions
|
||||||
|
* Now you can delete the file or rename it.
|
||||||
|
|
||||||
* Disable unneeded services
|
* Map caps key to left-ctrl
|
||||||
|
* If the keyboard supports remapping at the hardware level (e.g. like the Keychron keyboards) then map it there and this should cover all
|
||||||
|
use cases, including Steam Link which for some reason does not respect the various remapping setups (except for PowerTools - see below).
|
||||||
|
* For software based remapping, there are two options:
|
||||||
|
* Use SharpKeys for a simple config change in Windows. You don't have to run any software at startup to get the remapping. The downside is that
|
||||||
|
this doesn't work over Steam Link.
|
||||||
|
* Use Bill Microsoft's [PowerTools](https://github.com/microsoft/PowerToys/releases/). Install it and then go to the key remapper tool in the settings.
|
||||||
|
This works over Steam Link but it requires you to run the program to get the remapping. If you go down this path then be sure to go through the settings
|
||||||
|
and disable the various tools that you don't want.
|
||||||
|
|
||||||
|
* If using 2+ monitors with different resolutions then you'll very likely have trouble with the mouse cursor moving from one screen to another due to a bad mapping.
|
||||||
|
You can fix this by installing [LittleBigMouse](https://github.com/mgth/LittleBigMouse/releases), run it, check the `Allow Corner Crossing` box and then apply. But note
|
||||||
|
that I had some issues when running this. I forget the details now. Ended up uninstalling.
|
||||||
|
|
||||||
* Do a pass over all Windows setting screens for anything obvious that wasn't covered here.
|
* Do a pass over all Windows setting screens for anything obvious that wasn't covered here.
|
||||||
|
|
||||||
* Open the Windows settings Apps & features and remove bloatware that isn't visible in the
|
* Open the Windows settings Apps & features and remove bloatware that isn't visible in the
|
||||||
control panel add/remove list, e.g. OneDrive
|
control panel add/remove list, e.g. OneDrive
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user