######################## # 1. History & basics # ######################## HISTFILE=~/.zsh_history HISTSIZE=5000 SAVEHIST=5000 setopt HIST_IGNORE_DUPS SHARE_HISTORY export PYENV_ROOT="$HOME/.pyenv" command -v pyenv >/dev/null && eval "$(pyenv init - zsh)" export PATH="$HOME/tools:$PATH" ######################## # 2. GPU defaults # ######################## # Both GPUs visible; apps can pick cuda:0 or cuda:1 export CUDA_VISIBLE_DEVICES=0,1 ######################## # 3. Prompt & completion ######################## autoload -Uz colors && colors PROMPT='%* %F{cyan}%n@%m%f %F{yellow}%~%f %# ' autoload -Uz compinit compinit if [[ -o interactive ]]; then fi # Give Ghostty a real moment to handshake with the GPU ######################## # 4. Package manager aliases ######################## detect_pm() { if command -v pacman >/dev/null 2>&1; then echo pacman elif command -v dnf >/dev/null 2>&1; then echo dnf elif command -v apt >/dev/null 2>&1; then echo apt fi } PM="$(detect_pm)" if [ "$PM" = "pacman" ]; then alias u-all='sudo pacman -Syu' alias pkg-install='sudo pacman -S' alias pkg-remove='sudo pacman -Rns' alias u-grub='sudo grub-mkconfig -o /boot/grub/grub.cfg' elif [ "$PM" = "dnf" ]; then alias u-all='sudo dnf upgrade --refresh' alias pkg-install='sudo dnf install' alias pkg-remove='sudo dnf remove' elif [ "$PM" = "apt" ]; then alias u-all='sudo apt update && sudo apt full-upgrade' alias pkg-install='sudo apt install' alias pkg-remove='sudo apt purge' fi if command -v flatpak >/dev/null 2>&1; then alias u-flatpak='flatpak update' fi if command -v dracut >/dev/null 2>&1; then alias u-initramfs='sudo dracut --regenerate-all --force' elif command -v mkinitcpio >/dev/null 2>&1; then alias u-initramfs='sudo mkinitcpio -P' fi ######################## # 5. Generic aliases # ######################## alias ls='ls --color=auto' alias ll='ls -lah' alias la='ls -A' alias ..='cd ..' alias ...='cd ../..' alias c='clear' alias watchsmi='watch -n 1 nvidia-smi' alias jctl='journalctl -xe' alias sctl='sudo systemctl' alias reload-shell='source ~/.zshrc' alias garuda-deep='garuda-update && sudo grub-mkconfig -o /boot/grub/grub.cfg' alias dragon-cool='sudo DISPLAY=:0 nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan:0]/GPUTargetFanSpeed=80"' #alias zing='chromium --user-data-dir="/mnt/ram_vault/zing_temp" --incognito --app="https://zingmp3.vn"' alias zing='export CUDA_VISIBLE_DEVICES=1 && chromium --user-data-dir="/mnt/ram_vault/temp_zing" --incognito --app="https://zingmp3.vn"' ######################## # 5b. Load Vault and Bind # ######################## #unalias load-vault 2>/dev/null #alias load-ram='echo "🚀 [LOAD] Preparing 250G RAM Worklab..." && \ #sudo rsync -au --info=progress2 /media/veracrypt1/Ram_data_dump/ /mnt/ram_vault/ && \ #sudo chown -R z5n:z5n /mnt/ram_vault/ && \ #echo "🔗 [BIND] Flipping System to RAM Mode..." && \ #sudo mount --bind /mnt/ram_vault/system_tmp /tmp && \ #sudo mount --bind /mnt/ram_vault/pkg_cache /var/cache/pacman/pkg && \ #sudo chmod 1777 /tmp && \ #notify-send "Worklab Active" "Global tasks are now processing in LZ4 RAM."' alias load-vault='sudo rsync -au --info=progress2 /media/veracrypt1/Ram_data_dump/ /mnt/ram_vault/ && sudo chown -R z5n:z5n /mnt/ram_vault/' # Global System Temp: Points system tasks to RAM without breaking the boot export TMPDIR="/mnt/ram_vault/system_tmp" export TEMP="/mnt/ram_vault/system_tmp" ######################## # 6. Snapshot helpers # ######################## unalias find_snaps 2>/dev/null find_snaps() { echo "=== All folders on all mounts with Timeshift-style date names ===" echo name_regex='^[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}_[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}$' awk '{print $2}' /proc/mounts | while read -r mountpoint; do case "$mountpoint" in /proc|/sys|/dev|/run|/tmp|/var/run) continue ;; esac [ -d "$mountpoint" ] || continue while IFS= read -r d; do [ -z "$d" ] && continue base=$(basename "$d") if printf '%s\n' "$base" | grep -qE "$name_regex"; then echo "$d" fi done < <(find "$mountpoint" -maxdepth 8 -type d 2>/dev/null) done } unalias snapall 2>/dev/null snapall() { sudo snapper -c root create -d "$1" sudo snapper -c home create -d "$1" } alias ts_snaps='find_snaps' ######################## # 7. Studio / lab aliases ######################## alias comfy='sudo nvidia-smi -pl 200 && cd /mnt/ram_vault/ComfyUI && source .venv/bin/activate && brave --app=http://127.0.0.1:8188 & python main.py --highvram --force-fp32 --fp32-vae --use-split-cross-attention' alias fftool='zsh ~/fftool_project/scripts/fftool.sh' alias nvme-watch='iostat -dxm 1 nvme0n1 | awk '\''$1=="nvme0n1" {printf "nvme0n1 R=%6s MB/s W=%6s MB/s util=%5s%%\n", $6, $7, $12; fflush(stdout)}'\''' alias thanos='cd /mnt/ram_vault/Thanos && source .venv/bin/activate 2>/dev/null || true && zsh' alias faceswap='cd /mnt/ram_vault/Faceswap && source .venv/bin/activate 2>/dev/null || true && python faceswap.py gui' alias diffusion='cd /mnt/ram_vault/Diffusion && source .venv/bin/activate 2>/dev/null || true && python launch.py' alias bye="~/bye.sh" alias new-mv="zsh /mnt/ram_vault/Hacker_Studio/scripts/new_mv.zsh" alias sync-lrc="zsh /mnt/ram_vault/Hacker_Studio/scripts/sync_lrc.zsh" alias burn-mv='zsh /mnt/ram_vault/Hacker_Studio/scripts/render_mv.zsh' alias burn-karaoke='zsh /mnt/ram_vault/Hacker_Studio/scripts/render_karaoke.zsh' alias new-chord-session='zsh ~/Desktop/Chords_Lab/scripts/new_chord_session.zsh' alias analyze-chords='zsh ~/Desktop/Chords_Lab/scripts/analyze_chords.zsh' alias open-chords='zsh ~/Desktop/Chords_Lab/scripts/open_chords.zsh' alias dump='~/vault-dump.sh' #alias search-up="cd /mnt/ram_vault/whoogle-search && ./venv/bin/python3 -m app --host 127.0.0.1 --port 5000" alias search-wh="export WHOOGLE_DOTENV=1 && cd /mnt/ram_vault/whoogle-search && ./venv/bin/python3 -m app --host 127.0.0.1 --port 5000" ######################## # 8. Global Muscle func ######################## alias m='z_global_muscle' z_global_muscle() { local song=$1 local target="/mnt/ram_vault/Hacker_Studio/Projects/$song/Work_lab" [[ -z "$song" ]] && { echo "❌ Usage: m SongName"; return 1; } [[ ! -d "$target" ]] && { echo "❌ Folder not found: $target"; return 1; } cd "$target" echo "🐉 Dragonized Muscle: $song (Cleaning Metadata & Fixing Clipping)" local v_p=$(find . -maxdepth 1 -iname "*vocal*" -type f | head -n 1) local b_p=$(find . -maxdepth 1 -iname "*bass*" -type f | head -n 1) local d_p=$(find . -maxdepth 1 -iname "*drum*" -type f | head -n 1) local o_p=$(find . -maxdepth 1 -iname "*other*" -type f | head -n 1) [[ -z "$v_p" || -z "$b_p" || -z "$d_p" || -z "$o_p" ]] && { echo "❌ Missing stems!"; return 1; } sox "$b_p" "b_tmp.wav" bass +12 60 0.5 compand 0.05,0.2 6:-70,-60,-20 -4 -90 0.1 gain -3 sox "$d_p" "d_tmp.wav" treble +4 5k 0.5q compand 0.01,0.1 -60,-60,-10 -2 -90 0.1 gain -3 ffmpeg -hwaccel cuda -hwaccel_output_format cuda -hide_banner -loglevel error -y \ -i "$v_p" -i "d_tmp.wav" -i "b_tmp.wav" -i "$o_p" \ -filter_complex "[0:a][1:a][2:a][3:a]amix=inputs=4:duration=longest[out];[out]aecho=0.8:0.88:6:0.3[final]" \ -map "[final]" -c:a pcm_s16le -ar 48000 "../audio_master/FINAL_DRAGON_MIX.wav" rm b_tmp.wav d_tmp.wav echo "✅ DONE: ../audio_master/FINAL_DRAGON_MIX.wav (Clean Metadata)" mpv "../audio_master/FINAL_DRAGON_MIX.wav" --no-video } ######################## # 9. Demucs function # ######################## unalias demucs 2>/dev/null demucs() { local current_p=$(pwd) cd ~/Demucs && source venv/bin/activate export LD_LIBRARY_PATH=$VIRTUAL_ENV/lib/python3.12/site-packages/nvidia/cudnn/lib:$LD_LIBRARY_PATH export TORCH_CUDNN_V8_API_ENABLED=0 python -m demucs.separate -d cuda:0 -n htdemucs "$@" deactivate cd "$current_p" } ######################## # 11. Terminal Synergy # ######################## # 1. DO THIS FIRST: Tell Ghostty to wake up and talk to Zsh if [[ -n "$GHOSTTY_RESOURCES_DIR" ]]; then source "$GHOSTTY_RESOURCES_DIR/shell-integration/zsh/ghostty-integration" fi # 2. WezTerm detection (Keep it if you use it, otherwise fine) if [[ -n "$WEZTERM_PANE" ]]; then alias split-v='wezterm cli split-pane --right' alias split-h='wezterm cli split-pane --bottom' fi ############################################################## # Zsan's Global HPC Content Cleaner (VeraCrypt Library Edition) ############################################################## # Zsan's Direct P40 RAM-Master (Manual Alias) alias remaster-ram='f() { ffmpeg -y -hwaccel cuda -hwaccel_device 1 -i "$1" -vf "hflip,scale=4000:2250:force_original_aspect_ratio=increase,crop=3840:2160,eq=contrast=1.1:saturation=1.1" -c:v h264_nvenc -gpu 1 -preset slow -tune hq -rc constqp -qp 18 -pix_fmt yuv420p -map_metadata -1 -fflags +bitexact -an "/mnt/ram_vault/Remastered_out/unique_$(basename ${1%.*}).mp4"; }; f' # Zsan's Multi-File RAM Master (Smart Batch) remaster-all() { local OUT_DIR="/mnt/ram_vault/Remastered_out" [[ ! -d "$OUT_DIR" ]] && mkdir -p "$OUT_DIR" # If no files are provided, grab all .mp4 files in the current dir local files=("$@") if [ ${#files[@]} -eq 0 ]; then files=(*.mp4) fi # Check if there are actually any .mp4 files to process if [ ! -e "${files[1]}" ]; then echo "❌ No .mp4 files found in this directory." return 1 fi for input in "${files[@]}"; do local filename=$(basename -- "$input") local output="$OUT_DIR/unique_${filename%.*}.mp4" echo "🐉 P40 Batch Washing: $filename" ffmpeg -y -hwaccel cuda -hwaccel_device 1 -i "$input" \ -vf "hflip,scale=4000:2250:force_original_aspect_ratio=increase,crop=3840:2160,eq=contrast=1.1:saturation=1.1" \ -c:v h264_nvenc -gpu 1 -preset slow -tune hq \ -rc constqp -qp 18 -pix_fmt yuv420p \ -map_metadata -1 -fflags +bitexact -an \ "$output" done echo "✅ Success! All files are now in $OUT_DIR" } ######################## # 13. Plugins (THE END) # ######################## # 3. DO THIS LAST: These must be the final lines to ensure colors work source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh # ... existing stuff above ... export PYTHONUNBUFFERED=1 # THIS IS THE "HERE" - THE VERY LAST LINE: sleep 0.4 && clear && fastfetch