~
Just a place to throw away some text.
Never sleep:
caffeinate -u -t 3600
caffeinate -i
Use Touch ID in Terminal:
sudo cp /etc/pam.d/sudo_local.template /etc/pam.d/sudo_local
# Uncomment last line
sudo nano /etc/pam.d/sudo_local
Hide Developer in Spotlight:
cd /Applications
touch Xcode.app
# Xcode mini version
xcode-select --install
Repeat key:
defaults write -g ApplePressAndHoldEnabled -bool false
Reset launchpad:
defaults write com.apple.dock ResetLaunchPad -bool true; killall Dock
Reduce padding in menu bar (Log out then log in to apply):
defaults -currentHost write -globalDomain NSStatusItemSelectionPadding -int 6
defaults -currentHost write -globalDomain NSStatusItemSpacing -int 6
Tweak Finder:
# Use list view
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
# Show path bar
defaults write com.apple.finder ShowPathbar -bool true
# Show status bar
defaults write com.apple.finder ShowStatusBar -bool true
# Show filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Keep folders on top when sorting by name
defaults write com.apple.finder _FXSortFoldersFirst -bool true
killall Finder
Enable accent color:
defaults write -g NSColorSimulateHardwareAccent -bool YES
# Value 3-8
defaults write -g NSColorSimulatedHardwareEnclosureNumber -int 7
Disable IPv6:
sudo networksetup -listallnetworkservices
sudo networksetup -setv6off Wi-Fi
Clean up leftover data:
/Library/Application Support
/Library/LaunchAgents
/Library/LaunchDaemons
/Library/Preferences
/Users/Shared
~/Library/Application Support
~/Library/Fonts (Removed)
~/Library/LaunchAgents
~/Library/Preferences
Clean up leftover shell:
/etc/bashrc
/etc/profile
/etc/zshrc
/etc/paths.d
Clean up clipboard:
pbcopy < /dev/null
Disable Smart zoom in Track pad settings to make right click instant
Fix OpenVPN Client 3
sudo launchctl unload -w /Library/LaunchDaemons/org.openvpn.client.plist
sudo launchctl load -w /Library/LaunchDaemons/org.openvpn.client.plist
Bluetooth stutter:
sudo rm /Library/Preferences/com.apple.Bluetooth.plist
sudo pkill bluetoothd
Thanks:
about:config
:
Disable unused features:
extensions.pocket.enabled
: falseidentity.fxaccounts.enabled
: falsereader.parse-on-load.enabled
: falseGood settings:
media.videocontrols.picture-in-picture.video-toggle.always-show
: true
network.IDN_show_punycode
: truebrowser.tabs.insertAfterCurrent
: trueEncrypted Client Hello (ECH):
network.dns.echconfig.enabled
: truenetwork.dns.use_https_rr_as_altsvc
: trueExperiment
image.jxl.enabled
: trueExtensions:
Thanks:
Edit ~/.ssh/config
Host *
IdentitiesOnly yes
UseKeychain yes
Thanks:
# Delete untracked
git clean -fdx
git gc
With find:
find . -name ".DS_Store" -print -type f -delete
With fd:
fd -H '^\.DS_Store$' -tf -X rm
Remove proto options:
sd -F 'import "validate/validate.proto";' '' api/raw/*.proto
sd -F 'import "marshal-zap.proto";' '' api/raw/*.proto
sd -f s '\s\[.*?];' ';' api/raw/*.proto
Remove duplicated files:
fdupes -rdN .
# Result is dst/src
rsync -avzP src dst
# Result is dst/* with * is from src
rsync -avzP src/ dst
Commonly flags:
-v
: verbose-z
: compress-P
: enable both --partial
,
--progress
to easily resume after interrupt
-n
: dry runBe careful flags (need dry run if not sure):
-u
: skip if files in dst is already newer
than in src, if you want to sync both ways
--delete
: delete files in dst if not exist
in src, useful to sync dst with src
# -crf: quality, 0 is lossless, more is lower quality
# -an: no audio
# -c:a aac -b:a 128k: audio codec and bitrate
ffmpeg -i input -c:v libx265 -crf 26 -preset fast -an output.mp4
Links:
Convert:
# Add --vips-progress to show progress
vips jxlsave filename.jpg filename.jxl --keep=none
vips jpegsave filename.png filename.jpg --keep=none
# Batch convert (require fd)
fd "jpg|jpeg|png|webp|gif" --exec vips jxlsave {} {.}.jxl --keep=none
fd "jpg|jpeg|png|webp|gif" --exec-batch rm
fd "png|webp|gif" --exec vips jpegsave {} {.}.jpg --keep=none
fd "png|webp|gif" --exec-batch rm
# Rotate
vips rot filename.jxl new_filename.jxl d90
Download:
yt-dlp -f - "https://www.youtube.com/watch?v=video_id"
Rename:
# If dry run, remove --exec
f2 --replace "{mtime.YYYY}{mtime.MM}{mtime.DD}_{mtime.H}{mtime.mm}{mtime.ss}_{hash.md5}{ext}" --exec
# Include ImageSize (require exiftool)
f2 --replace "{mtime.YYYY}{mtime.MM}{mtime.DD}_{mtime.H}{mtime.mm}{mtime.ss}_{xt.ImageSize}_{hash.md5}{ext}" --exec
# Not include time
f2 --exclude="\d+x\d+_[a-z\d]{32}" --sort=mtime --replace "{xt.ImageSize}_{hash.md5}{ext}" --exec
# Remove space in directory
f2 --find " " --replace "_" --string-mode --only-dir --exec