diff --git a/scripts/.gitignore b/.gitignore
similarity index 100%
rename from scripts/.gitignore
rename to .gitignore
diff --git a/README.md b/README.md
index c137cb1..01dc81a 100644
--- a/README.md
+++ b/README.md
@@ -5,3 +5,8 @@ My zshrc
```sh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Hykilpikonna/zshrc/HEAD/fastinstall.sh)"
```
+
+## Ubuntu fast setup
+```sh
+/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Hykilpikonna/zshrc/HEAD/ubuntu_setup.sh)"
+```
diff --git a/brew-services/homebrew.mxcl.frpc.plist b/brew-services/homebrew.mxcl.frpc.plist
new file mode 100644
index 0000000..9756a78
--- /dev/null
+++ b/brew-services/homebrew.mxcl.frpc.plist
@@ -0,0 +1,22 @@
+
+
+
+
+ KeepAlive
+
+ Label
+ homebrew.mxcl.frpc
+ ProgramArguments
+
+ /usr/local/opt/frpc/bin/frpc
+ -c
+ /usr/local/etc/frp/frpc.ini
+
+ RunAtLoad
+
+ StandardErrorPath
+ /usr/local/var/log/frpc.log
+ StandardOutPath
+ /usr/local/var/log/frpc.log
+
+
diff --git a/brew-services/homebrew.mxcl.menu-bot.plist b/brew-services/homebrew.mxcl.menu-bot.plist
new file mode 100644
index 0000000..8bbeef3
--- /dev/null
+++ b/brew-services/homebrew.mxcl.menu-bot.plist
@@ -0,0 +1,21 @@
+
+
+
+
+ KeepAlive
+
+ Label
+ homebrew.mxcl.menu-bot
+ ProgramArguments
+
+ /usr/bin/python3
+ /Volumes/macWorkspace/CS/CSC110/menubot/menubot.py
+
+ RunAtLoad
+
+ StandardErrorPath
+ /usr/local/var/log/menubot.log
+ StandardOutPath
+ /usr/local/var/log/menubot.log
+
+
\ No newline at end of file
diff --git a/fastinstall.sh b/fastinstall.sh
index b08a6d6..da998ed 100644
--- a/fastinstall.sh
+++ b/fastinstall.sh
@@ -20,8 +20,10 @@ addline .zshrc 'SCR="$HOME/zshrc/scripts"'
addline .zshrc '. $SCR/zshrc.sh'
# Initialize submodules
+pushd zshrc
git submodule init
git submodule update
+popd
# Return to the previous directory
popd
diff --git a/scripts/helpers/prompt.py b/scripts/helpers/prompt.py
index 3bedb53..f04b3e5 100755
--- a/scripts/helpers/prompt.py
+++ b/scripts/helpers/prompt.py
@@ -1,14 +1,33 @@
#!/usr/bin/env python3
+from __future__ import annotations
import json
import sys
-import time
-from typing import Tuple, List
+
+
+def ansirgb(r: int, g: int, b: int, foreground: bool = True) -> str:
+ c = '38' if foreground else '48'
+ return f'\033[{c};2;{r};{g};{b}m'
def replace_color(msg: str) -> str:
replacements = ["&0/\033[0;30m", "&1/\033[0;34m", "&2/\033[0;32m", "&3/\033[0;36m", "&4/\033[0;31m", "&5/\033[0;35m", "&6/\033[0;33m", "&7/\033[0;37m", "&8/\033[1;30m", "&9/\033[1;34m", "&a/\033[1;32m", "&b/\033[1;36m", "&c/\033[1;31m", "&d/\033[1;35m", "&e/\033[1;33m", "&f/\033[1;37m", "&r/\033[0m", "&n/\n"]
for r in replacements:
msg = msg.replace(r[:2], r[3:])
+
+ while '&gf(' in msg or '&gb(' in msg:
+ i = msg.index('&gf(') if '&gf(' in msg else msg.index('&gb(')
+ end = msg.index(')', i)
+ code = msg[i + 4:end]
+ fore = msg[i + 2] == 'f'
+
+ if code.startswith('#'):
+ rgb = tuple(int(code.lstrip('#')[i:i+2], 16) for i in (0, 2, 4))
+ else:
+ code = code.replace(',', ' ').replace(';', ' ').replace(' ', ' ')
+ rgb = tuple(int(c) for c in code.split(' '))
+
+ msg = msg[:i] + ansirgb(*rgb, foreground=fore) + msg[end + 1:]
+
return msg
@@ -28,13 +47,17 @@ def set():
if __name__ == '__main__':
- start_time = time.time()
-
+ # start_time = time.time()
args = sys.argv[1:]
parts_raw = args.pop(0)
- parts: List[Tuple[int, str]] = json.loads(parts_raw) if parts_raw != '' else []
cmd = args.pop(0).lower()
+ if cmd == 'color':
+ print(replace_color(parts_raw))
+ exit()
+
+ parts: list[tuple[int, str]] = json.loads(parts_raw) if parts_raw != '' else []
+
if cmd == 'show':
show()
elif cmd == 'debug':
diff --git a/scripts/helpers/video.py b/scripts/helpers/video.py
new file mode 100755
index 0000000..9f167db
--- /dev/null
+++ b/scripts/helpers/video.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python3
+import os
+import sys
+from datetime import datetime
+
+
+def comp(input: str = 'latest', proc: str = 'cpu', codec: str = 'x264', crf: int = 24, br: int = 500,
+ cmd: bool = False, aargs: str = '', suffix: str = 'mp4'):
+ """
+ Compress video
+
+ :param input: Input file (Default: latest)
+ :param proc: cpu (c) or gpu (g)
+ :param codec: x264 (4) or x265 (5)
+ :param crf: CRF (quality) for cpu encoding
+ :param cmd: Whether to output command directly
+ :param aargs: Additional args
+ :param suffix: File suffix (Default mp4)
+ :return:
+ """
+ if input == 'latest':
+ rename()
+ i = sorted([s for s in os.listdir('.') if s.startswith('Rec') and s.endswith('mov')])[-1]
+ else:
+ i = input
+
+ proc = proc[0]
+ codec = {'4': {'c': 'x264', 'g': 'h264'}, '5': {'c': 'x265', 'g': 'hevc'}}[codec[-1]][proc]
+
+ out = i[:i.rindex('.')] + f'.{codec}'
+ if proc == 'c':
+ out += f'-{crf}'
+ out += f'.{suffix}'
+
+ if proc == 'c':
+ c = f'ffmpeg -i "{i}" -vcodec lib{codec} -crf {crf} {aargs} "{out}"'
+ elif proc == 'g':
+ c = f'ffmpeg -i "{i}" -c:v {codec}_videotoolbox -b:v {br}k {aargs} "{out}"'
+ else:
+ raise AssertionError(f'Processor is invalid ({codec}[0] not in "cg")')
+
+ if cmd:
+ print(c)
+ else:
+ os.system(c)
+
+
+def rename():
+ for file in os.listdir('.'):
+ if file.startswith('Screen Recording ') or file.startswith('Screen Shot '):
+ pre = 'Rec' if 'Recording' in file else 'Shot'
+ end_index = (file.index('AM') if 'AM' in file else file.index('PM')) + 2
+ datestr = file[17 if pre == 'Rec' else 12:end_index]
+ dt = datetime.strptime(datestr, '%Y-%m-%d at %I.%M.%S %p')
+ date = dt.strftime(f'{pre} %Y-%m-%d %H-%M' + file[end_index:])
+
+ print(f'Renaming {file} to {date}')
+ os.rename(file, date)
+
+
+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:])))
diff --git a/scripts/includes/application.sh b/scripts/includes/application.sh
index f6e99e7..c88e7c9 100644
--- a/scripts/includes/application.sh
+++ b/scripts/includes/application.sh
@@ -3,3 +3,6 @@
alias va-restart='sctl restart va'
alias va-log-all='jctl -u va --output cat'
alias va-log='va-log-all -f'
+
+# General
+alias jctlog='jctl --output cat -f -u'
\ No newline at end of file
diff --git a/scripts/includes/home-mac.sh b/scripts/includes/home-mac.sh
index 6da5cfe..5b3fb79 100644
--- a/scripts/includes/home-mac.sh
+++ b/scripts/includes/home-mac.sh
@@ -2,10 +2,9 @@
if [[ $OSTYPE == 'darwin'* ]] && [ -d "/Volumes/External" ]; then
# Minecraft
export MC_DIR="/Volumes/External/Minecraft"
- alias minecraft="pushd $MC_DIR; java8 -jar $MC_DIR/HMCL-*.jar; popd"
+ alias minecraft="pushd $MC_DIR; java17 -jar $MC_DIR/HMCL-*.jar; popd"
# Paths
- export PATH="$PATH:/Users/hykilpikonna/.pyenv/versions/3.8.0/bin"
export DOTNET_ROOT="/usr/local/opt/dotnet/libexec"
# export PATH="/Volumes/MacData/SageMath:$PATH"
export PATH="$PATH:/Users/hykilpikonna/.gem/ruby/2.6.0/bin" # https://stackoverflow.com/a/53388305/7346633
@@ -14,4 +13,10 @@ if [[ $OSTYPE == 'darwin'* ]] && [ -d "/Volumes/External" ]; then
export PATH="${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"
export NDK_HOME="/Volumes/MacData/Resources/android-ndk-r21d"
export NDK_ROOT=$NDK_HOME
+ export PATH="/usr/local/opt/node@14/bin:$PATH"
+
+ # Use Python3.9 by default
+ export PATH="/usr/local/opt/python@3.8/bin:$PATH"
+ export PATH="/usr/local/opt/python@3.10/bin:$PATH"
+ export PATH="/usr/local/opt/python@3.9/bin:$PATH"
fi
diff --git a/scripts/includes/mac.sh b/scripts/includes/mac.sh
index 1af2966..758c9e6 100644
--- a/scripts/includes/mac.sh
+++ b/scripts/includes/mac.sh
@@ -4,8 +4,11 @@ if [[ $OSTYPE == 'darwin'* ]]; then
alias ports="netstat -ap tcp | grep -i \"listen\""
alias ports2="sudo lsof -i -P | grep LISTEN"
alias trash="rmtrash"
+
alias checkrain="/Applications/checkra1n.app/Contents/MacOS/checkra1n"
alias obs="open -n -a OBS.app"
+ alias idea="open -a Intellij\ IDEA.app"
+ alias xcode="open -a Xcode.app"
# Java
export JDK8="/usr/local/opt/openjdk@8/libexec/openjdk.jdk/Contents/Home"
diff --git a/scripts/includes/prompt.sh b/scripts/includes/prompt.sh
index a8b7477..4fa1e4d 100755
--- a/scripts/includes/prompt.sh
+++ b/scripts/includes/prompt.sh
@@ -13,14 +13,20 @@ prompt-set() {
prompt-update() {
PROMPT=$(prompt-show)
}
+pcolor() {
+ tmp="$@"
+ prompt "$tmp" color
+}
########### Build a zsh prompt
# 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 "
# 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 "
# Username, or show a cat if I'm hykilpikonna
prompt-set 30 "&e%n&r "
[[ "$USER" == "hykilpikonna" ]] && prompt-set 30 "🐱 "
diff --git a/scripts/zshrc.sh b/scripts/zshrc.sh
index f7bea75..90e8afa 100755
--- a/scripts/zshrc.sh
+++ b/scripts/zshrc.sh
@@ -118,6 +118,8 @@ cut() {
echo $start
ffmpeg -i $1 -codec copy -ss $start -t $2 Cut\ $1
}
+alias vcomp="$SCR/helpers/video.py"
+alias vcompy="ipython -i $SCR/helpers/video.py"
# include if it exists
[ -f $HOME/extra.rc.sh ] && . $HOME/extra.rc.sh
diff --git a/ubuntu_setup.sh b/ubuntu_setup.sh
new file mode 100644
index 0000000..edb78f1
--- /dev/null
+++ b/ubuntu_setup.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+# Automatically setup ubuntu
+
+# Install essential packages
+apt update
+apt install curl git net-tools -y
+
+# Add ssh keys
+mkdir ~/.ssh
+curl -L https://github.com/Hykilpikonna.keys > ~/.ssh/authorized_keys
+
+# Install zsh
+apt install zsh -y
+chsh -s /bin/zsh
+
+# Install zshrc
+/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Hykilpikonna/zshrc/HEAD/fastinstall.sh)"
+
+# Install shadowsocks
+apt install shadowsocks-libev -y
+git clone https://github.com/hykilpikonna/HyDEV-Proxy
+mkdir /etc/shadowsocks-libev
+cp -f ./HyDEV-Proxy/ss-server.json /etc/shadowsocks-libev/hydev.json
+systemctl stop shadowsocks-libev
+systemctl disable shadowsocks-libev
+systemctl start shadowsocks-libev-server@hydev.service
+systemctl enable shadowsocks-libev-server@hydev.service