Merge branch 'master' of github.com:hykilpikonna/zshrc

This commit is contained in:
Azalea
2023-03-24 10:48:31 -04:00
24 changed files with 3001 additions and 188 deletions
+3
View File
@@ -7,3 +7,6 @@
[submodule "plugins/find-the-command"]
path = plugins/find-the-command
url = https://github.com/pkasemir/find-the-command
[submodule "config-sync/.config/ibus/rime/rime-japanese"]
path = config-sync/.config/ibus/rime/rime-japanese
url = https://github.com/gkovacs/rime-japanese
@@ -1,4 +1,5 @@
patch:
schema_list:
- schema: luna_pinyin_simp
- schema: japanese
menu/page_size: 7
+1
View File
@@ -0,0 +1 @@
rime-japanese/japanese.dict.yaml
@@ -0,0 +1 @@
rime-japanese/japanese.jmdict.dict.yaml
@@ -0,0 +1 @@
rime-japanese/japanese.kana.dict.yaml
@@ -0,0 +1 @@
rime-japanese/japanese.mozc.dict.yaml
+1
View File
@@ -0,0 +1 @@
rime-japanese/japanese.schema.yaml
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,15 @@
patch:
# engine/translators/+:
# - punct_translator
# - r10n_translator
# - reverse_lookup_translator
# meaning of the regex: ^ start of line, \\ the starting \, .+ any char 1 or more time, $ end
recognizer/patterns/reverse_lookup: '^\\.+$'
schema/dependencies/+:
- latex
abc_segmentor/extra_tags:
- reverse_lookup
reverse_lookup:
dictionary: latex
enable_completion: false
tips: latex
@@ -0,0 +1,36 @@
# Rime schema
# encoding: utf-8
schema:
schema_id: latex
name: Latex Math Symbols
version: "1.1"
author:
- slbtty <shenlebantongying@gmail.com>
- mark <mark@mkmark.net>
description: |
Latex Math Symbols Input Method.
You have to type '\' first to get symbols.
This schema is intended to be used as an addon for other input methods.
engine:
processors:
- speller # to enable alphabet & initials below.
- selector
- navigator
- express_editor
segmentors:
- abc_segmentor
- fallback_segmentor
translators:
- table_translator
speller:
alphabet: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\^_-><+-=()[]'
initials: '\_^'
auto_select: true
translator:
dictionary: latex
enable_sentence: false
enable_user_dict: false
@@ -2,6 +2,8 @@ __patch:
# Rx: emoji:customize:schema=luna_pinyin {
- patch/+:
__include: emoji_suggestion:/patch
- patch/+:
__include: latex.patch:/patch
# }
# https://wiki.archlinuxcn.org/wiki/Fcitx5#RIME/%E4%B8%AD%E5%B7%9E%E9%9F%BB
@@ -10,4 +12,4 @@ __patch:
patch:
"translator/dictionary": extended #词典名字可自定义,与下方文件名保持一致即可
'engine/translators/+':
- lua_translator@date_translator
- lua_translator@date_translator
+6
View File
@@ -48,3 +48,9 @@ Host caspase
Host kevin
HostName caspase3kjq.terra-incognita.dev
User me@hydev.org
Host ut-343
HostName dbsrv1.teach.cs.toronto.edu
Host ut-cs
HostName teach.cs.toronto.edu
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
level="${level:-19}"
cmd=$(which tar)
if command -v "gtar" &> /dev/null; then
cmd=$(which gtar)
fi
echo "Using $cmd"
# Read first parameter
arg1="$1"
name="$1".tar.zst.gpg
shift
echo "Output to $name"
# Read second parameter
if [[ -z "$*" ]]; then
files="$arg1"
else
files="$*"
fi
echo "Compressing $files"
cores=$(python3 -c "import os; print(os.cpu_count())")
echo "Starting ZSTD compression with $cores cores and level $level"
"$cmd" -I "zstd -T$cores -$level" --checkpoint=.1024 --totals --totals=SIGUSR1 -cf - "$files" | gpg --symmetric --cipher-algo aes256 -o "$name"
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
#######################################
# Variables #
#######################################
SSD_DEVICE="/dev/sda"
ON_TIME_TAG="Power_On_Hours"
WEAR_COUNT_TAG="Wear_Leveling_Count"
LBAS_WRITTEN_TAG="Total_LBAs_Written"
LBA_SIZE=512 # Value in bytes
BYTES_PER_MB=1048576
BYTES_PER_GB=1073741824
BYTES_PER_TB=1099511627776
#######################################
# Get total data written... #
#######################################
# Get SMART attributes
SMART_INFO=$(sudo /usr/sbin/smartctl -A "$SSD_DEVICE")
# Extract required attributes
ON_TIME=$(echo "$SMART_INFO" | grep "$ON_TIME_TAG" | awk '{print $10}')
WEAR_COUNT=$(echo "$SMART_INFO" | grep "$WEAR_COUNT_TAG" | awk '{print $4}' | sed 's/^0*//')
LBAS_WRITTEN=$(echo "$SMART_INFO" | grep "$LBAS_WRITTEN_TAG" | awk '{print $10}')
# Convert LBAs -> bytes
BYTES_WRITTEN=$(echo "$LBAS_WRITTEN * $LBA_SIZE" | bc)
MB_WRITTEN=$(echo "scale=3; $BYTES_WRITTEN / $BYTES_PER_MB" | bc)
GB_WRITTEN=$(echo "scale=3; $BYTES_WRITTEN / $BYTES_PER_GB" | bc)
TB_WRITTEN=$(echo "scale=3; $BYTES_WRITTEN / $BYTES_PER_TB" | bc)
# Output results...
echo "------------------------------"
echo " SSD Status: $SSD_DEVICE"
echo "------------------------------"
echo " On time: $(echo $ON_TIME | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta') hr"
echo "------------------------------"
echo " Data written:"
echo " MB: $(echo $MB_WRITTEN | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
echo " GB: $(echo $GB_WRITTEN | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
echo " TB: $(echo $TB_WRITTEN | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
echo "------------------------------"
echo " Mean write rate:"
echo " MB/hr: $(echo "scale=3; $MB_WRITTEN / $ON_TIME" | bc | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
echo "------------------------------"
echo " Drive health: ${WEAR_COUNT} %"
echo "------------------------------"
@@ -4,7 +4,8 @@ from __future__ import annotations
import os
import platform
import re
from subprocess import Popen
import shutil
from subprocess import Popen, check_call
import sys
import shlex
from datetime import datetime
@@ -107,23 +108,29 @@ def rename():
os.rename(file, date)
def convert_gnome():
rec_dir = Path.home() / "Videos/Screencasts"
fs = [rec_dir / str(f) for f in os.listdir(rec_dir) if str(f).startswith("Screencast") and str(f).endswith(".webm")]
for inf in fs:
sp = inf.stem.split(" ")
ouf = rec_dir / f"Rec {sp[2]} {sp[3][:sp[3].rindex('-')]}.mp4"
if ouf.is_file():
print(f"Already converted: {inf}")
continue
print(f"Converting '{inf}' to '{ouf}'")
check_call(['ffmpeg', '-i', inf,
'-c:v', 'libx264',
'-vf', 'crop=trunc(iw/2)*2:trunc(ih/2)*2, fps=30',
'-y',
ouf])
if input("Remove files? [y/N]") == "y":
[os.remove(f) for f in fs]
if __name__ == '__main__':
if not hasattr(sys, 'ps1'):
args = sys.argv[1:]
if len(args) < 1:
print('Usage: compress [rename/python code]')
# Command to rename all screen recordings
if args[0] == 'rename':
rename()
exit()
# processor = args[0].lower().strip()
# i = args[1]
# crf = args[2] if len(args) > 2 else '24'
# cmd = 'cmd' in processor
# if cmd:
# processor = processor.replace('cmd', '')
# additional_args = ' '.join(args[3:] if len(args) > 3 else [])
print(eval(' '.join(args[0:])))
args = sys.argv[1:]
if args:
v = eval(args[0])
if v:
print(v)
+32
View File
@@ -0,0 +1,32 @@
# Mamba (conda replacement)
alias mamba="micromamba"
alias mamba-install="curl micro.mamba.pm/install.sh | zsh"
export MAMBA_ROOT_PREFIX="$HOME/.conda"
# Mamba initialize function
mamba-init()
{
export MAMBA_EXE="$(which micromamba)";
__mamba_setup="$("$MAMBA_EXE" shell hook --shell zsh --prefix "$HOME/micromamba" 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__mamba_setup"
else
if [ -f "$MAMBA_ROOT_PREFIX/etc/profile.d/micromamba.sh" ]; then
. "$MAMBA_ROOT_PREFIX/etc/profile.d/micromamba.sh"
else
export PATH="$MAMBA_ROOT_PREFIX/bin:$PATH"
fi
fi
unset __mamba_setup
}
# Auto init mamba
if command -v 'micromamba' &> /dev/null; then
mamba-init
fi
# Pyenv
if command -v 'pyenv' &> /dev/null; then
eval "$(pyenv init -)"
PATH=$(pyenv root)/shims:$PATH
fi
+24
View File
@@ -0,0 +1,24 @@
if command -v 'docker-compose' &> /dev/null; then
alias dc='docker-compose'
else
alias dc='docker compose'
fi
alias docker-ip="docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}'"
alias dockers="docker ps --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}'"
# Docker linux containers
alpine-create()
{
docker rmi azalea/alpine
docker run -it --name alpine-init --hostname alpine alpine \
/bin/sh -c 'apk add zsh bash git curl wget tar zstd python3 && bash <(curl -sL hydev.org/zsh)'
docker commit alpine-init azalea/alpine
docker rm alpine-init
}
alias alpine="docker start -ai alpine"
alias alpine-init="docker run -it --name alpine --hostname alpine azalea/alpine zsh"
alias psqlt+="docker run --rm -dit --name psql-test --hostname psql -e POSTGRES_HOST_AUTH_METHOD=trust postgres && echo 'Created'"
alias psqlt-="docker stop psql-test && echo 'Deleted'"
alias psqlt='psql -h $(docker-ip psql-test) -p 5432 -U postgres'
-16
View File
@@ -1,16 +0,0 @@
# Git commit wrapper
commit() {
msg="$@"
git commit -m "$msg"
}
commitall() {
git add .
commit "$@"
}
alias commita="commitall"
compush() {
commitall "$@"
git push
}
+63
View File
@@ -0,0 +1,63 @@
# Git commit wrapper
commit() {
msg="$@"
git commit -m "$msg"
}
commitall() {
git add .
commit "$@"
}
alias commita="commitall"
compush() {
commitall "$@"
git push
}
# Git identity
git-ida() {
# Zsh only
TMP_ARR=("${(@f)$(git-id-list get "$1")}")
git-id "${TMP_ARR[1]}" "${TMP_ARR[2]}"
}
git-id() {
export GIT_USER="$1"
export GIT_EMAIL="$2"
git-id-prompt
}
git-id-prompt() {
if [[ -z "$GIT_USER" ]] && [[ -z "$GIT_EMAIL" ]]; then
prompt-reset
else
prompt-set 30 "&cGit ID: $GIT_USER | $GIT_EMAIL "
prompt-update
fi
}
git-id-prompt
[[ -z $GIT_BIN ]] && GIT_BIN=$(which git)
git() {
if [[ -z "$GIT_USER" ]]; then
$GIT_BIN "$@"
else
$GIT_BIN -c "user.name=$GIT_USER" -c "user.email=$GIT_EMAIL" -c "commit.gpgsign=false" "$@"
fi
}
# Git environment
git-env() {
git_commands=( add bisect branch checkout clone commit diff fetch grep init log merge pull push rebase reset restore show status tag )
for i in "${git_commands[@]}"
do
alias "$i"="git $i"
done
alias 'grm'='git rm'
alias 'gmv'='git mv'
}
git-unenv() {
git_commands=( add bisect branch checkout clone commit diff fetch grep init log merge pull push rebase reset restore show status tag grm gmv )
for i in "${git_commands[@]}"
do
unalias "$i"
done
}
+8
View File
@@ -22,6 +22,14 @@ if [[ $OSTYPE == 'darwin'* ]]; then
export JAVA_HOME=${JDK11}
export PATH="${JDK11}/bin:$PATH"
# Mac hostname
mac-hostname() {
name="$@"
sudo scutil --set HostName "$name"
sudo scutil --set LocalHostName "$name"
sudo scutil --set ComputerName "$name"
}
# Anaconda
export CONDA_PATH="/usr/local/anaconda3"
export PATH="$CONDA_PATH/bin:$PATH"
+21
View File
@@ -0,0 +1,21 @@
# Cut videos - cut <file name> <end time> [start time (default 00:00:00)]
cutv() {
if [ "$#" -lt 2 ]; then
echo "Usage: cut <file name> <end time (hh:mm:ss)> [start time (00:00:00)]"
return 2
fi
local start="${3:-00:00:00}"
echo "$1"
echo "$2"
echo "$start"
ffmpeg -i "$1" -codec copy -ss "$start" -t "$2" Cut\ "$1"
}
alias vcomp="$BASEDIR/scripts/bin/video.py"
alias vcompy="ipython -i $BASEDIR/scripts/bin/video.py"
flac2mp3() {
for file in *.flac; do
ffmpeg -i "$file" -ab 320k -map_metadata 0 -id3v2_version 3 "${file%.flac}.mp3"
done
}
+6 -4
View File
@@ -21,17 +21,19 @@ pcolor() {
# Build a zsh prompt
prompt-reset() {
host="$(sed "s/HyDEV-//g" <<< "$HOST")"
# New line first
prompt-set 0 "&n"
# Time stamp
prompt-set 10 "&5%D{%a %m-%d %H:%M}&r "
[[ "$HOST" != "HyDEV" ]] && prompt-set 10 "&gf(#55CDFC)%D{%a} &gf(#F7A8B8)%D{%m-}&f%D{%d} &gf(#F7A8B8)%D{%H:}&gf(#55CDFC)%D{%M}&r "
[[ "$host" != "HyDEV" ]] && prompt-set 10 "&gf(#55CDFC)%D{%a} &gf(#F7A8B8)%D{%m-}&f%D{%d} &gf(#F7A8B8)%D{%H:}&gf(#55CDFC)%D{%M}&r "
# Hostname
prompt-set 20 "&1%m&r "
[[ "$HOST" == "HyDEV" ]] && prompt-set 20 "&gf(#55CDFC)H&gf(#F7A8B8)y&fD&gf(#F7A8B8)E&gf(#55CDFC)V&r "
prompt-set 20 "&1$host&r "
[[ "$host" == "HyDEV" ]] && prompt-set 20 "&gf(#55CDFC)H&gf(#F7A8B8)y&fD&gf(#F7A8B8)E&gf(#55CDFC)V&r "
# Username, or show a cat if I'm hykilpikonna
prompt-set 30 "&e%n&r "
[[ "$USER" == "hykilpikonna" ]] && prompt-set 30 "🐱 "
[[ "$USER" == "hykilpikonna" || "$USER" == "azalea" ]] && prompt-set 30 "🐱 "
# Directory
prompt-set 40 "&r%~ "
# New line after the prompt header
+47 -147
View File
@@ -72,19 +72,12 @@ alias dusa='du -hc --max-depth=1 | sortsize'
alias ts='tailscale'
alias ts-install='curl -fsSL https://tailscale.com/install.sh | sh'
if command -v 'docker-compose' &> /dev/null; then
alias dc='docker-compose'
else
alias dc='docker compose'
fi
alias vsucode='sudo code --user-data-dir /root/.config/vscode --no-sandbox'
alias visucode='EDITOR="code --wait" sudoedit'
alias gpu-temp='while sleep 1; do clear; gpustat; done'
alias cpu-temp='s-tui'
alias mine='sudo lolminer --algo ETHASH --pool stratum+ssl://daggerhashimoto.auto.nicehash.com:443 --user=3AcCeSHHwWJRf945iKCbxZ8cjUvy7Tmg3g.Daisy-lol'
alias mine-zel='sudo lolminer --algo ZEL --pers BgoldPoW --pool stratum+tcp://zelhash.auto.nicehash.com:9200 --user=3AcCeSHHwWJRf945iKCbxZ8cjUvy7Tmg3g.Daisy-lol'
alias mount-external='sudo mount -t cifs //192.168.2.1/external /smb/external -o rw,user=azalea,uid=1000,gid=1000,pass='
alias compress-json="find -name '*.json' -print0 | parallel --jobs 80% -0 zstd -z -19 -v -f --rm {}"
alias ds-clean="find . -name '.DS_Store' -delete -print"
alias dotclean="find . -name '._*' -delete -print"
@@ -100,15 +93,32 @@ alias old-update-ssh-keys="curl -L https://github.com/Hykilpikonna.keys > ~/.ssh
alias tar-kill-progress="watch -n 60 killall tar -SIGUSR1"
alias valgrin="valgrind \
--leak-check=full \
--show-leak-kinds=all \
--leak-resolution=med \
--track-origins=yes \
--vgdb=no"
upload-daisy() {
file="$@"
curl -u azalea -F "path=@$file" "https://daisy-ddns.hydev.org/upload\?path\=/"
}
# Automatic sudo
alias sctl="sudo systemctl"
alias jctl="sudo journalctl"
alias ufw="sudo ufw"
alias nginx="sudo nginx"
# Gradle with auto environment detection
GRADLE="$(which gradle)"
[[ -z $GRADLE ]] && GRADLE="$(which gradle)"
gradle() {
[[ -f "./gradlew" ]] && ./gradlew "$@" || $GRADLE "$@"
if [[ -f "./gradlew" ]]; then
./gradlew "$@"
else
$GRADLE "$@"
fi
}
# Unix permissions reset (Dangerous! This will make executable files no longer executable)
@@ -117,45 +127,12 @@ reset-permissions-dangerous() {
sudo find . -type f -exec chmod 644 {} \;
}
# Mamba (conda replacement)
alias mamba="micromamba"
alias mamba-install="curl micro.mamba.pm/install.sh | zsh"
export MAMBA_ROOT_PREFIX="$HOME/.conda"
# Mamba initialize function
mamba-init()
{
export MAMBA_EXE="$(which micromamba)";
__mamba_setup="$("$MAMBA_EXE" shell hook --shell zsh --prefix "$HOME/micromamba" 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__mamba_setup"
else
if [ -f "$MAMBA_ROOT_PREFIX/etc/profile.d/micromamba.sh" ]; then
. "$MAMBA_ROOT_PREFIX/etc/profile.d/micromamba.sh"
else
export PATH="$MAMBA_ROOT_PREFIX/bin:$PATH"
fi
fi
unset __mamba_setup
}
# Auto init mamba
if command -v 'micromamba' &> /dev/null; then
mamba-init
fi
# Pyenv
if command -v 'pyenv' &> /dev/null; then
eval "$(pyenv init -)"
PATH=$(pyenv root)/shims:$PATH
fi
export PATH="$SCR/bin:$PATH"
export PATH="$HOME/.local/bin:$PATH"
# Lisp wrapper
lisp() {
ros run --load $1 --quit
ros run --load "$1" --quit
}
test-nf() {
@@ -164,13 +141,13 @@ test-nf() {
# Remote adb
adblan() {
adb connect $1:16523
adb connect "$1:16523"
}
alias adblan-start="adb tcpip 16523"
# Add line if it doesn't exist in a file
addline() {
grep -qxF "$2" "$1" || echo "$2" >> $1
grep -qxF "$2" "$1" || echo "$2" >> "$1"
}
# Silent pushd and popd
@@ -183,33 +160,33 @@ spopd () {
# Minecraft coloring
color() {
tmp="$@"
tmp="$tmp&r"
tmp=$(echo "${tmp//&0/\033[0;30m}")
tmp=$(echo "${tmp//&1/\033[0;34m}")
tmp=$(echo "${tmp//&2/\033[0;32m}")
tmp=$(echo "${tmp//&3/\033[0;36m}")
tmp=$(echo "${tmp//&4/\033[0;31m}")
tmp=$(echo "${tmp//&5/\033[0;35m}")
tmp=$(echo "${tmp//&6/\033[0;33m}")
tmp=$(echo "${tmp//&7/\033[0;37m}")
tmp=$(echo "${tmp//&8/\033[1;30m}")
tmp=$(echo "${tmp//&9/\033[1;34m}")
tmp=$(echo "${tmp//&a/\033[1;32m}")
tmp=$(echo "${tmp//&b/\033[1;36m}")
tmp=$(echo "${tmp//&c/\033[1;31m}")
tmp=$(echo "${tmp//&d/\033[1;35m}")
tmp=$(echo "${tmp//&e/\033[1;33m}")
tmp=$(echo "${tmp//&f/\033[1;37m}")
tmp=$(echo "${tmp//&r/\033[0m}")
tmp="$*&r"
tmp="${tmp//&0/\033[0;30m}"
tmp="${tmp//&1/\033[0;34m}"
tmp="${tmp//&2/\033[0;32m}"
tmp="${tmp//&3/\033[0;36m}"
tmp="${tmp//&4/\033[0;31m}"
tmp="${tmp//&5/\033[0;35m}"
tmp="${tmp//&6/\033[0;33m}"
tmp="${tmp//&7/\033[0;37m}"
tmp="${tmp//&8/\033[1;30m}"
tmp="${tmp//&9/\033[1;34m}"
tmp="${tmp//&a/\033[1;32m}"
tmp="${tmp//&b/\033[1;36m}"
tmp="${tmp//&c/\033[1;31m}"
tmp="${tmp//&d/\033[1;35m}"
tmp="${tmp//&e/\033[1;33m}"
tmp="${tmp//&f/\033[1;37m}"
tmp="${tmp//&r/\033[0m}"
newline=$'\n'
tmp=$(echo "${tmp//&n/$newline}")
echo $tmp
tmp="${tmp//&n/$newline}"
echo "$tmp"
}
alias colors="color '&000&111&222&333&444&555&666&777&888&999&aaa&bbb&ccc&ddd&eee&fff'"
# Includes
for f in $SCR/includes/*; do source $f; done
for f in "$SCR/includes/"*.*sh; do source "$f"; done
for f in "$SCR/includes/later/"*.*sh; do source "$f"; done
# Set proxy
setproxy() {
@@ -225,55 +202,8 @@ setproxy() {
prompt-update
}
# Git identity
git-ida() {
# Zsh only
TMP_ARR=("${(@f)$(git-id-list get "$1")}")
git-id "${TMP_ARR[1]}" "${TMP_ARR[2]}"
}
git-id() {
export GIT_USER="$1"
export GIT_EMAIL="$2"
git-id-prompt
}
git-id-prompt() {
if [[ -z "$GIT_USER" ]] && [[ -z "$GIT_EMAIL" ]]; then
prompt-reset
else
prompt-set 30 "&cGit ID: $GIT_USER | $GIT_EMAIL "
prompt-update
fi
}
git-id-prompt
GIT_BIN=$(which git)
git() {
if [[ -z "$GIT_USER" ]]; then
$GIT_BIN "$@"
else
$GIT_BIN -c "user.name=$GIT_USER" -c "user.email=$GIT_EMAIL" -c "commit.gpgsign=false" "$@"
fi
}
# Git environment
git-env() {
git_commands=( add bisect branch checkout clone commit diff fetch grep init log merge pull push rebase reset restore show status tag )
for i in "${git_commands[@]}"
do
alias "$i"="git $i"
done
alias 'grm'='git rm'
alias 'gmv'='git mv'
}
git-unenv() {
git_commands=( add bisect branch checkout clone commit diff fetch grep init log merge pull push rebase reset restore show status tag grm gmv )
for i in "${git_commands[@]}"
do
unalias "$i"
done
}
# SSH Patch
SSH_BIN=$(which ssh)
[[ -z $SSH_BIN ]] && SSH_BIN=$(which ssh)
ssh() {
if [[ "$TERM" == 'xterm-kitty' ]]; then
env TERM=xterm-256color "$SSH_BIN" "$@"
@@ -282,35 +212,5 @@ ssh() {
fi
}
# Mac hostname
mac-hostname() {
name="$@"
sudo scutil --set HostName "$name"
sudo scutil --set LocalHostName "$name"
sudo scutil --set ComputerName "$name"
}
# Cut videos - cut <file name> <end time> [start time (default 00:00:00)]
cut() {
if [ "$#" -lt 2 ]; then
echo "Usage: cut <file name> <end time (hh:mm:ss)> [start time (00:00:00)]"
return 2
fi
local start="${3:-00:00:00}"
echo "$1"
echo "$2"
echo "$start"
ffmpeg -i "$1" -codec copy -ss "$start" -t "$2" Cut\ "$1"
}
alias vcomp="$BASEDIR/scripts/helpers/video.py"
alias vcompy="ipython -i $BASEDIR/scripts/helpers/video.py"
flac2mp3() {
for file in *.flac; do
ffmpeg -i "$file" -ab 320k -map_metadata 0 -id3v2_version 3 "${file%.flac}.mp3"
done
}
# include if it exists
[ -f "$HOME/extra.rc.sh" ] && . "$HOME/extra.rc.sh"
[ -f "$HOME/extra.rc.sh" ] && source "$HOME/extra.rc.sh"