Skip to content

Instantly share code, notes, and snippets.

@amio
Last active May 28, 2020 14:19
Show Gist options
  • Save amio/5541645 to your computer and use it in GitHub Desktop.
Save amio/5541645 to your computer and use it in GitHub Desktop.
一些不太常用所以记不住但还挺有用的终端命令

一些不太常用所以记不住但还挺有用的终端命令

# 清理 Launchpad 缓存,解决双指滑动卡顿的问题
rm ~/Library/Application\ Support/Dock/*.db
killall Dock
# "XXX" is damaged and can’t be opened. You should move it to trash.
# http://apple.stackexchange.com/questions/58050/damaged-and-cant-be-open-app-error-message
xattr -rc /Volumes/Application.app
# 修复 n 安装的 node 每次启动服务器都会弹出确认 “Do you want the application “node” to accept incoming network connections?” 的问题
# https://github.com/tj/n/issues/394#issuecomment-386807868
sudo codesign --force --sign - /usr/local/bin/node
# 先停止所有下载,退出 utorrent,执行命令:
cd "~/Library/Application Support/uTorrent" && sudo rm -f *.old
## Remove existing .DS_Store files from the repository:
find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch
# 清理右键 "Open With ..." 菜单
# Clean Items on “Open With…” List in Mac OS X
# Credit to: http://itpixie.com/2011/05/fix-duplicate-old-items-open-with-list/
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/\
LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local\
-domain system -domain user
# Enable text selection within Quicklook
defaults write com.apple.finder QLEnableTextSelection -bool TRUE; killall Finder
# and Disable it:
defaults delete com.apple.finder QLEnableTextSelection; killall Finder
# Enable Quicklook On Application Switch
defaults write com.apple.finder QLHidePanelOnDeactivate false; killall Finder
# and Disable it:
defaults write com.apple.finder QLHidePanelOnDeactivate true; killall Finder
# Show The Finder Pathbar In The Title
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true; killall Finder
# and Disable it:
defaults write com.apple.finder _FXShowPosixPathInTitle -bool false; killall Finder
# 禁用开机声音:咚~
sudo nvram SystemAudioVolume=%80
# 启用开机声音:咚~
sudo nvram -d SystemAudioVolume
# list
diskutil list
# unmount
diskutil unmount /dev/disk5s2
# remount
mkdir ~/Public/LaCie
sudo diskutil mount -mountPoint ~/Public/LaCie /dev/disk5s2
diskutil unmount /dev/disk3s2 22:16:55
# Volume MioT2 on disk3s2 unmounted
sudo diskutil mount -mountPoint ~/Public/MioT2 /dev/disk3s2 22:17:37
# Volume MioT2 on /dev/disk3s2 mounted
# 修正 npm 命令没有 sudo 就会报错的问题
# 一劳永逸地设置下文件夹所有权即可:
sudo chown -R `whoami` /usr/local/lib/node_modules ~/.npm
# Terminal 启动提速
# 问题是由于 /private/var/log/asl/ 目录下的系统日志太多,删除即可
# http://www.webapper.com/blog/index.php/2009/03/26/consoleapp-freezes-on-launch-terminalapp-slow-to-launch/
sudo rm -rf /private/var/log/asl/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment