Skip to content

dev24hrs/Dotfiles

Repository files navigation

[Mac] WorkFlow

[!NOTE] This is a collection of configurations that includes all on my Mac.

keywords: [git, homebrew, nerdfonts, fish, starship, neovim, tmux, golang, rust]



setup.sh & cfg.sh

setup.sh

新mac: 无任何环境配置

git clone https://github.com/dev24hrs/Dotfiles.git ~/Documents/Dotfiles
cd ~/Documents/Dotfiles && chmod +x setup.sh && ./setup.sh
# setup.sh 脚本会执行dotfiles的所有配置

cfg.sh

相关使用场景:

  • ./cfg.sh symlinks: 当前mac环境,之前手动配置 ~/.config,也手动维护dotfiles目录,现在改成symlink方式
# 在Dotfiles目录执行 ./cfg.sh symlinks
# 自动在 ~/.config目录下创建相关链接,并链接到Dotfiles的对应配置目录
# 同时备份之前手动管理的配置
  • ./cfg.sh add : 假如后续想安装某个某些软件,需要配置 ~/.config / ~目录
# 比如新安装了yazi,则在Dotfiles目录下执行
./cfg.sh add ~/.config/yazi
# 或者
./cfg.sh add ~/.hammerspoon

# 然后手动在 cfg.sh 的 setup_symlinks() 里补上对应的 make_link
# 最后 git 提交Dotfiles更新
  • ./cfg migrate: 当前mac环境,之前只手动配置~/.config,无dotfiles
mkdir -p ~/Dotfiles && cd ~/Dotfiles

# 把config 已有配置都迁移进 Dotfiles
./cfg.sh migrate

# 检查结果
ls -la ~/.config/fish   # 应该显示 -> ~/Dotfiles/fish

# 3. 提交
git add .
git commit -m "chore: migrate existing configs to Dotfiles"
git push

Brewfile

  • 导出当前 mac 已安装的所有包
brew bundle dump --file=~/Dotfiles/Brewfile --force
# --force 表示已存在则覆盖
  • 在新 mac 上安装 Brewfile 里的所有包
brew bundle install --file=~/Dotfiles/Brewfile
  • 检查哪些包已安装、哪些还没装
brew bundle check --file=~/Dotfiles/Brewfile
  • 清理本机有但 Brewfile 里没有的包(同步删除)
brew bundle cleanup --file=~/Dotfiles/Brewfile
# 加 --force 才会真正删除,不加只是预览
brew bundle cleanup --file=~/Dotfiles/Brewfile --force
  • 装了新包之后同步到 Brewfile
# 重新导出
brew bundle dump --file=~/Dotfiles/Brewfile --force
# 生成 brewfile, 无vscode 相关依赖
brewup file

Enhance terminal

Note

已存在于 setup.sh 自动配置

#  Disable press-and-hold for keys in favor of key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 1  # default 2,recommend 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10

# mac app id
osascript -e 'id of app "app name"'
# e.g
osascript -e 'id of app "Wezterm"'

Git Config

refer to git config

Homebrew

Use pkg to install homebrew, but need to config config.fish

# add to config.fish
# homebrew
eval (/opt/homebrew/bin/brew shellenv)

# set ustc mirrors
# export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
# export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
# export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"
# then
source ~/.config/fish/config.fish

brew update
# if unistall
# then brew autoremove
# brew cleanup
# brew cleanup --prune=all

Font

brew install

  • english: recursive & fira

    brew install --cask font-recursive-mono-nerd-font
    brew install --cask font-fira-mono-nerd-font
  • symbols

    brew install --cask font-symbols-only-nerd-font
  • chinese simple : source-han-sans

    brew install --cask font-source-han-sans-vf

manual install (Recommend)

Note

The brew method installs many unnecessary fonts. For example, when installing Source Han Sans, brew will automatically install Japanese, Korean, and Traditional Chinese fonts, but I only need Simplified Chinese.

  • english

    ## recursive & fira
    https://www.nerdfonts.com/font-downloads
  • chinese simple

    ## chinese simple otf
    https://github.com/adobe-fonts/source-han-sans/releases

Fish Shell

refer to fish config

Cli Tools

Starship

refer to starship config

brew install starship
  • with fish
starship init fish | source

# config
# use preset & restart terminal starship preset nerd-font-symbols -o ~/.config/starship/starship.toml
# or can refer to github dotfiles

Bat

brew install bat
  • config
# config
bat --generate-config-file
# add to ~/.config/bat/config
--paging=never
--theme="gruvbox-dark"
--style="numbers,changes,header,snip,rule"
  • with fish
# add to config.fish
alias cat='bat'

Fzf

brew install fzf
  • with fish
# add to config.fish
# FZF
fzf --fish | source
set -gx FZF_DEFAULT_COMMAND 'fd --type f --strip-cwd-prefix --hidden --follow --exclude .git'
set -gx FZF_CTRL_T_COMMAND "$FZF_DEFAULT_COMMAND"
set -gx FZF_DEFAULT_OPTS "--height 40% --layout=reverse --border --preview 'bat --style=numbers --color=always --line-range :500 {}' --preview-window 'right,60%,border-left'"
set -gx FZF_CTRL_R_OPTS "--preview-window hidden"

Zoxide

brew install zoxide
  • with fish
zoxide init fish | source

Delta

brew install git-delta

Eza

  • install eza

    brew install eza
  • with fish

    alias ls='eza -a --icons --group-directories-first'
    alias la='eza -la --icons --group-directories-first'
    alias lt='eza -aT --icons --group-directories-first --git-ignore'

Fd & RipGrep

brew install fd
brew install ripgrep

LazyGit

refer to config or default config

brew install lazygit
  • with fish
alias lg='lazygit'

Cheat.sh

# add to config.fish
function ch --description 'curl cheat.sh'
    curl cheat.sh/$argv[1]
end

# use
ch go chan

Go-musicbox

brew install anhoder/go-musicfox/go-musicfox
  • with fish
alias mu='musicfox'

WezTerm

refer to wezterm config

brew install --cask wezterm@nightly

Tmux

config refer to tmux dotfiles

Neovim

config refer to nvim dotfiles

Vimrc

Refer to vimrc

Rime 输入法

Refer to rime 输入法

Golang

  • install
# brew install
brew install go
go version
brew upgrade go

# set env
mkdir -p $HOME/Documents/Tools/GoPath/pkg
mkdir -p $HOME/Documents/Tools/GoPath/bin

go env -w GOPROXY=https://goproxy.cn,direct
go env -w GO111MODULE=on
go env -w GOPATH=$HOME/Documents/Tools/GoPath

# gofumpt
go install mvdan.cc/gofumpt@latest

# gopls
go install golang.org/x/tools/gopls@latest
  • with fish
set -gx GOPATH $HOME/Documents/Tools/GoPath
fish_add_path $GOPATH/bin

Books

Rust

Setup

Refer to set up

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

其他命令:

rustc --version
cargo --version
rustup update

Awesome Rust

Apps

  • AlDente -- charge limiter app

  • lemon -- mac clean app

  • Chrome -- browser

  • appcleaner -- app manager

  • snipaster -- screenshot

  • vlc -- video player

  • Vimium -- Chrome & Arc extension for Vim

    # config Custom key
    unmap /
    map <c-/> enterFindMode
    # Custom search engines
    # so u can press o and enter g/bd/gh to search something
    bd: http://www.baidu.com/s?wd=%s+-csdn Baidu
    g: https://www.google.com/search?q=%s Google
    gh: https://github.com/search?q=%s GitHub
  • sublime text -- buy license from taobao

    {
     "ignored_packages":
     [
      "Vintage",
     ],
     "color_scheme": "ayu-light.sublime-color-scheme",
     "theme": "ayu-light.sublime-theme",
     "always_prompt_for_file_reload": true,
     "font_size": 16,
     "remember_open_files": true,
     "update_check": false,
     "font_face": "RecMonoCasual Nerd Font",
    }
  • PicGo -- upload images to GitHub

    if u forget your GitHub tokens, u cant find it in the blew file data.json

    // the data.json saved all the uploaded imgs info
    // this is vscode settings
    "picgo.dataPath": "$home/Library/Application Support/picgo/data.json",

    If use typora & picgo app, when u pasted images in typora,it will cached images in the path$home/Library/Application\ Support/typora-user-images,so u need clean it.

LICENSE

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors