Skip to content

Mac 使用小记

Published: at 10:00 AM

Table of contents

Open Table of contents

系统设置

程序坞自动隐藏加速

# 设置启动坞动画时间设置为 0.5 秒
defaults write com.apple.dock autohide-time-modifier -float 0.5 && killall Dock

# 设置启动坞响应时间最短
defaults write com.apple.dock autohide-delay -int 0 && killall Dock

# 恢复启动坞默认动画时间
defaults delete com.apple.dock autohide-time-modifier && killall Dock

# 恢复默认启动坞响应时间
defaults delete com.apple.Dock autohide-delay && killall Dock

启动台自定义行和列

# 设置列数
defaults write com.apple.dock springboard-columns -int 7

# 设置行数
defaults write com.apple.dock springboard-rows -int 6

# 重启 Dock 生效
killall Dock

# 恢复默认的列数和行数
defaults write com.apple.dock springboard-rows Default
defaults write com.apple.dock springboard-columns Default

# 重启 Dock 生效
killall Dock

解除 history 输出条数过少的限制

export HISTSIZE=100000
export HISTFILESIZE=100000

常用软件安装

命令行工具

统一采用 Homebrew 对系统软件包进行管理,安装命令行工具时,优先考虑 Homebrew 提供的软件包。

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

差生文具多:

PreferDescriptionReplace
ezaA modern, maintained replacement for ls.ls
zoxideA smarter cd command, supports all major shells.cd
htopAn interactive process viewer.top
ripgrepripgrep recursively searches directories for a regex pattern while respecting your gitignoregrep
ncduNcdu (NCurses Disk Usage) is a disk usage analyzer with an ncurses interface.du
batA cat(1) clone with wings.cat
fdA simple, fast and user-friendly alternative to ‘find’find
procsA modern replacement for ps written in Rust.ps
fzfA general-purpose command-line fuzzy finder written in Go.find
fzf-tabReplace zsh’s default completion selection menu with fzf.find
tokeiA program that displays statistics about your code.cloc
tldrCollaborative cheatsheets for console commands.man
thefuckMagnificent app which corrects your previous console command.-
lazygitA simple terminal UI for git commands.git
lazydockerA simple terminal UI for both docker and docker-compose.docker
fastfetchLike neofetch, but much faster because written mostly in C.neofetch
deltaA syntax-highlighting pager for git, diff, and grep output.diff

部分 alias 定义于 ~/.zshrc 如下:

alias ls="eza"
alias ll="eza --time-style=long-iso --icons --group --git --binary -lg"
alias tree="eza --tree --icons"
alias cls="clear"

开发工具

GUI 工具

统一采用 Homebrew Cask 进行管理。

$ brew list
==> Formulae
...
==> Casks
1password                       iina                    plex
alacritty                       jellyfin                sabnzbd
applite                         loop                    transmit
daisydisk                       lulu                    tuxera-ntfs
downie                          netnewswire             typora
font-jetbrains-mono-nerd-font   notion                  zed
font-lxgw-wenkai                orbstack
handbrake                       pictureview

编程语言版本管理

MacOS 软件一键更新

准备工作

更新软件

升级所有已安装的软件:

brew update && brew upgrade && brew cu --all --yes --cleanup \
&& mas upgrade && brew cleanup
  1. brew update:更新 Homebrew 自身及其相关软件源的信息,确保 Index 信息准确;

  2. brew upgrade:将系统中已安装的所有 Homebrew 软件包升级到最新版本;

  3. brew cu --all --yes --cleanup:自动升级所有可更新的 Homebrew cask 软件包到最新版本,并在完成后清理删除旧版本;

  1. mas upgrade: 一键更新从 Mac App Store 安装的应用程序;

  2. brew cleanup: 用于清理 Homebrew 安装的软件包时产生的临时文件和缓存,以释放磁盘空间。

执行结果样例如下:

可以作为定时任务,周期性执行,以保持 Mac 上软件为最新版本。