Category: macOS

  • mac 查看端口占用

    docker: Error response from daemon: Ports are not available: listen tcp 0.0.0.0:8080: bind: address already in use.
    ERRO[0000] error waiting for container: context canceled
    
    lsof -n -i4TCP:8080 | grep LISTEN
    
    main    30863 jpuyy   14u  IPv6 0xe7a300fd0dafc76f      0t0  TCP *:http-alt (LISTEN)
    
    jpuyy       30863   0.0  0.0  5014020  10856 s010  S+    3:22PM   0:00.29 /var/folders/d7/s1_bmdw95gg8grv857tkvqmw0000gp/T/go-build454434651/b001/exe/main all
    
    
  • DELL U2720QM 匹配设置 macOS OR win11

    U2720QM 设置

    Display -> Response Time -> Fast
    Smart HDR -> Desktop

    macOS 设置

    System Preferences -> Displays

    按住 Options 点 Scaled,选择

    2304 x 1296(比较舒服)介于 2k 和 1080p 之间

    此时 High dynamic Range (HDR)应该是勾选状态

    在 System Information -> Hardware -> Graphics/Displays 显示

    Radeon Pro 560X:
    
      Chipset Model:	Radeon Pro 560X
      Type:	GPU
      Bus:	PCIe
      PCIe Lane Width:	x8
      VRAM (Total):	4 GB
      Vendor:	AMD (0x1002)
      Device ID:	0x67ef
      Revision ID:	0x00c2
      ROM Revision:	113-C980AL-075
      VBIOS Version:	113-C97501U-005
      EFI Driver Version:	01.A1.075
      Automatic Graphics Switching:	Supported
      gMux Version:	5.0.0
      Metal:	Supported, feature set macOS GPUFamily2 v1
      Displays:
    DELL U2720QM:
      Resolution:	3840 x 2160 (2160p/4K UHD 1 - Ultra High Definition)
      UI Looks like:	1920 x 1080 @ 60 Hz
      Framebuffer Depth:	30-Bit Color (ARGB2101010)
      Display Serial Number:	5ZG1WS2     
      Main Display:	Yes
      Mirror:	Off
      Online:	Yes
      Rotation:	Supported
      Automatically Adjust Brightness:	No
      Connection Type:	DisplayPort
    

    Win10 设置

    175% 缩放

  • zsh .zprofile

    从 macOS Catalina 开始,zsh 成为了默认 shell

    https://support.apple.com/en-us/HT208050

    .zprofile 相当于 .bash_profile
    .zshrc 相当于 .bashrc


    fix error
    zsh compinit: insecure directories, run compaudit for list.
    Ignore insecure directories and continue [y] or abort compinit [n]? ccompinit: initialization aborted
    complete:13: command not found: compdef
    complete:13: command not found: compdef
    complete:13: command not found: compdef
    检查$ compaudit
    There are insecure directories:
    /usr/local/share/zsh/site-functions
    /usr/local/share/zsh

    chown -R "$(whoami)" /usr/local/share/zsh/site-functions /usr/local/share/zsh
    chmod 755 /usr/local/share/zsh/site-functions /usr/local/share/zsh
    


    2023-03-16 fix error

    Last login: Thu Mar 16 14:35:14 on ttys010
    [9]    47765 illegal hardware instruction  sed --version 2>&1 | 
           47766 exit 1                        grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} -q GNU
    

    fixed by updating file `oh-my-zsh.sh`

    omz update
    

    preferred zsh themes

    ZSH_THEME="random"                                                                         
    # Set list of themes to pick from when loading at random                        
    # Setting this variable when ZSH_THEME=random will cause zsh to load            
    # a theme from this variable instead of looking in ~/.oh-my-zsh/themes/         
    # If set to an empty array, this variable will have no effect.                  
    ZSH_THEME_RANDOM_CANDIDATES=(rkj-repos cloud)
    
  • brew 切换 node 版本

    现在默认安装的 node 是 13 版本,因为要用 12 版本,进行如下操作

    安装 12 版本

    brew install node@12
    
    

    查看所有 node 版本

    brew ls --versions | grep node
    
    node 13.1.0
    node@12 12.13.1
    

    切换为 12 版本

    brew unlink node
    rm -f '/usr/local/bin/npm'
    rm -f '/usr/local/bin/npx'
    rm -rf /usr/local/lib/node_modules
    brew link --force node@12
    
  • macOS 初始化及必装软件

    Langurage & Region-设置为英文 (Only)

    Dock 设置到左侧, Automatically hide and show the Dock
    remove unneed applications in Dock
    取消勾选 Show recent applications in Dock
    minimize window using: Scale effect

    Keyboard -> input sources 五笔
    Keyboard -> shortcuts -> switch select previous input source using command + space ( remove spotlight shortcuts )
    Keyboard -> Key Repeat(Fast), Delay Until Repeat(Short)
    Modifier Keys Caps Lock 改为 Control
    添加启动台快捷键 F4

    The Unarchiver
    kindle
    The Clock # App Store

    默认使用 zsh

    env | grep SHELL
    

    https://support.apple.com/en-us/HT208050?from=timeline&isappinstalled=0

    open terminal, type `git`, hint

    xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.
    

    brew

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

    如果安装包都是 up-to-date,可以先执行, 不用每次 check, 节省时间

    export HOMEBREW_NO_AUTO_UPDATE=1

    brew install wget
    brew install jq
    brew install yq
    brew install cmake
    brew install llvm

    ·> brew install python3
    Warning: No available formula with the name “python3”.
    ·> rm -fr $(brew –repo homebrew/core)
    brew install python3

    brew install google-cloud-sdk
    gcloud components install kubectl
    gcloud components install gke-gcloud-auth-plugin

    遇到

    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    

    解决

    xcode-select --install
    

    brew install openssl
    brew install mysql-client
    brew install grep
    brew install mtr # sudo /usr/local/sbin/mtr baidu.com
    brew install oath-toolkit # sudo chown ${USER}:wheel /usr/local/lib/security
    brew install iperf
    brew install fping
    brew install tflint
    brew install maven
    brew install openjdk
    brew install ansible
    brew install nvm
    brew install nmap

    brew install kubectx
    brew install fzf # https://github.com/junegunn/fzf

    brew install yarn
    brew install gradle
    brew install gnu-sed
    brew install tree
    brew install github/gh/gh
    brew install terraform
    brew install shellcheck
    brew install shfmt
    brew install hey
    brew install coreutils
    brew install brotli
    brew install kubernetes-helm
    brew install sbt
    brew install gawk
    brew install watch
    brew install yamllint
    brew install inetutils # PATH=”/usr/local/opt/inetutils/libexec/gnubin:$PATH”
    brew install redis

    # nodejs
    brew install npm

    brew install keepassxc # https://keepassxc.org/

    brew install go2shell

    brew install cisco-proximity

    golang https://jpuyy.com/?p=8411

    https://ohmyz.sh/

    application 开发组件
    https://www.jetbrains.com/toolbox-app/ 下载 webstorm goland pycharm intelij, 登录账号, 设置自动更新,添加 shell scripts 命令到 /usr/local/bin
    brew install vault
    brew install terragrunt
    brew install git-crypt
    brew install aliyun-cli
    brew install groovysdk
    brew install pre-commit
    brew install wireshark –cask
    brew install fortio

    brew install graphviz
    https://gpgtools.org/
    https://istio.io/docs/setup/getting-started

    kubectl 插件
    https://krew.sigs.k8s.io/docs/user-guide/setup/install/

    启用 locate updatedb

    sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
    

    docker 安装
    https://hub.docker.com/editions/community/docker-ce-desktop-mac/

    logitech options
    https://support.logi.com/hc/zh-cn/articles/360025297893

    Apple Music => account => Sign In

    分屏 rectangle https://rectangleapp.com/

    vscode https://code.visualstudio.com/

    postman https://www.postman.com/downloads/?utm_source=postman-home

    2022-01-13 更换新电脑 MacBook Pro (14-inch, 2021) Apple M1 Max 更新

    2023-03 Intel Mac 更换 MacBook Pro 13-inch, M2, 2022

    Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
    Please create a new installation in /opt/homebrew using one of the
    “Alternative Installs” from:
    https://docs.brew.sh/Installation
    You can migrate your previously installed formula list with:
    brew bundle dump
    重新安装 brew
    brew 将会安装到 /opt/homebrew/bin/brew
    可以清理 /usr/local/Cellar 下的无用文件