Posts
mac问题汇总

mac问题汇总

记录macos初次使用的一些问题

显卡切换

sudo pmset -a GPUSwitch i
i = 0/1/2 cpu/gpu/auto 外接显示器必须得开独显,贼坑

强制退出程序

cmd + opt + esc

三指拖动

偏好设置 -> 辅助功能 -> 指针控制 -> 触控板选项

homebrew

mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

环境变量

默认的sehllzsh, 需要将~/.bashrc,~/.bash_profile,/etc/profile中的变量移到zshrc中, 或是在zshrcsourcebash中的变量

同程序不同窗口切换

cmd + ~

同窗口不同标签

cmd + opt + </>

Quicktime录屏,仅录制内部声音

安装soundflower插件,再到音频MIDI设置中添加聚集与多输出设备

vscode代码补全tab切换

command + shift + p, Preference: Open keyboard Shortcuts(Json)

[
    {
        "key": "tab",
        "command": "acceptSelectedSuggestion",
        "when": "suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "shift+tab",
        "command": "acceptSelectedSuggestion",
        "when": "suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "tab",
        "command": "selectNextSuggestion",
        "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible"
    },
        {
        "key": "shift+tab",
        "command": "selectPrevSuggestion",
        "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible"
    }
]

zsh配置

brew install zsh
brew cask install iterm2
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
cp ~./oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
#chsh -s /bin/zsh
 
# theme
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
 
# Inconsolata Powerline font
git clone https://github.com/powerline/fonts.git
cd font
./install.sh
 
git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
 
 
 
# .zshrc
#ZSH_THEME="powerlevel9k/powerlevel9k"
#plugins=(git zsh-autosuggestions zsh-syntax-highlighting z history-substring-search history )

.zshrc

asynctask

brew install fzf
 
mkdir ~/github
cd ~/github
git clone --depth 1 https://github.com/skywind3000/asynctasks.vim
 
mkdir -p ~/.config/asynctask/
echo -e '[git-fetch-master]
command=git fetch origin master
cwd=<root>
 
[git-checkout]
command=git checkout $(?branch)
cwd=<root>' > ~/.config/asynctask/tasks.ini
 
sudo ln -s /Users/wcw/github/asynctasks.vim/bin/asynctask /usr/local/bin
echo alias task='asynctask -f' >> ~/.zshrc    
echo bindkey -s "'\\e[15~'" "'task\\n'" >> ~/.zshrc
source ~/.zshrc 
 

WireShark权限

sudo chown wcw bp*

Xcode c IO输出

左侧navigatorProducts, 右键项目, Show in finder

vscode 上下次位置

win10 alt + <-/-> mac ctl + shift + - / ctl + -

Xcode malloc incorrect checksum

cmd + 8切换断点导航栏, 左下角➕选择Symbol断点, 然后在Symbol字段下添加malloc_error_break, module会默认匹配到libsystem_malloc.dylib , 添加action, bt(backtrace), 即可像python那样打印异常栈,

其实也可以直接在报错的调试栏进行的交互式lldb来手动打印bt, 定位代码段, 打印变量, 地址 Product下的Scheme可以设定各种malloc的守护机制, 帮助定位malloc错误

Xcode lib location

Xcode默认的IDE lib是不包括openssl的, 而mac又是自带openssl的, 只需要将opensslinclude软连接到Xcodeinclude下,

应用->平台->SDK,臭长臭长的/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/

which、where的话,只能看可执行文件的位置, 万能的google还是能找到, lib通常会在/usr/local, binary则是/usr/binsudo ln -s /usr/local/opt/openssl/include/openssl . 然后就能正常#include <openssl/ssl.h>

Updated at