2020-03-15 18:44:36 +00:00
#
2020-05-14 06:44:25 +00:00
# Note: this may contain Windows line endings. If you're going to use it in Linux then you'll need
# to remove those with: `sed -i 's/\r//' <file>` or with `dos2unix`.
2020-03-15 18:44:36 +00:00
#
2020-07-21 15:29:52 +00:00
if which tput >/dev/null 2>&1; then
2020-07-26 17:58:29 +00:00
ncolors=$(tput colors)
2020-07-21 15:29:52 +00:00
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
2020-07-26 17:58:29 +00:00
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)"
2020-07-21 15:29:52 +00:00
else
2020-07-26 17:58:29 +00:00
RED=""
GREEN=""
YELLOW=""
BLUE=""
MAGENTA=""
CYAN=""
BOLD=""
NORMAL=""
2020-07-21 15:29:52 +00:00
fi
2020-07-30 15:56:04 +00:00
platform=`uname`
2020-05-14 06:44:25 +00:00
####################################################################################################
# Helper Functions
####################################################################################################
2020-07-21 15:29:52 +00:00
error() {
2020-07-26 17:58:29 +00:00
printf "${BOLD}${RED}$1${NORMAL}\n"
2020-07-21 15:29:52 +00:00
}
reload() {
2021-03-04 19:33:29 +00:00
test -f ~/.env.loader && . ~/.env.loader
2020-05-14 06:44:25 +00:00
}
2020-07-30 15:56:04 +00:00
update-shell() {
if [[ '${platform,,}' == *'ming'* ]]; then
pacman -Syu
printf "\n${BOLD}${YELLOW}Close this shell, open a new one, and then run 'pacman -Su'${NORMAL}\n"
fi
}
2021-02-07 20:11:51 +00:00
# Will return a symlink path in its expanded form. If the path's root is the
# home directory symbol "~" then it'll be replaced by the full home path.
expand_path() {
local ret="$1"
IFS="/" read -ra parts <<< "$ret"
if [[ "${parts[0]}" == "~" ]]; then
ret="$HOME"
for ((i=1; i < ${#parts[@]}; i++))
do
ret="$ret/${parts[$i]}"
done
fi
ret=$(readlink -m "$ret")
echo $ret
}
2024-07-26 15:15:04 +00:00
2021-02-07 20:11:51 +00:00
is_absolute_unix_path() {
if [[ $1 =~ ^/ ]]; then echo 1; else echo 0; fi
}
is_windows_path() {
if [[ ! $1 =~ \/+ ]]; then echo 1; else echo 0; fi
}
# Returns a Unix path with spaces escaped with a '\'.
escape_unix_path() {
ret="$1"
ret="${ret/ /\\ }"
echo "$ret"
}
# Returned value does not have a trailing '\'.
unix_to_windows_path() {
ret="$1"
if [[ $(is_windows_path "$ret") -eq 0 ]]; then
if [[ $(is_absolute_unix_path "$ret") -eq 1 ]]; then
ret="${ret/\//}"
# Fix the drive name, e.g. c\foo becomes c:\foo
ret=$(sed 's,\([a-zA-Z]*\),\1:,' <<< "$ret")
fi
ret="${ret////\\}" # Replace Unix slashes.
ret="${ret//\\\(/\(}" # Remove backslash before (.
ret="${ret//\\\)/\)}" # Remove backslash before ).
fi
# Strip trailing slashes.
shopt -s extglob
ret=$(echo "${ret%%+(\\)}")
echo $ret
}
2020-07-21 15:29:52 +00:00
remove_windows_file() {
2021-02-07 20:11:51 +00:00
local path=$(expand_path "$1")
if [[ -f "$path" || -d "$path" ]]; then
local dest=$(unix_to_windows_path "$path")
recycle-bin.exe $dest
2020-05-14 06:44:25 +00:00
else
2021-02-07 20:11:51 +00:00
echo "'$path' does not exist!"
2020-05-14 06:44:25 +00:00
fi
}
2021-02-07 20:11:51 +00:00
open_explorer_here() {
local path_expanded=$(expand_path "$1")
2021-03-04 19:33:41 +00:00
if [[ -d $path_expanded ]]; then
local path=$(unix_to_windows_path "$path_expanded")
explorer.exe "$path"
else
echo "Folder no longer exists"
fi
2021-02-07 20:11:51 +00:00
}
2024-07-26 15:15:04 +00:00
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"
}
2021-07-14 16:10:23 +00:00
##################
# Building code
##################
# Dev build
b() {
2023-01-05 03:24:46 +00:00
test -f build && ./build $@ ; test -f build.sh && ./build.sh $@ ; test -f build.jai && ./build.jai $@
2021-07-14 16:10:23 +00:00
}
# fast dev build
2022-02-19 05:04:26 +00:00
bf() {
2023-01-05 03:24:46 +00:00
test -f build && ./build $@ -fast ; test -f build.sh && ./build.sh $@ -fast ; test -f build.jai && ./build.jai $@
2021-07-14 16:10:23 +00:00
}
# Optimized dev build
bb() {
2023-01-05 03:24:46 +00:00
test -f build && ./build $@ -o 1 ; test -f build.sh && ./build.sh $@ -o 1 ; test -f build.jai && ./build.jai -release $@
2021-07-14 16:10:23 +00:00
}
# Production build
bp() {
2023-01-05 03:24:46 +00:00
test -f build && ./build $@ -p p ; test -f build.sh && ./build.sh $@ -p p ; test -f build.jai && ./build.jai -release $@ - -prod
2021-07-14 16:10:23 +00:00
}
# Profiling build
2022-02-19 05:04:26 +00:00
bpf() {
2023-01-05 03:24:46 +00:00
test -f build && ./build $@ -p pf ; test -f build.sh && ./build.sh $@ -p pf
2021-07-14 16:10:23 +00:00
}
# GPU profiling build
2022-02-19 05:04:26 +00:00
bgpf() {
2023-01-05 03:24:46 +00:00
test -f build && ./build $@ -p gpu ; test -f build.sh && ./build.sh $@ -p gpu
2021-07-14 16:10:23 +00:00
}
# Run build
r() {
2023-01-05 03:24:46 +00:00
test -f run && ./run $@ ; test -f run.sh && ./run.sh $@
2021-07-14 16:10:23 +00:00
}
# Build then run
br() {
b $@ ; r
}
####################################################################################################
if [[ $platform == 'Darwin' ]]; then
alias trash='rmtrash'
alias tt='rmtrash'
elif [[ "${platform,,}" == *'ming'* ]]; then # convert to lowercase then compare with wildcard
#alias rm='echo "use trash command instead!"'
#alias rmr='echo "use trash command instead!"'
alias trash='remove_windows_file'
alias tt='remove_windows_file'
alias cgrep='cgrep.exe'
fi
alias cd-='echo "Use c- instead"'
alias ..='cd ../'
alias ...='cd ../..'
alias cd..='cd ..'
alias cd...='cd ../..'
alias cd....='cd ../../..'
alias cd.....='cd ../../../..'
alias ls='ls -F --color'
alias l='ls -lh'
alias ll='ls -lha'
2024-01-21 03:19:57 +00:00
mkcd() {
mkdir -p "${1}"
cd "${1}"
}
2023-06-13 19:53:57 +00:00
alias aliases='vim ~/.aliases'
2021-07-14 16:10:23 +00:00
alias al='aliases'
if [[ "${platform,,}" == *'ming'* ]]; then
_checksum() {
local algo="$1"
local file="$2"
certutil -hashfile $file $algo
}
alias checksum='certutil -hashfile'
alias checksum-md5='_checksum MD5'
alias checksum-sha1='_checksum SHA1'
alias checksum-sha256='_checksum SHA256'
alias checksum-sha512='_checksum SHA512'
fi
check_signature() {
local algo="$1"
local hashes_file="$2"
local pem_file="$3"
local sig_file="$4"
if [[ $hashes_file == "" || $pem_file == "" || $sig_file == "" ]]; then
2023-06-06 19:48:43 +00:00
error "Usage: <hashes file (e.g. sha512 hashes)> <pem file> <sig file>"
2021-07-14 16:10:23 +00:00
return
fi
openssl dgst -$algo -verify $pem_file -signature $sig_file $hashes_file
}
alias check-signature256='check_signature sha256 '
alias cr='RUSTFLAGS="$RUSTFLAGS -A unused_variables -A dead_code -A unused_parens" cargo run'
alias crr='cargo run --release'
alias cb='RUSTFLAGS="$RUSTFLAGS -A unused_variables -A dead_code -A unused_parens" cargo build'
alias cbr='cargo build --release'
alias clrtmp='trash ~/tmp/*.bak && trash ~/tmp/*.swp'
alias clrtemp='clrtmp'
alias clipboard='xclip -selection c'
# Cloc alias may be overridden by a private alias
alias cloc='cloc --no3 --by-file-by-lang --skip-win-hidden'
alias cls=clear
alias cpr='cp -r'
alias dc='gdc'
alias duh='du -csh'
2024-04-29 03:32:23 +00:00
dos2unix_all() {
local path="$1"
if [[ $path == "" ]]; then
path="$PWD"
fi
find $path -type f -exec dos2unix '{}' '+'
}
alias d2u='dos2unix_all'
2021-07-14 16:10:23 +00:00
alias e='open_explorer_here "$PWD"'
alias exp='echo "Use e instead."'
alias f='fg'
alias hist='history'
alias histroy='history'
alias moon='curl wttr.in/moon -A "curl"'
alias rc='rclone'
alias rcc='rclone copy'
alias restart='sudo shutdown now -r'
alias rl='reload'
alias rmr='rm -r'
alias rmrf='rm -rf'
alias s='cd ~/.ssh'
alias sc='vim ~/.ssh/config'
alias shutdown='sudo shutdown now'
alias t='tree'
alias tag='ctags -R .'
alias v='vim'
alias vi='vim'
alias vimrc='vim ~/.vimrc'
alias weather='curl wttr.in/toronto -A "curl"'
####################################################################################################
# Grep
####################################################################################################
custom_grep() {
local term="$1"
shift 1
local include_list=("$@")
local include_arg=""
if [[ $include_list != "" ]]; then
2023-06-04 15:57:32 +00:00
# We're looping like this instead of for var in "$@", because that way of looping is affecting
# my shell environment. Very strange!
2021-07-14 16:10:23 +00:00
for i in "${include_list[@]}"; do
include_arg+="--include=\*${i} "
done
fi
eval grep -nri --color=auto $include_arg --exclude=tags --exclude=newtags --exclude-dir=.git \"$term\"
}
# Search c/cpp/txt files. Only supports a single search term arg or a quoted search term.
grep_dev() {
custom_grep "$@" .h .c .cpp .inc .def .txt .md
}
# Search c/cpp files. Only supports a single search term arg or a quoted search term.
grep_c() {
custom_grep "$@" .h .c .cpp .inc .def
}
# Search txt/md files. Only supports a single search term arg or a quoted search term.
grep_txt() {
custom_grep "$@" .txt .md
}
alias grepp='grep -n --color=auto --exclude=tags --exclude=newtags --exclude-dir=.git '
alias grep-c='grep_c '
alias grep-txt='grep_txt'
alias grep-dev='grep_dev'
####################################################################################################
# Downloading Vids and Audio
####################################################################################################
COMPRESSION_ON=1
COMPRESSION_OFF=0
2023-06-04 18:40:59 +00:00
2021-07-14 16:10:23 +00:00
SHORTNAME_ON=1
SHORTNAME_OFF=0
2023-06-04 18:40:59 +00:00
TRANSCRIBE_ON=1
TRANSCRIBE_OFF=0
2020-07-21 15:29:52 +00:00
make_vid_dir_and_cd_into() {
2020-05-14 06:44:25 +00:00
local url="$1"
local dir_name="$2"
2021-05-27 21:39:42 +00:00
shift 2
local opts="$@"
2020-05-14 06:44:25 +00:00
if [[ $dir_name == "" ]]; then
# @note If the filename contains symbols that are incompatible with
# Windows' directory names then add --restrict-filenames to the command.
2021-12-09 21:34:32 +00:00
dir_name=$(yt-dlp.exe --get-filename -o "%(upload_date>%Y-%m-%d)s - %(title)s" $opts $url)
2021-07-14 15:16:23 +00:00
2020-05-14 06:44:25 +00:00
if [[ $dir_name == "" ]]; then
return 1
fi
fi
2024-07-26 15:15:04 +00:00
dir_name=$(remove_extra_spaces "$dir_name")
2020-07-21 15:29:52 +00:00
printf "${BOLD}Creating directory ${YELLOW}'$dir_name'${NORMAL}\n"
2021-12-09 21:34:32 +00:00
mkdir "$dir_name" 2>/dev/null
2020-05-14 06:44:25 +00:00
cd "$dir_name"
error=$?
if [[ ! $error -eq 0 ]]; then
2023-03-16 16:59:23 +00:00
error "Error: failed to create directory. Aborting."
2020-05-14 06:44:25 +00:00
return 1
fi
return 0
}
2023-06-06 19:48:43 +00:00
function my_transcribe_video() {
file="$1"
output="$2"
2023-07-14 21:29:59 +00:00
include_small=$3
2023-08-07 21:22:07 +00:00
start_time="$4"
end_time="$5"
2023-06-06 19:48:43 +00:00
if [[ $file == "" ]]; then
2023-08-07 21:22:07 +00:00
error "Usage: <input video> <optional output name> <optional include small model (1 or 0)> <optional start time> <optional end time>"
2023-06-06 19:48:43 +00:00
return
fi
if [[ $output == "" ]]; then
output="${1%.*}" # just use the input name without the extension.
fi
2023-08-07 21:22:07 +00:00
if [[ $start_time == "" ]]; then start_time="0"; fi
if [[ $end_time == "" ]]; then end_time="0"; fi
2023-06-06 19:48:43 +00:00
# Tiny is fast and semi-accurate, so whatever.
# Base is pretty good overall. It has good punctuation inserting and
# catches most words. Small and medium can do better word detection at
# times, but suffer from bad punctuation. Medium is particularly bad and
# not adding commas and periods.
2023-07-14 21:29:59 +00:00
if [[ $include_small -eq 1 ]]; then
2023-08-07 21:22:07 +00:00
transcribe-video "$file" "$output" $start_time $end_time tiny base small
2023-07-14 21:29:59 +00:00
else
2023-08-07 21:22:07 +00:00
transcribe-video "$file" "$output" $start_time $end_time tiny base
2023-07-14 21:29:59 +00:00
fi
2023-06-06 19:48:43 +00:00
}
function my_transcribe_video_all_models() {
file="$1"
output="$2"
2023-08-07 21:22:07 +00:00
start_time="$3"
end_time="$4"
2023-06-06 19:48:43 +00:00
if [[ $file == "" ]]; then
2023-08-07 21:22:07 +00:00
error "Usage: <input video> <optional output name> <optional start time> <optional end time>"
2023-06-06 19:48:43 +00:00
return
fi
2023-08-07 21:22:07 +00:00
2023-06-06 19:48:43 +00:00
if [[ $output == "" ]]; then
output="${1%.*}" # just use the input name without the extension.
fi
2023-08-07 21:22:07 +00:00
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
2023-06-04 18:40:59 +00:00
}
2023-06-06 19:48:43 +00:00
2022-03-28 17:06:02 +00:00
# Download YouTube videos. Note that yt-dlp downloads a lot faster than streamlink.
2023-03-01 20:27:38 +00:00
download_youtube_vid() {
2020-05-14 06:44:25 +00:00
local format="$1"
2020-09-30 01:51:11 +00:00
local shortname="$2"
2023-06-04 18:40:59 +00:00
local transcribe="$3"
local make_folder="$4"
local url="$5"
shift 5
2020-05-14 06:44:25 +00:00
local opts="$@"
2020-07-30 02:22:33 +00:00
if [[ $url == "" ]]; then
2023-06-06 19:48:43 +00:00
error "Usage: <make folder?> <url> <optional args>"
2020-07-30 02:22:33 +00:00
return
fi
2023-01-19 23:13:46 +00:00
2023-06-04 18:40:59 +00:00
if [[ $shortname == "1" || $transcribe == "1" ]]; then
printf "${BOLD}Downloading Youtube vid "
if [[ $shortname == "1" ]]; then printf "| ${YELLOW}using short name${NORMAL}${BOLD} "; fi
if [[ $transcribe == "1" ]]; then printf "| ${YELLOW}audio transcription on${NORMAL}${BOLD} "; fi
printf "\n\n${NORMAL}"
else
printf "${BOLD}Downloading Youtube vid\n\n${NORMAL}"
fi
2021-08-11 14:37:41 +00:00
if [[ $format == "" ]]; then
printf "${BOLD}No format given; using best available.${NORMAL}\n"
2023-06-04 18:40:59 +00:00
# Download best mp4 video.
2022-02-14 18:11:20 +00:00
format="bv*[ext=mp4]+ba[ext=m4a]"
2021-08-11 14:37:41 +00:00
fi
2020-07-30 02:22:33 +00:00
2023-06-04 18:40:59 +00:00
# We're assuming we'll always have an mp4 video only and audio track to merge.
opts+=" --merge-output-format mp4 --write-subs --sub-lang en --embed-subs"
2020-05-14 06:44:25 +00:00
2021-07-14 15:16:23 +00:00
if [[ $make_folder == "1" ]]; then
make_vid_dir_and_cd_into $url ""
if [[ $? -ne 0 ]]; then
return
fi
2020-05-14 06:44:25 +00:00
fi
2023-06-04 18:40:59 +00:00
if [[ $shortname == "0" ]]; then
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s"
2020-09-30 01:51:11 +00:00
else
2023-06-04 18:40:59 +00:00
local name_format="%(upload_date>%Y-%m-%d)s-shortname-yt-%(id)s"
2020-09-30 01:51:11 +00:00
fi
2023-06-04 18:40:59 +00:00
# Get the video filename.
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
2024-07-26 15:15:04 +00:00
filename=$(remove_extra_spaces "$filename")
2023-06-04 18:40:59 +00:00
printf "filename: $filename\n"
2020-05-14 06:44:25 +00:00
2024-07-26 15:15:04 +00:00
# Download the video.
2023-06-04 18:40:59 +00:00
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=$?
2020-07-30 02:22:33 +00:00
2023-06-04 18:40:59 +00:00
if [[ $error -ne 0 ]]; then
error "Error: Failed to download '$url'"
if [[ $make_folder == "1" ]]; then cd ..; fi
2020-07-30 02:22:33 +00:00
return
fi
2021-12-09 21:34:32 +00:00
# Removing any trailing subtitle files
rm *.vtt *.srt 2>/dev/null
2020-06-10 15:23:38 +00:00
2023-06-04 18:40:59 +00:00
if [[ $transcribe == "1" ]]; then
2023-06-06 19:48:43 +00:00
my_transcribe_video "$filename"
2021-07-14 15:16:23 +00:00
fi
2023-06-04 18:40:59 +00:00
if [[ $make_folder == "1" ]]; then cd ..; fi
2023-06-05 21:12:16 +00:00
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
2020-06-10 15:23:38 +00:00
}
2024-11-22 01:26:16 +00:00
#
# 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)
#
2023-03-01 20:27:38 +00:00
download_youtube_playlist() {
2020-05-14 06:44:25 +00:00
local format="$1"
local url="$2"
local dir_name="$3"
2020-07-30 02:22:33 +00:00
shift 3
2024-11-22 01:26:16 +00:00
local opts="$@ --write-sub --sub-lang en --embed-subs"
2020-07-30 02:22:33 +00:00
2024-11-22 01:26:16 +00:00
if [[ $url == "" || $dir_name == "" ]]; then
error "Usage: <url> <directory name> <optional args>"
2020-05-14 06:44:25 +00:00
return
fi
2023-06-04 18:40:59 +00:00
printf "${BOLD}Downloading Youtube playlist\n\n${NORMAL}"
2021-12-09 21:34:32 +00:00
if [[ $format == "" ]]; then
printf "${BOLD}No format given; using best available.${NORMAL}\n"
2022-02-14 18:11:20 +00:00
# Download best mp4 video and best m4a audio, then merge.
format="bv*[ext=mp4]+ba[ext=m4a]"
opts+=" --merge-output-format mp4"
2021-12-09 21:34:32 +00:00
fi
2020-07-30 02:22:33 +00:00
2024-11-22 01:26:16 +00:00
make_vid_dir_and_cd_into $url "$dir_name"
if [[ $? -ne 0 ]]; then
return
2020-05-14 06:44:25 +00:00
fi
2024-11-22 01:26:16 +00:00
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"
2021-12-09 21:34:32 +00:00
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
2020-05-14 06:44:25 +00:00
2021-12-09 21:34:32 +00:00
# Removing any trailing subtitle files
rm *.vtt *.srt 2>/dev/null
2020-06-10 15:23:38 +00:00
2024-11-22 01:26:16 +00:00
cd ..
2023-06-05 21:12:16 +00:00
printf "${BOLD}Finished downloading the playlist\n${NORMAL}"
2020-05-14 06:44:25 +00:00
}
2023-06-06 19:48:43 +00:00
download_youtube_playlist_list() {
local url="$1"
local output_name="$2"
shift 2
local opts="$@"
if [[ $url == "" || $output_name == "" ]]; then
error "Usage: <url> <output name> <optional args>"
return
fi
printf "${BOLD}Downloading Youtube playlist video list\n\n${NORMAL}"
local cmd="yt-dlp.exe --ignore-errors -O \"%(playlist_index)s-%(title)s--%(id)s\" --skip-download $opts $url"
2023-06-09 21:20:24 +00:00
eval $cmd 1>"${output_name}.txt" # Need to eval in order to preserve the quotes wrapping the filename format string.
2023-06-06 19:48:43 +00:00
printf "${BOLD}Finished downloading the playlist video list\n${NORMAL}"
}
download_youtube_uploads_list() {
2023-06-09 21:20:24 +00:00
local include_descriptions="$1"
local url="$2"
local output_name="$3"
shift 3
2023-06-06 19:48:43 +00:00
local opts="$@"
if [[ $url == "" || $output_name == "" ]]; then
error "Usage: <url> <output name> <optional args>"
return
fi
2023-06-09 21:20:24 +00:00
local cmd=""
if [[ $include_descriptions == "1" ]]; then
printf "${BOLD}Downloading Youtube uploads list with descriptions\n\n${NORMAL}"
cmd="yt-dlp.exe --ignore-errors -O \"@@@ %(video_autonumber)s-%(upload_date>%Y-%m-%d)s--%(title)s--%(id)s\" --skip-download --get-description $opts $url"
else
printf "${BOLD}Downloading Youtube uploads list\n\n${NORMAL}"
cmd="yt-dlp.exe --ignore-errors -O \"%(video_autonumber)s-%(upload_date>%Y-%m-%d)s--%(title)s--%(id)s\" --skip-download $opts $url"
fi
2023-06-06 19:48:43 +00:00
2023-06-09 21:20:24 +00:00
eval $cmd 1>"${output_name}.txt" # Need to eval in order to preserve the quotes wrapping the filename format string.
2023-06-06 19:48:43 +00:00
printf "${BOLD}Finished downloading the upload list\n${NORMAL}"
}
2023-07-14 21:29:59 +00:00
function download_youtube_audio() {
2024-05-20 18:25:46 +00:00
local make_folder="$1"
local url="$2"
shift 2
local opts="$@"
if [[ $url == "" ]]; then
error "Usage: <make folder?> <url> <optional args>"
2023-07-14 21:29:59 +00:00
return
fi
2024-05-20 18:25:46 +00:00
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)
2024-07-26 15:15:04 +00:00
filename=$(remove_extra_spaces "$filename")
2024-05-20 18:25:46 +00:00
printf "filename: $filename\n"
2024-07-26 15:15:04 +00:00
# Download the audio.
2024-05-20 18:25:46 +00:00
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"
2023-07-14 21:29:59 +00:00
}
2021-07-14 15:16:23 +00:00
# Download Twitch chat transcript
2023-03-01 20:27:38 +00:00
actually_download_twitch_chat() {
2021-07-14 15:16:23 +00:00
local url="$1"
local filename="$2"
2024-07-26 15:15:04 +00:00
filename=$(remove_extra_spaces "$filename")
2021-07-14 15:16:23 +00:00
rechat.exe -d $url "$filename.json"
if [[ -f "$filename.json" ]]; then
rechat.exe -p "$filename.json" "$filename.txt" -b -o
rm "$filename.json"
else
error "Video doesn't have a chat transcript."
fi
2023-06-05 21:12:16 +00:00
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
2021-07-14 15:16:23 +00:00
}
2023-03-01 20:27:38 +00:00
download_twitch_chat() {
2022-07-10 18:35:58 +00:00
local make_folder="$1"
local url="$2"
shift 2
2021-05-27 21:39:42 +00:00
local opts="$@"
if [[ $url == "" ]]; then
2023-06-06 19:48:43 +00:00
error "Usage: <url>"
2021-05-27 21:39:42 +00:00
return
fi
2022-07-10 18:35:58 +00:00
if [[ $make_folder == "1" ]]; then
make_vid_dir_and_cd_into $url "" $opts
if [[ $? -ne 0 ]]; then
return
fi
2021-05-27 21:39:42 +00:00
fi
2023-06-05 21:12:16 +00:00
actually_download_twitch_chat $url "$(yt-dlp.exe --get-filename -o "%(upload_date>%Y-%m-%d)s-%(title)s-tw-%(id)s.chat" $opts $url)"
2021-05-27 21:39:42 +00:00
2023-06-05 21:12:16 +00:00
if [[ $make_folder == "1" ]]; then cd ..; fi
2021-05-27 21:39:42 +00:00
}
2022-03-28 17:06:02 +00:00
# Download Twitch videos, both VODs and live streams. Pass a Twitch account URL to download a live stream.
# The live stream filename will not contain the stream title, so you'll need to modify it afterwards.
#
# If you want to download subcriber-only vids then first extract your Twitch
# cookies to a file (can use cookies.txt add-on from Lennon Hill) and then pass it as an option,
2021-07-14 15:16:23 +00:00
# using the full path to the cookies file, e.g.
2021-05-27 21:39:42 +00:00
# `tw-1080p60 <url> --cookies /c/<cookie_path>/twitch_cookies.txt`
#
2022-03-28 17:06:02 +00:00
# To extract a portion of a video, you have to first download the entire file and then use the
# `trim-video` or `compress-video-and-trim` scripts.
2021-08-22 17:49:35 +00:00
#
2023-03-01 20:27:38 +00:00
download_twitch_vid() {
2020-05-14 06:44:25 +00:00
local format="$1"
2020-07-21 15:29:52 +00:00
local shortname="$2"
2021-07-14 15:16:23 +00:00
local compress="$3"
2023-06-04 18:40:59 +00:00
local transcribe="$4"
local make_folder="$5"
local url="$6"
shift 6
2020-05-14 06:44:25 +00:00
local opts="$@"
2020-07-30 02:22:33 +00:00
if [[ $url == "" ]]; then
2023-06-06 19:48:43 +00:00
error "Usage: <make folder?> <url> <optional args>"
2023-06-04 18:40:59 +00:00
return
2020-07-30 02:22:33 +00:00
fi
2022-03-28 17:06:02 +00:00
# We use yt-dlp to get the filename and then use streamlink to download it (the latter is a lot faster).
# It's a two step process because streamlink cannot pass the formatted filename to ffmpeg.
# We fallback to yt-dlp when it's a subscriber VOD because we don't have an easy way to access it with streamlink.
local subscriber_vod=0
local split_opts=($opts)
if [[ ${split_opts[0]} == "--cookies" ]]; then
subscriber_vod=1
printf "${BOLD}Subscriber VOD. Will use yt-dlp to download.${NORMAL}\n"
fi
2023-06-04 18:40:59 +00:00
if [[ $shortname == "1" || $compress == "1" || $transcribe == "1" ]]; then
printf "${BOLD}Downloading Twitch vid "
if [[ $shortname == "1" ]]; then printf "| ${YELLOW}using short name${NORMAL}${BOLD} "; fi
if [[ $compress == "1" ]]; then printf "| ${YELLOW}compression on${NORMAL}${BOLD} "; fi
if [[ $transcribe == "1" ]]; then printf "| ${YELLOW}audio transcription on${NORMAL}${BOLD} "; fi
printf "\n\n${NORMAL}"
2020-05-14 06:44:25 +00:00
else
2023-06-04 18:40:59 +00:00
printf "${BOLD}Downloading Twitch vid\n\n${NORMAL}"
2021-08-11 14:37:41 +00:00
fi
2022-03-28 17:06:02 +00:00
local yt_dlp_format=""
local streamlink_format=""
2021-08-11 14:37:41 +00:00
if [[ $format == "" ]]; then
2022-03-25 00:18:05 +00:00
# Twitch only supplies pre-merged mp4s so we can ask for the best format and not worry about anything else.
2021-08-11 14:37:41 +00:00
printf "${BOLD}No format given; using best available.${NORMAL}\n"
2022-03-28 17:06:02 +00:00
yt_dlp_format="b"
streamlink_format="best"
else
yt_dlp_format="$format"
streamlink_format="$format"
2020-05-14 06:44:25 +00:00
fi
2020-06-10 15:23:38 +00:00
2021-07-14 15:16:23 +00:00
if [[ $make_folder == "1" ]]; then
make_vid_dir_and_cd_into $url "" $opts
if [[ $? -ne 0 ]]; then
2023-06-04 18:40:59 +00:00
return
2021-07-14 15:16:23 +00:00
fi
2020-06-10 15:23:38 +00:00
fi
2023-06-04 18:40:59 +00:00
if [[ $shortname == "0" ]]; then
2022-03-11 19:22:23 +00:00
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-tw-%(id)s"
2020-06-25 17:30:08 +00:00
else
2022-03-11 19:22:23 +00:00
local name_format="%(upload_date>%Y-%m-%d)s-shortname-tw-%(id)s"
2020-06-25 17:30:08 +00:00
fi
2020-12-16 15:56:06 +00:00
# Download Twitch chat transcript
2023-03-01 20:27:38 +00:00
actually_download_twitch_chat $url "$(yt-dlp.exe --get-filename -o "$name_format" $opts $url)"
2020-12-16 15:56:06 +00:00
2022-03-28 17:06:02 +00:00
# Get the video filename.
2023-06-04 18:40:59 +00:00
local filename=$(yt-dlp.exe --get-filename -f $yt_dlp_format -o "$name_format.%(ext)s" $opts $url)
2024-07-26 15:15:04 +00:00
filename=$(remove_extra_spaces "$filename")
printf "filename: $filename\n"
2022-03-28 17:06:02 +00:00
2024-07-26 15:15:04 +00:00
# Download the video.
2023-06-04 18:40:59 +00:00
if [[ $subscriber_vod == "0" ]]; then
2024-07-26 15:15:04 +00:00
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\""
2022-03-28 17:06:02 +00:00
else
2024-07-26 15:15:04 +00:00
printf "${YELLOW}${BOLD}\nUsing yt-dlp to download...${NORMAL}\n"
2022-03-28 17:06:02 +00:00
local cmd="yt-dlp.exe -f $yt_dlp_format -o \"$filename\" $opts $url"
fi
2020-06-10 15:23:38 +00:00
2023-06-04 18:40:59 +00:00
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
2020-06-10 15:23:38 +00:00
error=$?
2023-06-04 18:40:59 +00:00
if [[ $error -ne 0 ]]; then
2023-03-16 16:59:23 +00:00
error "Error: Failed to download '$url'"
2023-06-04 18:40:59 +00:00
if [[ $make_folder == "1" ]]; then cd ..; fi
return
2020-06-10 15:23:38 +00:00
fi
2023-06-04 18:40:59 +00:00
if [[ $compress == "1" ]]; then
local temp_name="temp_${RANDOM}"
2024-07-26 15:15:04 +00:00
extension="${filename##*.}"
2023-06-04 18:40:59 +00:00
# 0=cpu, 1=gpu
compress-video "$filename" "$temp_name" 0
mv "$filename" "orig_$filename"
mv $temp_name.$extension "$filename"
printf "${BOLD}Make sure to delete the original video file\n${NORMAL}"
fi
if [[ $transcribe == "1" ]]; then
2023-06-06 19:48:43 +00:00
my_transcribe_video "$filename"
2021-07-14 15:16:23 +00:00
fi
2023-06-04 18:40:59 +00:00
if [[ $make_folder == "1" ]]; then cd ..; fi
2023-06-05 21:12:16 +00:00
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
2021-07-14 15:16:23 +00:00
}
# Download Vimeo videos.
2022-11-05 04:48:21 +00:00
# Can download an embedded vid. You might need to save the site cookies if the vid is behind a paywall.
2023-06-04 18:40:59 +00:00
# e.g. --cookies cookies.txt --referer https://gillyandkeeves.tv https://player.vimeo.com/video/756941969
2022-11-05 04:48:21 +00:00
# The vid ID can be found by looking at the embed's iframe src attribute.
2023-03-01 20:27:38 +00:00
download_vimeo_vid() {
2023-06-04 18:40:59 +00:00
local shortname="$1"
local compress="$2"
local transcribe="$3"
local format="$4"
local make_folder="$5"
local url="$6"
2021-07-14 15:16:23 +00:00
shift 5
local opts="$@"
2023-06-04 18:40:59 +00:00
if [[ $format == "" || $url == "" ]]; then
2023-06-06 19:48:43 +00:00
error "Usage: <format> <make folder?> <url> <optional args>"
2021-07-14 15:16:23 +00:00
return
fi
2023-06-04 18:40:59 +00:00
if [[ $shortname == "1" || $compress == "1" || $transcribe == "1" ]]; then
printf "${BOLD}Downloading Vimeo vid "
if [[ $shortname == "1" ]]; then printf "| ${YELLOW}using short name${NORMAL}${BOLD} "; fi
if [[ $compress == "1" ]]; then printf "| ${YELLOW}compression on${NORMAL}${BOLD} "; fi
if [[ $transcribe == "1" ]]; then printf "| ${YELLOW}audio transcription on${NORMAL}${BOLD} "; fi
printf "\n\n${NORMAL}"
2021-07-14 15:16:23 +00:00
else
2023-06-04 18:40:59 +00:00
printf "${BOLD}Downloading Vimeo vid\n\n${NORMAL}"
2021-07-14 15:16:23 +00:00
fi
if [[ $make_folder == "1" ]]; then
make_vid_dir_and_cd_into $url "" $opts
if [[ $? -ne 0 ]]; then
return
fi
fi
2023-06-04 18:40:59 +00:00
if [[ $shortname == "0" ]]; then
2021-12-09 21:34:32 +00:00
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-vimeo-%(id)s"
2021-07-14 15:16:23 +00:00
else
2021-12-09 21:34:32 +00:00
local name_format="%(upload_date>%Y-%m-%d)s-shortname-vimeo-%(id)s"
2021-07-14 15:16:23 +00:00
fi
2024-07-26 15:15:04 +00:00
# Get the video filename.
2021-12-09 21:34:32 +00:00
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
2024-07-26 15:15:04 +00:00
filename=$(remove_extra_spaces "$filename")
printf "filename: $filename\n"
2021-07-14 15:16:23 +00:00
2024-07-26 15:15:04 +00:00
# Download the video.
2021-12-09 21:34:32 +00:00
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.
2021-07-14 15:16:23 +00:00
error=$?
if [[ $error -eq 0 ]]; then
2023-06-04 18:40:59 +00:00
if [[ $compress == "1" ]]; then
2021-07-14 15:16:23 +00:00
local temp_name="temp_${RANDOM}"
2023-01-05 03:24:46 +00:00
# 0=cpu, 1=gpu
compress-video "$filename" "$temp_name" 0
2021-07-14 15:16:23 +00:00
extension="${filename##*.}"
2021-09-14 00:59:47 +00:00
mv "$filename" "orig_$filename"
2021-07-14 15:16:23 +00:00
mv $temp_name.$extension "$filename"
printf "${BOLD}Make sure to delete the original video file${NORMAL}\n"
fi
else
2023-03-16 16:59:23 +00:00
error "Error: Failed to download '$url'"
2023-06-04 18:40:59 +00:00
if [[ $make_folder == "1" ]]; then cd ..; fi
return
2021-07-14 15:16:23 +00:00
fi
2023-06-04 18:40:59 +00:00
if [[ $transcribe == "1" ]]; then
2023-06-06 19:48:43 +00:00
my_transcribe_video "$filename"
2021-07-14 15:16:23 +00:00
fi
2023-06-04 18:40:59 +00:00
if [[ $make_folder == "1" ]]; then cd ..; fi
2023-06-05 21:12:16 +00:00
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
2020-05-14 06:44:25 +00:00
}
2022-08-03 22:05:57 +00:00
# Download Twitter videos.
2023-03-01 20:27:38 +00:00
download_twitter_vid() {
2022-08-03 22:05:57 +00:00
local format="$1"
local make_folder="$2"
local url="$3"
local vid_name="$4"
if [[ $url == "" ]]; then
2023-06-06 19:48:43 +00:00
error "Usage: <make folder?> <url> <optional filename> <optional args>"
2022-08-03 22:05:57 +00:00
return
fi
printf "${BOLD}Downloading Twitter vid.${NORMAL}\n"
2024-11-22 01:26:16 +00:00
local opts=""
2022-08-03 22:05:57 +00:00
if [[ $vid_name == "" ]]; then
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-twitter-%(id)s"
else
local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-twitter-%(id)s"
2022-10-18 23:00:36 +00:00
shift 4
2024-11-22 01:26:16 +00:00
opts="$@"
2022-08-03 22:05:57 +00:00
fi
if [[ $make_folder == "1" ]]; then
make_vid_dir_and_cd_into $url $vid_name $opts
if [[ $? -ne 0 ]]; then
return
fi
fi
if [[ $format == "" ]]; then
printf "${BOLD}No format given; using best available.${NORMAL}\n"
format="b"
fi
2024-07-26 15:15:04 +00:00
# Get the video filename.
2022-08-03 22:05:57 +00:00
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
2024-07-26 15:15:04 +00:00
filename=$(remove_extra_spaces "$filename")
printf "filename: $filename\n"
2022-08-03 22:05:57 +00:00
2024-07-26 15:15:04 +00:00
# Download the video.
2022-08-03 22:05:57 +00:00
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
error=$?
if [[ $error -eq 1 ]]; then
2023-03-16 16:59:23 +00:00
error "Error: Failed to download '$url'"
2022-08-03 22:05:57 +00:00
fi
2023-06-04 18:40:59 +00:00
if [[ $make_folder == "1" ]]; then cd ..; fi
2023-06-05 21:12:16 +00:00
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
2023-06-04 18:40:59 +00:00
}
# Download Instagram videos.
download_instagram_vid() {
local transcribe="$1"
local make_folder="$2"
local url="$3"
local vid_name="$4"
if [[ $url == "" ]]; then
2023-06-06 19:48:43 +00:00
error "Usage: <make folder?> <url> <optional filename> <optional args>"
2023-06-04 18:40:59 +00:00
return
fi
printf "${BOLD}Downloading Instagram vid.${NORMAL}\n"
2024-11-22 01:26:16 +00:00
local opts=""
2023-06-04 18:40:59 +00:00
if [[ $vid_name == "" ]]; then
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-ig-%(id)s"
else
local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-ig-%(id)s"
shift 4
2024-11-22 01:26:16 +00:00
opts="$@"
2023-06-04 18:40:59 +00:00
fi
2022-08-03 22:05:57 +00:00
if [[ $make_folder == "1" ]]; then
2023-06-04 18:40:59 +00:00
make_vid_dir_and_cd_into $url $vid_name $opts
if [[ $? -ne 0 ]]; then
return
fi
fi
format="b" # best available
2024-07-26 15:15:04 +00:00
# Get the video filename.
2023-06-04 18:40:59 +00:00
local filename=$(yt-dlp.exe --get-filename -f $format -o "$name_format.%(ext)s" $opts $url)
2024-07-26 15:15:04 +00:00
filename=$(remove_extra_spaces "$filename")
printf "filename: $filename\n"
2023-06-04 18:40:59 +00:00
2024-07-26 15:15:04 +00:00
# Download the video.
2023-06-04 18:40:59 +00:00
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
error=$?
if [[ $error -eq 1 ]]; then
error "Error: Failed to download '$url'"
if [[ $make_folder == "1" ]]; then cd ..; fi
return
fi
if [[ $transcribe == "1" ]]; then
transcribe "$filename"
2022-08-03 22:05:57 +00:00
fi
2023-06-04 18:40:59 +00:00
if [[ $make_folder == "1" ]]; then cd ..; fi
2023-06-05 21:12:16 +00:00
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
2022-08-03 22:05:57 +00:00
}
2020-11-23 19:13:36 +00:00
# Download MP4 video.
2023-03-01 20:27:38 +00:00
download_mp4() {
2020-06-10 15:23:38 +00:00
local url="$1"
local filename="$2"
2020-11-23 19:13:36 +00:00
if [[ $url == "" || $filename == "" ]]; then
2023-06-06 19:48:43 +00:00
error "Usage: <url> <filename>"
2020-11-23 19:13:36 +00:00
return
fi
2020-06-10 15:23:38 +00:00
temp_name="temp_${RANDOM}.mp4"
2020-07-21 15:29:52 +00:00
printf "${BOLD}Downloading: ${YELLOW}$filename${NORMAL}\n"
2020-06-10 15:23:38 +00:00
curl "$url" -o $temp_name
if [[ $? -ne 0 ]]; then
2023-03-16 16:59:23 +00:00
error "Error: failed to download."
2020-06-10 15:23:38 +00:00
return
fi
mv $temp_name "$filename.mp4"
}
2020-11-23 19:13:36 +00:00
# Download from m3u8 stream to mp4.
2023-07-21 23:28:41 +00:00
# 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.
#
2023-08-02 19:11:38 +00:00
download_mp4_from_m3u8() {
2020-11-23 19:13:36 +00:00
local m3u8_path="$1"
local filename="$2"
if [[ $m3u8_path == "" || $filename == "" ]]; then
2023-06-06 19:48:43 +00:00
error "Usage: <m3u8 path> <filename>"
2020-11-23 19:13:36 +00:00
return
fi
printf "${BOLD}Downloading: ${YELLOW}$filename${NORMAL}\n"
2023-10-05 20:18:38 +00:00
ffmpeg.exe -protocol_whitelist file,data,https,crypto,tls,tcp -allowed_extensions ALL -i $m3u8_path -acodec copy -vcodec copy "${filename}.mp4"
2020-11-23 19:13:36 +00:00
if [[ $? -ne 0 ]]; then
2023-03-16 16:59:23 +00:00
error "Error: failed to download."
2020-11-23 19:13:36 +00:00
return
fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
}
2023-08-02 19:11:38 +00:00
# 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
error "Error: failed to download."
return
fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
}
2020-06-10 15:23:38 +00:00
2023-06-04 18:40:59 +00:00
#-------------------------------------------------
2021-07-14 15:16:23 +00:00
# YouTube Vid DL
2023-06-04 18:40:59 +00:00
#-------------------------------------------------
2023-06-09 21:20:24 +00:00
alias yt-list='download_youtube_uploads_list 0 '
alias yt-list-desc='download_youtube_uploads_list 1 '
2023-06-06 19:48:43 +00:00
2023-06-04 18:40:59 +00:00
alias yt='download_youtube_vid "" $SHORTNAME_OFF $TRANSCRIBE_OFF'
alias yt-shortname='download_youtube_vid "" $SHORTNAME_ON $TRANSCRIBE_OFF'
2024-01-21 03:19:57 +00:00
alias yt-1440='download_youtube_vid "620+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
2024-09-16 02:02:55 +00:00
alias yt-1440p60='download_youtube_vid "400+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
2024-01-21 03:19:57 +00:00
alias yt-1440-shortname='download_youtube_vid "620+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
2023-06-04 18:40:59 +00:00
alias yt-1080='download_youtube_vid "137+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
alias yt-1080-shortname='download_youtube_vid "137+140" $SHORTNAME_ON $TRANSCRIBE_OFF'
alias yt-720='download_youtube_vid "136+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
alias yt-720-shortname='download_youtube_vid "136+140" $SHORTNAME_ON $TRANSCRIBE_OFF'
#TRANSCRIPTION ON
alias ytt='download_youtube_vid "" $SHORTNAME_OFF $TRANSCRIBE_ON'
alias yt-shortname-t='download_youtube_vid "" $SHORTNAME_ON $TRANSCRIBE_ON'
2024-01-21 03:19:57 +00:00
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'
2023-06-04 18:40:59 +00:00
alias yt-1080-t='download_youtube_vid "137+140" $SHORTNAME_OFF $TRANSCRIBE_ON'
alias yt-1080-shortname-t='download_youtube_vid "137+140" $SHORTNAME_ON $TRANSCRIBE_ON'
alias yt-720-t='download_youtube_vid "136+140" $SHORTNAME_OFF $TRANSCRIBE_ON'
alias yt-720-shortname-t='download_youtube_vid "136+140" $SHORTNAME_ON $TRANSCRIBE_ON'
#---------------------------
2024-11-22 01:26:16 +00:00
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"'
2023-06-06 19:48:43 +00:00
alias yt-playlist-list='download_youtube_playlist_list '
2024-05-20 18:25:46 +00:00
#---------------------------
2023-07-14 21:29:59 +00:00
alias yt-audio='download_youtube_audio'
2020-06-10 15:23:38 +00:00
2023-06-04 18:40:59 +00:00
#-------------------------------------------------
2021-07-14 15:16:23 +00:00
# Twitch Vid DL
2023-06-04 18:40:59 +00:00
#-------------------------------------------------
2023-03-01 20:27:38 +00:00
alias tw-chat='download_twitch_chat'
2023-06-04 18:40:59 +00:00
alias tw='download_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_OFF $TRANSCRIBE_OFF'
alias tw-compressed='download_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-shortname='download_twitch_vid "" $SHORTNAME_ON $COMPRESSION_OFF $TRANSCRIBE_OFF'
alias tw-shortname-compressed='download_twitch_vid "" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-source='download_twitch_vid "Source" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-custom='download_twitch_vid '
#TRANSCRIPTION ON
alias twt='download_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_OFF $TRANSCRIBE_ON'
alias tw-compressed-t='download_twitch_vid "" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-shortname-t='download_twitch_vid "" $SHORTNAME_ON $COMPRESSION_OFF $TRANSCRIBE_ON'
alias tw-shortname-compressed-t='download_twitch_vid "" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-source-t='download_twitch_vid "Source" "Source" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
#1080p
alias tw-1080='download_twitch_vid "1080" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080-compressed='download_twitch_vid "1080" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080-shortname='download_twitch_vid "1080" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080-shortname-compressed='download_twitch_vid "1080" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
#TRANSCRIPTION ON
alias tw-1080-t='download_twitch_vid "1080" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080-compressed-t='download_twitch_vid "1080" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080-shortname-t='download_twitch_vid "1080" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080-shortname-compressed-t='download_twitch_vid "1080" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
#1080p60/50
alias tw-1080p60='download_twitch_vid "1080p60" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080p50='download_twitch_vid "1080p50" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080p60-compressed='download_twitch_vid "1080p60" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080p50-compressed='download_twitch_vid "1080p50" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080p60-shortname='download_twitch_vid "1080p60" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080p50-shortname='download_twitch_vid "1080p50" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080p60-shortname-compressed='download_twitch_vid "1080p60" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-1080p50-shortname-compressed='download_twitch_vid "1080p50" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
#TRANSCRIPTION ON
alias tw-1080p60-t='download_twitch_vid "1080p60" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p50-t='download_twitch_vid "1080p50" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p60-compressed-t='download_twitch_vid "1080p60" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p50-compressed-t='download_twitch_vid "1080p50" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p60-shortname-t='download_twitch_vid "1080p60" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p50-shortname-t='download_twitch_vid "1080p50" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p60-shortname-compressed-t='download_twitch_vid "1080p60" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-1080p50-shortname-compressed-t='download_twitch_vid "1080p50" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
#720p
alias tw-720='download_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-720-compressed='download_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-720-shortname='download_twitch_vid "720p" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-720p60='download_twitch_vid "720p60" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-720p60-shortname='download_twitch_vid "720p60" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
#TRANSCRIPTION ON
alias tw-720-t='download_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-720-compressed-t='download_twitch_vid "720p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-720-shortname-t='download_twitch_vid "720p" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-720p60-t='download_twitch_vid "720p60" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-720p60-shortname-t='download_twitch_vid "720p60" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
#4k
alias tw-4k='download_twitch_vid "2160p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-4k-compressed='download_twitch_vid "2160p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-4k-shortname='download_twitch_vid "2160p" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
alias tw-4k-shortname-compressed='download_twitch_vid "2160p" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_OFF'
#TRANSCRIPTION ON
alias tw-4k-t='download_twitch_vid "2160p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-4k-compressed-t='download_twitch_vid "2160p" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-4k-shortname-t='download_twitch_vid "2160p" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
alias tw-4k-shortname-compressed-t='download_twitch_vi "2160p" $SHORTNAME_ON $COMPRESSION_ON $TRANSCRIBE_ON'
#-------------------------------------------------
2021-07-14 15:16:23 +00:00
# Vimeo Vid DL
2023-06-04 18:40:59 +00:00
#-------------------------------------------------
alias vimeo='download_vimeo_vid $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias vimeo-t='download_vimeo_vid $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
alias vimeo-compressed='download_vimeo_vid $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
alias vimeo-compressed-t='download_vimeo_vid $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
2021-07-14 15:16:23 +00:00
2023-06-04 18:40:59 +00:00
#-------------------------------------------------
2022-03-11 19:22:23 +00:00
# Instagram Vid DL
2023-06-04 18:40:59 +00:00
#-------------------------------------------------
alias ig='download_instagram_vid $TRANSCRIBE_OFF'
alias igt='download_instagram_vid $TRANSCRIBE_ON'
2022-03-11 19:22:23 +00:00
2023-06-04 18:40:59 +00:00
#-------------------------------------------------
2022-08-03 22:05:57 +00:00
# Twitter Vid DL
2023-06-04 18:40:59 +00:00
#-------------------------------------------------
2023-06-04 15:57:32 +00:00
alias twitter='download_twitter_vid "" '
2022-08-03 22:05:57 +00:00
2023-06-04 18:40:59 +00:00
#-------------------------------------------------
2021-07-14 15:16:23 +00:00
# Misc
2023-06-04 18:40:59 +00:00
#-------------------------------------------------
2023-03-01 20:27:38 +00:00
alias download-mp4='download_mp4'
2023-08-02 19:11:38 +00:00
alias download-from-m3u8='download_mp4_from_m3u8'
alias download-audio-from-m3u8='download_aac_from_m3u8'
2020-11-23 19:13:36 +00:00
2021-07-14 16:10:23 +00:00
####################################################################################################
2021-07-14 15:16:23 +00:00
# Video Compression
2021-07-14 16:10:23 +00:00
####################################################################################################
2021-07-14 15:16:23 +00:00
function _compress_video_hard() {
local crf=35
local name="$1"
local out="$2"
if [[ name == "" || out == "" ]]; then
2023-03-16 16:59:23 +00:00
error "Usage: cmd <source> <dest>"
2021-07-14 15:16:23 +00:00
return
fi
2023-01-05 03:24:46 +00:00
# 0=cpu, 1=gpu
compress-video-with-crf $crf "$name" "$out" 0
2021-07-14 15:16:23 +00:00
}
alias compress-video-hard='_compress_video_hard'
2023-11-02 16:14:48 +00:00
alias cv='compress-video'
alias cvh='compress-video-hard'
2024-01-21 03:19:57 +00:00
alias jv='join-video'
2024-09-16 02:02:55 +00:00
alias av='analyze-volume'
alias aa='analyze-volume'
2023-11-02 16:14:48 +00:00
alias nv='normalize-volume'
2023-11-21 01:11:59 +00:00
alias na='normalize-volume'
2024-01-21 03:19:57 +00:00
alias tv='trim-video'
2021-07-14 15:16:23 +00:00
2020-05-14 06:44:25 +00:00
####################################################################################################
2013-07-07 21:30:11 +00:00
# Git
2020-05-14 06:44:25 +00:00
####################################################################################################
2017-02-18 18:05:08 +00:00
2020-07-30 15:56:04 +00:00
if [[ '${platform,,}' == *'ming'* ]]; then
2021-08-11 14:37:41 +00:00
# Fix a weird mingw 'not a valid identifierline' error.
# Got the fix from https://github.com/Alexpux/MSYS2-packages/issues/735#issuecomment-328938800
alias git="PATH=/usr/bin git"
2017-11-21 04:08:51 +00:00
fi
2017-10-10 23:49:48 +00:00
2024-05-19 21:28:23 +00:00
# Performs a commit amend with the nocheckin prehook disabled.
git_amend_nocheckin() {
eval "DISABLE_NOCHECKIN=1 git commit --amend"
}
2021-07-14 16:10:23 +00:00
git_cmd_wrapper() {
2021-08-11 14:37:41 +00:00
# If no args are provided then run `git status -s`
if [[ $# > 0 ]]; then
git $@
else
git status -s
fi
2021-07-14 16:10:23 +00:00
}
git_commit() {
cmd="git commit -m \"$*\""
eval "$cmd"
}
2021-09-14 00:59:47 +00:00
# Performs a commit with the nocheckin prehook disabled.
git_commit_nocheckin() {
cmd="git commit -m \"$*\""
eval "DISABLE_NOCHECKIN=1 $cmd"
}
2021-07-14 16:10:23 +00:00
git_commit_signed() {
cmd="git commit -S -m \"$*\""
eval "$cmd"
}
2024-05-19 21:28:23 +00:00
# Performs a commit amend to the head with the nocheckin prehook disabled.
2021-09-14 00:59:47 +00:00
git_fix_nocheckin() {
eval "DISABLE_NOCHECKIN=1 git commit --amend -C HEAD"
}
2021-07-14 16:10:23 +00:00
git_branch_name() {
val=`git branch 2>/dev/null | grep '^*' | colrm 1 2`
echo "$val"
}
git_nuke() {
2021-08-11 14:37:41 +00:00
git checkout master && git branch -D $1 && git push origin :$1
}
git_create_stash_patch() {
stashNum="$1"
file="stash_$stashNum.patch"
git stash show "stash@{$stashNum}" -p > $file
printf "${BOLD}${YELLOW}Created $file for stash@{$stashNum}.${NORMAL}\n"
2021-07-14 16:10:23 +00:00
}
2024-12-24 00:58:11 +00:00
git_print_tracked_file_sizes() {
git ls-tree -r -l HEAD | sort -k 4 -nr | awk '{
sha = substr($3, 1, 7); # Truncate the commit SHA to 7 characters
if ($4 >= 1024 * 1024) {
printf "%s sha:%s %06.2f MB %s\n", $2, sha, $4 / 1024 / 1024, $5
} else if ($4 >= 1024) {
printf "%s sha:%s %06.2f KB %s\n", $2, sha, $4 / 1024, $5
} else {
printf "%s sha:%s %04d B %s\n", $2, sha, $4, $5
}
}'
}
2015-11-04 19:25:27 +00:00
alias am='git commit --amend'
2024-05-19 21:28:23 +00:00
alias amno='git_amend_nocheckin'
2015-11-18 02:50:00 +00:00
alias ama='git commit --amend -C head --author'
2015-11-04 19:25:27 +00:00
alias ams='git commit -S --amend' # signed
2020-07-21 15:29:52 +00:00
alias g='git_cmd_wrapper'
2019-10-12 16:29:11 +00:00
alias ga='git add -A'
2020-05-14 05:45:07 +00:00
alias gaa='git add -A; gdcc'
2019-10-12 16:29:11 +00:00
alias gap='git add -Ap'
2013-07-07 21:30:11 +00:00
alias gau='git add --update'
2020-06-10 15:23:38 +00:00
alias gaup='git add --update -p'
2017-07-13 20:02:25 +00:00
alias gb='git branch -v'
2020-09-30 01:51:11 +00:00
alias gbb='git bisect bad'
2013-07-16 23:36:06 +00:00
alias gbd='git branch -D'
2023-06-09 21:20:24 +00:00
alias gbdr='git branch -Dr' # Delete a remote tracking branch; useful when the remote no longer exists and branch pruning isn't removing the lingering tracking branches.
2020-09-30 01:51:11 +00:00
alias gbg='git bisect good'
2014-05-17 19:31:36 +00:00
alias gbl='git branch --all'
2018-03-15 18:39:50 +00:00
alias gblm='git blame -wMC'
2014-09-30 00:51:23 +00:00
alias gbm='git branch -m'
2015-11-04 19:25:27 +00:00
alias gbr='git branch -rv'
2013-07-07 21:30:11 +00:00
alias gc='git commit'
2013-07-07 21:25:47 +00:00
alias gcl='git clone'
2020-05-14 06:44:25 +00:00
alias gcm='git_commit'
alias gcms='git_commit_signed' # signed
2021-09-14 00:59:47 +00:00
alias gcmno='git_commit_nocheckin'
2013-07-07 21:25:47 +00:00
alias gco='git checkout'
2017-08-21 18:26:38 +00:00
alias gco-='git checkout -'
2013-07-16 23:36:06 +00:00
alias gcob='git checkout -b'
2014-06-25 16:41:29 +00:00
alias gcon='vi .git/config'
2013-07-07 21:30:11 +00:00
alias gcp='git cherry-pick'
2014-12-01 00:18:25 +00:00
alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
2014-05-17 19:31:36 +00:00
alias gcps='git cherry-pick -n'
2013-07-07 21:25:47 +00:00
alias gd='git diff'
2020-05-14 05:45:07 +00:00
alias gdc='git diff --cached'
alias gdcc='git diff --cached --color-words'
2013-07-07 21:25:47 +00:00
alias gdm='git diff master'
2013-07-07 21:30:11 +00:00
alias gds='git diff --stat=160,120'
alias gf='git fetch'
2015-02-24 04:34:00 +00:00
alias gfa='git fetch --all'
2020-05-14 05:45:07 +00:00
alias gfd='git fetch --prune' # Removes remote branches that don't have a counterpart branch on the remote.
2021-09-14 00:59:47 +00:00
alias gfix='git commit --amend -C HEAD'
alias gfixs='git commit -S -a --amend -C HEAD' # signed
alias gfixno='git_fix_nocheckin'
2014-02-17 07:00:21 +00:00
alias gfo='git fetch origin'
2020-03-15 18:44:36 +00:00
alias gfu='git fetch up'
2014-02-17 07:00:21 +00:00
alias gfm='git fetch origin master'
2015-02-24 04:34:00 +00:00
alias gfup='git fetch upstream'
2024-04-26 19:10:26 +00:00
alias ggcf='git gc --prune=now'
2015-11-04 19:25:27 +00:00
alias ggrep='git log --all --oneline | grep '
2015-10-16 05:11:24 +00:00
alias gla='git lg --all'
alias gl='git lg -30'
alias gll='git lg'
2014-01-25 04:04:23 +00:00
alias gli='git show --pretty="format:" --name-only'
alias glog='git log'
2019-10-12 16:29:11 +00:00
alias glom='gl origin/master'
2013-07-25 16:54:40 +00:00
alias gm='git merge'
2015-11-04 19:25:27 +00:00
alias gmnff='git merge --no-ff'
2013-07-10 16:13:13 +00:00
alias gmff='git merge --ff-only'
2015-10-16 05:11:24 +00:00
alias gmffm='git merge --ff-only master'
2014-02-17 07:00:21 +00:00
alias gmffs='git merge --ff-only --squash'
2013-07-07 21:30:11 +00:00
alias gmtheirs='git merge -Xtheirs'
2013-07-07 21:25:47 +00:00
alias gp='git push'
2024-12-24 00:58:11 +00:00
alias gpa='echo "pushing all branches..." && git push --all && echo "pushing tags..." && git push --tags'
alias gpaf='echo "force pushing all branches..." && git push --all -f && echo "force pushing tags..." && git push --tags -f'
2020-09-29 20:53:38 +00:00
alias gpf='git push -f'
2013-07-07 21:30:11 +00:00
alias gpff='git pull --ff-only'
2020-09-29 20:53:38 +00:00
alias gplu='git pull --set-upstream origin HEAD'
2015-02-24 04:34:00 +00:00
alias gplup='git pull upstream master'
2016-10-23 16:45:42 +00:00
alias gpo='git push origin'
2013-07-07 21:30:11 +00:00
alias gpom='git push origin master'
2013-07-07 21:25:47 +00:00
alias gpr='git pull --rebase'
2014-05-17 19:31:36 +00:00
alias gpt='git push --tags'
2024-04-26 19:10:26 +00:00
alias gptf='git push --tags -f'
2020-09-29 20:53:38 +00:00
alias gpu='git push --set-upstream origin HEAD'
2013-07-07 21:30:11 +00:00
alias gr='git reset'
2023-12-02 04:48:11 +00:00
alias gr1='git reset HEAD^1; gl'
2021-12-01 04:03:55 +00:00
alias grb='git rebase --autostash'
2014-01-25 04:04:23 +00:00
alias grba='git rebase --abort'
alias grbc='git rebase --continue'
2015-11-29 19:04:40 +00:00
alias grbs='git rebase --skip'
2019-03-28 00:13:27 +00:00
alias grbi='git rebase -i --autostash'
alias grbm='git rebase master --autostash'
alias grbmi='git rebase master -i --autostash'
2021-12-19 21:45:35 +00:00
alias grbom='git fetch origin master && git rebase origin/master --autostash'
alias grbomi='git fetch origin master && git rebase origin/master -i --autostash'
2021-12-01 04:03:55 +00:00
alias grbum='git fetch upstream master && git rebase upstream/master --autostash'
2021-12-19 21:45:35 +00:00
alias grbumi='git fetch upstream master && git rebase upstream/master -i --autostash'
2013-07-07 21:30:11 +00:00
alias gre='git remote'
2014-09-30 00:51:23 +00:00
alias grea='git remote add'
2016-04-14 13:34:42 +00:00
alias gremo='git remote remove origin; git remote add origin'
2014-09-30 00:51:23 +00:00
alias greao='git remote add origin'
2019-09-30 20:51:05 +00:00
alias gred='git remote remove'
2018-11-28 17:22:28 +00:00
alias gref='git reflog --format="%C(auto)%h %<|(17)%gd %C(cyan)%ci%C(reset) [%gs] %C(yellow)(%s)%C(reset)"'
2013-08-13 15:17:54 +00:00
alias grev='git remote -v'
2013-07-16 15:24:18 +00:00
alias grm='git rm'
2015-02-24 04:34:00 +00:00
alias grmr='git rm -r'
2016-04-14 13:34:42 +00:00
alias grp='git reset -p'
2013-07-07 21:30:11 +00:00
alias gsnapshot='git stash save "snapshot: $(date)" && git stash apply "stash@{0}"'
2014-03-07 20:00:19 +00:00
alias gsh='git show'
2018-03-15 18:39:50 +00:00
alias gshh='git show -w'
2013-07-07 21:30:11 +00:00
alias gs='git stash'
2021-08-11 14:37:41 +00:00
alias gsc='git_create_stash_patch'
2016-04-14 13:34:42 +00:00
alias gsk='git stash -k -u'
2019-10-12 16:29:11 +00:00
alias gssk='git stash save -k -u'
2013-07-17 22:46:38 +00:00
alias gss='git stash save'
2013-07-07 21:30:11 +00:00
alias gsd='git stash drop'
alias gsl='git stash list'
2016-04-14 13:34:42 +00:00
alias gsi='git stash -p'
2013-07-07 21:30:11 +00:00
alias gsp='git stash pop'
2024-05-19 21:28:23 +00:00
alias gspm='git stash pop --merge'
2017-08-21 18:26:38 +00:00
alias gsp0='git stash pop stash@{0}'
alias gsp1='git stash pop stash@{1}'
alias gsp2='git stash pop stash@{2}'
alias gsp3='git stash pop stash@{3}'
alias gsp4='git stash pop stash@{4}'
alias gsp5='git stash pop stash@{6}'
alias gsp6='git stash pop stash@{7}'
2023-06-09 21:20:24 +00:00
alias gt='git tag' # Unsigned
2014-05-17 19:31:36 +00:00
alias gta='git tag -a'
alias gtd='git tag -d'
alias gtl='git tag -l'
2023-06-09 21:20:24 +00:00
alias gts='git tag -s' # Signed
2013-07-07 21:30:11 +00:00
alias gx='git reset --hard'
2015-11-04 19:25:27 +00:00
alias gxx='git reset --hard HEAD~1'
2019-10-12 16:29:11 +00:00
alias gxom='git reset --hard origin/master'
2015-11-17 05:11:13 +00:00
alias gstats='echo "Total commits: $(git rev-list HEAD --count)"; echo "\nAuthor breakdown:"; git shortlog | grep -E "^[^ ]"'
2024-12-24 00:58:11 +00:00
alias gsize='git_print_tracked_file_sizes'
2015-10-16 05:11:24 +00:00
alias gwip="git add . && git commit -m \"WIP\""
2013-07-07 21:30:11 +00:00
2021-12-01 04:04:27 +00:00
####################################################################################################
# Elixir
####################################################################################################
2022-10-27 21:00:49 +00:00
alias iex='rlwrap -i -f ~/.iex_history -H ~/.iex_history -s 30000 iex'
alias iexw='rlwrap -i -f ~/.iex_history -H ~/.iex_history -s 30000 iex --werl'
2021-12-03 02:07:47 +00:00
alias ep='iex -S mix phx.server'
alias ei='iex -S mix'
2021-12-01 04:04:27 +00:00
alias er='mix phx.server'
2021-12-03 02:07:47 +00:00
alias et='mix test'
2021-12-01 04:04:27 +00:00
2021-07-14 16:10:23 +00:00
####################################################################################################
2017-08-10 15:46:10 +00:00
# Haxe
2021-07-14 16:10:23 +00:00
####################################################################################################
2017-08-10 15:46:10 +00:00
alias flow='haxelib run flow'
alias snowfall='haxelib run snowfall'
2021-07-14 16:10:23 +00:00
####################################################################################################
# CMake
####################################################################################################
2017-06-12 11:23:58 +00:00
alias cmake-gen='cmake -D CMAKE_CXX_COMPILER="/Library/Developer/CommandLineTools/usr/bin/c++" CMAKE_C_COMPILER="/Library/Developer/CommandLineTools/usr/bin/cc" ..'
2020-09-30 01:51:11 +00:00