Mac 配置
终端安装
iTerm2 直接在网上下载iTerm2
首先
xcode-select --install
配置brew
# 使用国内源安装
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
配置oh-my-zsh
wget https://gitee.com/pocmon/ohmyzsh/raw/master/tools/install.sh chmod +x install.sh ./install.sh
添加代理别名,加到.zshrc;我的代理查了配置文件才知道监听2333
echo '
# >>>终端配置代理 START >>>
alias proxy="
export http_proxy=socks5://127.0.0.1:2333;
export https_proxy=socks5://127.0.0.1:2333;
export all_proxy=socks5://127.0.0.1:2333;
export no_proxy=socks5://127.0.0.1:2333;
export HTTP_PROXY=socks5://127.0.0.1:2333;
export HTTPS_PROXY=socks5://127.0.0.1:2333;
export ALL_PROXY=socks5://127.0.0.1:2333;
export NO_PROXY=socks5://127.0.0.1:2333;"
alias unproxy="
unset http_proxy;
unset https_proxy;
unset all_proxy;
unset no_proxy;
unset HTTP_PROXY;
unset HTTPS_PROXY;
unset ALL_PROXY;
unset NO_PROXY"
proxy
# <<< 终端配置代理 END <<<
' >> ~/.zshrc
终端插件
接来下,就可以用proxy开,unproxy关终端代理了
p10k主题并未安装
配置了zsh的zsh-autosuggestions插件
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
修改.zshrc内
plugins=(git zsh-autosuggestions)
安装软件工具
安装软件
# cli
brew install git # 替换自带的git
brew install tree # 输出目录结构
brew install thefuck #thefuck还需要在.zshrc中添加eval $(thefuck --alias),不过fuck fuck也能配好
# gui
brew install obsidian # 笔记
brew install keka # 解压
brew install wpsoffice-cn # wps
brew install qq wechat # 社交
brew install orbstack # 上位替代docker
手动安装 runcat
添加到.zshrc中
# >>> Java环境配置 START >>>
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home # 优先使用jdk21
# export CPPFLAGS="-I/opt/homebrew/opt/openjdk@21/include" # 使得编译时能找到jdk21的头文件
function jdk8() {
# 设置 JDK 8
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home
echo "Switched to JDK8"
}
function jdk21() {
# 设置 JDK 21
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home
echo "Switched to JDK21"
}
# <<< Java环境配置 END <<<
快捷开终端
文件夹下快捷打开终端 自动操作app -> 新建文稿 -> 创建应用程序 -> 资源库 -> 实用工具 -> 运行AppleScript,把app拖到访达工具栏处
on run {input, parameters}
tell application "Finder"
set pathList to (quoted form of POSIX path of (folder of the front window as alias))
set command to "clear; cd " & pathList
end tell
tell application "System Events"
# some versions might identify as "iTerm2" instead of "iTerm"
set isRunning to (exists (processes where name is "iTerm")) or (exists (processes where name is "iTerm2"))
end tell
# 如果想用terminal,就把这里改成terminal
tell application "iTerm"
activate
set hasNoWindows to ((count of windows) is 0)
if isRunning and hasNoWindows then
create window with default profile
end if
select first window
tell the first window
if isRunning and hasNoWindows is false then
create window with default profile
end if
tell current session to write text command
end tell
end tell
end run
ssh
配置 ssh-agent
ssh-keygen -t rsa -f ~/.ssh/id_rsa -C "youremail@gmail.com"
于是 .ssh/id_rsa 密钥、.ssh/id_rsa.pub 公钥就被创建
配置 .ssh/config
# Added by OrbStack: 'orb' SSH host for Linux machines
# This only works if it's at the top of ssh_config (before any Host blocks).
# This won't be added again if you remove it.
Include ~/.orbstack/ssh/config
Host hostname
HostName ipaddress
User username
IdentityFile ~/.ssh/id_rsa
配置 .zshrc 的 ssh 部分,自动启动 ssh-agent 以及加载私钥并利用 apple-use-keychain 加载密码
# >>> SSH环境配置 START >>>
# 启动 SSH Agent
if [ -z "$SSH_AUTH_SOCK" ]; then
eval "$(ssh-agent -s)" > /dev/null
fi
# 确保 id_rsa 密钥已加载
if ! ssh-add -l 2>/dev/null | grep -q "id_rsa"; then
ssh-add --apple-use-keychain ~/.ssh/id_rsa > /dev/null 2>&1
fi
# <<< SSH环境配置 END <<<