Last active 3 weeks ago

Revision 2f5db39656c0e55244b11b150e11abdd5197fef9

backup.sh Raw
1#!/bin/bash
2
3# Color Utilities
4function green() { printf "\033[32m%s\033[0m\n\n" "$1"; }
5function orange() { printf "\033[38;5;208m%s\033[0m\n" "$1"; }
6function red() { printf "\033[91m%s\033[0m\n" "$1"; }
7function blue() { printf "\033[38;5;27m%s\033[0m\n" "$1"; }
8
9# Constants
10BACKUP_DIR="$HOME/backups"
11FILENAME="$BACKUP_DIR/$(date +%d_%m_%Y).tar"
12
13# Create backup directory if it doesn't exist
14function ensure_backup_dir() {
15 if [[ ! -e "$BACKUP_DIR" ]]; then
16 blue "Creating backup directory."
17 mkdir -p "$BACKUP_DIR"
18 fi
19}
20
21# Handle existing backup file
22function check_existing_backup() {
23 if [[ -f "$FILENAME" ]]; then
24 orange "$FILENAME already exists!"
25 read -rp "Do you want to remove the existing backup file? (y/n) : " answer
26 [[ $answer == 'y' ]] && rm "$FILENAME" || exit 1
27 fi
28}
29
30# Brew
31function generate_config_files() {
32 green "Preparing brew ..."
33 local brew_file="$HOME/Brewfile"
34 brew bundle dump --force --no-go --no-cargo --no-uv --no-npm --file="$brew_file"
35
36 tar -rpf "$FILENAME" "$brew_file"
37}
38
39# Backup dotfiles
40function backup_dotfiles() {
41 green "Backing up dotfiles..."
42 find "$HOME"/.* -maxdepth 0 -type f \
43 -not -name ".claude.json" \
44 -not -name ".CFUserTextEncoding" \
45 -not -name ".DS_Store" \
46 -exec tar -rpf "$FILENAME" {} +
47}
48
49# Exclude large config dirs and create gzipped archive of .config
50function backup_config_gz() {
51 tar -rpf "$FILENAME" "$HOME/.config/git"
52 tar -rpf "$FILENAME" "$HOME/.config/rclone/*.conf"
53 tar -rpf "$FILENAME" "$HOME/.config/telebit"
54 tar -rpf "$FILENAME" "$HOME/.config/omniwm/settings.toml"
55 tar -rpf "$FILENAME" "$HOME/.gnupg/*.gpg"
56 tar -rpf "$FILENAME" "$HOME/.gradle/gradle.properties"
57 tar -rpf "$FILENAME" "$HOME/.claude/settings.json"
58}
59
60# Append selected items to tar archive
61function backup_specific_items() {
62 green "Backing up specific items..."
63 tar -rpf "$FILENAME" --exclude=".git" --exclude="local.zsh" "$HOME/.zsh"
64 tar -rpf "$FILENAME" --exclude="agent" --exclude="known_hosts" "$HOME/.ssh"
65 tar -rpf "$FILENAME" $HOME/Library/LaunchAgents/local.*
66 tar -rpf "$FILENAME" $HOME/Data/launchd/*/*.sh
67 # tar -rpf "$FILENAME" "$HOME/Library/Developer/Xcode/UserData/KeyBindings"
68 tar -rpf "$FILENAME" /etc/hosts /etc/paths
69}
70
71# Append list of backed-up files
72function add_backup_log() {
73 {
74 echo -e "\n\nBackup List:\n"
75 tar -tvf "$FILENAME" | sort -k5 -rn
76 } >backup_log.txt
77 tar -rpf "$FILENAME" backup_log.txt
78 blue backup log
79 cat backup_log.txt
80 rm backup_log.txt
81}
82
83# Validate final backup size
84function validate_backup_size() {
85 local size size_mb
86 size=$(stat -f "%z" "$FILENAME")
87 size_mb=$(echo "scale=2; $size / 1024 / 1024" | bc)
88 blue "$FILENAME has size ${size_mb} MB"
89
90 if [[ $size -gt 24000000 ]]; then
91 red "Backup > 24 MB, aborting."
92 exit 1
93 else
94 green "Done!"
95 fi
96}
97
98# === Main Execution ===
99ensure_backup_dir
100check_existing_backup
101cd "$HOME" || exit 1
102generate_config_files
103backup_dotfiles
104backup_config_gz
105backup_specific_items
106add_backup_log
107validate_backup_size
108
109exit 0
110
111# Restore with:
112# sudo tar -xvf <backup_filename>.tar -C /
113# brew bundle install --file=~/Brewfile
114
brew.sh Raw
1### Input / pointing devices
2brew install mos
3brew install asciinema
4brew install --cask alt-tab
5brew install --cask keycastr
6brew install --cask middleclick
7brew install --cask rectangle
8brew install --cask linearmouse
9
10### macOS / Xcode / iOS tooling
11
12brew install swiftformat
13brew install --cask xcodes
14brew install --cask swiftformat-for-xcode
15brew install fastlane
16brew install carthage
17brew tap robotsandpencils/made && brew install robotsandpencils/made/xcodes
18brew tap majd/repo && brew install ipatool
19brew install mackup # backup app settings
20brew install pngpaste
21
22### Development & VCS
23brew install git
24brew install git-gui
25brew install git-lfs
26git lfs install
27git lfs install --system
28brew install gitui
29brew install git-delta
30brew install gitleaks
31brew install source-highlight
32
33### Languages, formatters & build tools
34brew install php
35brew install rbenv
36brew install rustfmt
37brew install swiftlint
38brew install rustup && rustup-init
39
40### Editors & terminal tools
41brew install micro
42brew install lesspipe
43brew install vhs
44brew install bat
45brew install tree
46
47### Search / find / file utils
48brew install fzf
49brew install ripgrep
50brew install fd
51brew install jq
52brew install yq
53brew install rsync
54brew install grep
55
56### Media & multimedia
57brew install ffmpeg
58brew install imagemagick
59brew install yt-dlp
60brew install pngpaste
61brew install vlc --cask
62
63### Android / reverse-engineering / mobile
64brew install apktool
65brew install jadx
66brew install scrcpy
67curl https://raw.githubusercontent.com/ax/apk.sh/main/apk.sh -o /usr/local/bin/apk.sh && chmod +x /usr/local/bin/apk.sh
68
69### Networking, proxies & transfer
70brew install aria2
71brew install rclone
72brew install ngrok/ngrok/ngrok
73brew install mitmproxy
74brew install --cask localsend
75
76### Productivity & system utilities (GUI)
77brew install --cask maccy
78brew install --cask lunar
79brew install --cask ghostty
80brew install stats
81brew install neofetch
82brew install glances
83brew install lolcat
84
85### Disk
86brew install dua-cli
87curl https://download.nektony.com/download/diskexpert/disk-space-analyzer.dmg -O && open disk-space-analyzer.dmg 2 >/dev/null &>1 &
88
89### Screenshot
90brew install --cask flameshot
91brew install --cask kap
92brew tap duongductrong/snapzy https://github.com/duongductrong/Snapzy && brew install --cask snapzy
93
94### Misc / convenience
95brew install lima
96brew install ipatool
97brew install yt-dlp
98brew install jesseduffield/lazygit/lazygit
99
100### Menu Bars
101brew install --cask hiddenbar
102brew install --cask swiftbar
103brew install --cask steipete/tap/codexbar
104brew install --cask pakerwreah/calendr/calendr
105brew install --cask simsim
106brew install thaw
107
108### Database
109brew install --cask sequel-ace
110
111## Extra
112[vscode xcode] https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line
113[storage] https://nektony.com/disk-expert
114[cliboard] flycut/cutbox
115[editor] textmate coteditor
116[vpn] warp 1.1.1.1
117[player] https://github.com/iina/iina/releases/tag/v1.3.0
118[extension] https://github.com/quoid/userscripts
119[wiget] https://github.com/leits/MeetingBar
120[ci] https://github.com/cirruslabs/tart
121[vm] https://github.com/utmapp/UTM
122[ipa] https://github.com/majd/ipatool
123[xcode] https://github.com/RobotsAndPencils/XcodesApp
124[emulator] https://github.com/PlayCover/PlayCover
125[annotate, cite, and share research] https://www.zotero.org/
126[terminal] https://iterm2.com/downloads.html
127[keyboard] https://github.com/pqrs-org/Karabiner-Elements
128[realm] https://studio-releases.realm.io/latest/download/mac-dmg https://github.com/dsmelov/simsim
129[sketch] https://github.com/duraki/SketchCrapp
130[record] https://github.com/onmyway133/GifCapture/releases/tag/1.1.0
131[note] https://github.com/glushchenko/fsnotes
132[convert video2gif] https://github.com/sindresorhus/Gifski
133[download manager] https://github.com/agalwood/Motrix/releases
134[wallpaper] https://github.com/rlxone/Equinox
135[php] https://github.com/nicoverbruggen/phpmon
136[firmware] https://github.com/ninxsoft/mist-cli
137[xcodeproject] https://github.com/yonaskolb/XcodeGen
138[java] https://www.oracle.com/java/technologies/downloads/#jdk19-mac
139[automation] https://www.hammerspoon.org/go/
140[video] https://github.com/mltframework/shotcut/releases
141[xcode] https://github.com/Serchinastico/Kin
142[database] https://github.com/dbeaver/dbeaver/releases
143[default app] https://www.rubicode.com/Downloads/RCDefaultApp-2.1.X.dmg
144[wasm] https://github.com/WebAssembly/wabt/releases/w
145[launchctl] launchcontrol
146[file-explorer] https://github.com/sayanarijit/xplr/releases | https://github.com/ranger/ranger | https://github.com/kamiyaa/joshuto | nnn | https://github.com/sxyazi/yazi
147[file server] https://github.com/sigoden/dufs # webdav
148[localsend] https://localsend.org/#/download # file sharing, airdrop
149[teamview] https://github.com/rustdesk/rustdesk/releases # teamviewer alternative
150[sql] drawsql.app
151[monitor brightness] https://github.com/alin23/Lunar
152[export photo library ios] https://github.com/RhetTbull/osxphotos
153[music lyric] buzz
154[image compressor, blog] caesium image compressor
155[vpn] tunelblick
156[bloatware] uad-ng-macos
157[window manager] https://github.com/MrKai77/Loop/releases/
158[editor] https://zed.dev/download
159[software] https://github.com/objective-see/KnockKnock
160[server] https://github.com/lollipopkit/flutter_server_box
161[network monitor] https://github.com/GyulyVGC/sniffnet
162[slideshow] https://github.com/gobbledegook/creevey
163[editor]https://github.com/sinelaw/fresh
164[window managers] https://www.raycast.com/ | https://github.com/nikitabobko/AeroSpace
165[video] https://github.com/HandBrake/HandBrake
166
config.md Raw

macos

  • settings -> keyboard shortuts -> services -> disable searching
  • settings -> keyboard shortuts -> mission control -> mission control {swtich to desktop nth}
  • settings -> display -> {reduce motion,increase contrast}
  • settings -> desktop & dock -> Mission control -> {diable rerrangement,separate spaces}
  • settings -> desktop & dock -> Desktop & dock -> {diable animate application,recent apps}
  • sudo mdutil -i off / -> disable spotlight indexing

iterm

  • settings -> profiles -> other actions -> import json as profile
  • Settings -> Advanced -> Scroll wheel sends arrow keys when in alternate screen mode: FALSE
  • Preferences → Profiles → Keys → Keyboard Behavior-> Natural Text Editing

android studio

  • tools -> create commandline launcher
  • logcat -> ⚙️ -> modify views
  • settings -> keymaps -> version control systems -> git -> Annotate = ctl + shf + b
  • build -> build tools -> gradle -> enable parallel gradle model fetching
  • Preferences -> Appearance & Behavior -> System Settings -> max
  • commit -> ⋮ -> configure local change -> staging area
  • commit -> 👁️ -> group by directory

firefox

  • about:preferences#privacy -> Firefox Data Collection and Use -> disable
  • about:preferences#privacy -> Custom history -> Uncheck all

mate

  • view -> show file browser -> project folder -> (dropdown) use * as project folder
  • settings -> terminal -> shell support insatll

vscode

  • settings gui -> "search: exclude" -> add "**/*lock.yaml"
  • > Install 'code' command in PATH" command

zed

  • /> cli: install cli binary

dbeaver

  • window -> show view -> query manager

tailscale

https://login.tailscale.com/admin/machines -> Disable key expiry (trusted server)

install.sh Raw
1## colors
2red() { printf "\033[31m${1}\033[0m\n\n"; }
3green() { printf "\033[32m${1}\033[0m\n\n"; }
4blue() { printf "\033[38;5;27m${1}\033[0m\n"; }
5purple() { printf "\033[35m${1}\033[0m\n\n"; }
6
7## show hidden files
8defaults write com.apple.Finder AppleShowAllFiles true
9
10# brew
11blue "Installing brew"
12bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
13brew analytics off
14brew bundle install
15
16## zinit
17blue "Installing zinit"
18bash -c "$(curl --fail --show-error --silent --location https://raw.githubusercontent.com/zdharma-continuum/zinit/HEAD/scripts/install.sh)"
19
20## vim
21blue "Installing vim plug"
22curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
23 https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
24
25## font
26blue "Installing fonts"
27echo -e "\xee\x82\xa0"
28brew tap homebrew/cask-fonts
29brew install --cask font-fira-code
30brew install font-hack-nerd-font
31echo -e "\xee\x82\xa0"
32
33# xcode
34blue "Installing xcode"
35xcode-select --install
36
37# sudo part
38sudo spctl --master-disable
39sudo csrutil disable
40
41# exit
42green "Install successfully, enjoy this awsome machine ❤️"
43exit
44