/dotfiles

My personal macOS configuration

Primary LanguageShell

dotfiles

This repository contains my personal SketchyBar, Yabai and Skhd configurations.

Screenshot2023-01-01

0x01 Installation

# Installing yabai, skhd, jq and alacritty
brew tap homebrew/cask-fonts
brew install koekeishiya/formulae/yabai
brew install jq
brew install koekeishiya/formulae/skhd
brew install gh #(gh auth login for notifications)
brew install --cask sf-symbols
brew install --cask font-hack-nerd-font
brew install --cask alacritty

# setting tmux
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm


# Installing Fonts
git clone git@github.com:shaunsingh/SFMono-Nerd-Font-Ligaturized.git /tmp/SFMono_Nerd_Font
mv /tmp/SFMono_Nerd_Font/* $HOME/Library/Fonts
rm -rf /tmp/SFMono_Nerd_Font/
curl -L https://github.com/kvndrsslr/sketchybar-app-font/releases/download/v1.0.3/sketchybar-app-font.ttf -o $HOME/Library/Fonts/sketchybar-app-font.ttf

# macOS Settings
echo "Changing macOS defaults..."
defaults write com.apple.NetworkBrowser BrowseAllInterfaces 1
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.spaces spans-displays -bool false
defaults write com.apple.dock autohide -bool true
defaults write com.apple.dock "mru-spaces" -bool "false"
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
defaults write com.apple.LaunchServices LSQuarantine -bool false
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false
defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
defaults write NSGlobalDomain _HIHideMenuBar -bool true
defaults write NSGlobalDomain AppleHighlightColor -string "0.65098 0.85490 0.58431"
defaults write NSGlobalDomain AppleAccentColor -int 1
defaults write com.apple.screencapture location -string "$HOME/Desktop"
defaults write com.apple.screencapture disable-shadow -bool true
defaults write com.apple.screencapture type -string "png"
defaults write com.apple.finder DisableAllAnimations -bool true
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool false
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool false
defaults write com.apple.finder ShowMountedServersOnDesktop -bool false
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool false
defaults write com.apple.Finder AppleShowAllFiles -bool true
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
defaults write com.apple.finder ShowStatusBar -bool false
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool YES
defaults write com.apple.Safari AutoOpenSafeDownloads -bool false
defaults write com.apple.Safari IncludeDevelopMenu -bool true
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false

# --- Remove previous links
rm -f "${HOME}"/.{yabai,skhd}rc

# --- Install configs
git clone https://github.com/zer0yu/dotfiles.git "${HOME}"/.config/dotfiles
ln -s "${HOME}/.config/dotfiles/yabai/yabairc" "${HOME}/.yabairc"
ln -s "${HOME}/.config/dotfiles/skhd/skhdrc" "${HOME}/.skhdrc"
ln -s "${HOME}/.config/dotfiles/sketchybar" "${HOME}/.config/sketchybar"
ln -s "${HOME}/.config/dotfiles/alacritty/alacritty.yml" "${HOME}/.config/alacritty/alacritty.yml"
ln -s "${HOME}/.config/dotfiles/alacritty/catppuccin/catppuccin-macchiato.yml" ${HOME}/.config/alacritty/catppuccin/catppuccin-macchiato.yml
ln -s "${HOME}/.config/dotfiles/tmux/.tmux.conf" "${HOME}/.tmux.conf"
ln -s "${HOME}/.config/dotfiles/tmux/sessions/" "${HOME}/.tmux/"
ln -s "${HOME}/.config/dotfiles/tmux/themes/" "${HOME}/.tmux/"

# 需要手动修改 .yabairc 和 .skhdrc 文件中的 .sh 脚本路径

# Start Services
brew services start skhd
brew services start fyabai
brew services start sketchybar

(optional) add to .zshrc

# Sketchybar interactivity overloads
function brew() {
  command brew "$@" 

  if [[ $* =~ "upgrade" ]] || [[ $* =~ "update" ]] || [[ $* =~ "outdated" ]]; then
    sketchybar --trigger brew_update
  fi
}

# Fancy sketchybar commands
function margin () {
  if [ $1 = "on" ]; then
    yabai -m config top_padding 20
    sketchybar --animate sin 30 --bar margin=10 y_offset=10 corner_radius=9
  else
    yabai -m config top_padding 10
    sketchybar --animate sin 30 --bar margin=0 y_offset=0 corner_radius=0
  fi
}

function zen () {
  ~/.config/sketchybar/plugins/zen.sh $1
}

function suyabai () {
  SHA256=$(shasum -a 256 /opt/homebrew/bin/yabai | awk "{print \$1;}")
  sudo sed -i '' -e 's/sha256:[[:alnum:]]*/sha256:'${SHA256}'/' /private/etc/sudoers.d/yabai
}

0x02 Keyboard Shortcuts

0x21 yabai(skhd)

Reload / restart the yabai launch agent

ctrl + alt + cmd + r

Show / hide items on desktop

cmd + f3

Toggle full screen / up-full screen

alt + cmd + space

Move Windows

Action Key Combination
Move left ctrl + alt + cmd + left
Move right ctrl + alt + cmd + right
Move up ctrl + alt + cmd + up
Move down ctrl + alt + cmd + down

Focus Windows

Action Key Combination
Focus left alt + cmd + left
Focus right alt + cmd + right
Focus up alt + cmd + up
Focus down alt + cmd + down

Resize Windows

Action Key Combination
Resize left ctrl + alt + cmd + home
Resize right ctrl + alt + cmd + end
Resize up ctrl + alt + cmd + pageUp
Resize down ctrl + alt + cmd + pageDown

Stack Windows

Action Key Combination
Stack left shift + alt + cmd + left
Stack right shift + alt + cmd + right

Focus Windows (stack mode)

Action Key Combination
Focus up shift + alt + cmd + up
Focus down shift + alt + cmd + down

Toggle float / Un-float mode window

ctrl + alt + cmd + space

Move Windows (floating mode)

Action Key Combination
Move left alt + cmd + left
Move right alt + cmd + right
full screen alt + cmd + up
place window to screen center alt + cmd + down
Move up left alt + cmd + home
Move down right alt + cmd + end
Move up right alt + cmd + pageUp
Move down left alt + cmd + pageDown

Send Window to Spaces

Action Key Combination
Send to prev space ctrl + cmd + left
Send to next space ctrl + cmd + right
Send to space (1-9) ctrl + cmd + 1 - 9

Send Window to Monitors (Displays)

Action Key Combination
Send to prev monitor ctrl + alt + left
Send to next monitor ctrl + alt + right

Focus Monitors (Displays)

Action Key Combination
Focus monitor 1 ctrl + alt + 1
Focus monitor 2 ctrl + alt + 2
Focus monitor 3 ctrl + alt + 3

Misc

Action Key Combination
Window rotate clockwise alt + cmd + r
Window rotate anticlockwise shift + alt + cmd + r
Window Equalize size alt + cmd + |
Enable / Disable gaps alt + cmd + g
Float / Unfloat window cmd + spcae

Open APP

Action Key Combination
Open alacritty alt+ cmd + t
Open iTerm2 ctrl + alt + t

Set the shortcut to open APP

  1. open Automator(自动操作)

  2. 选择 “选取文稿类型”,在创建界面选择”快速操作”

  3. 创建“开启应用程序”

  4. 设置快捷键

    “系统偏好设置” => "键盘" => "服务" => "通用" => 选中添加的程序, 设置快捷键。

Ref: https://blog.csdn.net/zhanglong_4444/article/details/105172109

或者使用 keyboard maestro 来自定义一些快捷操作

0x23 keyboard maestro

Action Key Combination
清除格式粘贴 shift + alt + cmd + v

0x24 Tmux + Alacritty

Action Key Combination
基本操作
New Tab cmd + t
Close Tab ctrl + d
New vertical panel cmd + d
Close vertical panel (关闭窗格) cmd + w
水平分割窗格 cmd + Return
访问左边的窗格 cmd + h
访问左边的窗格 cmd + Left
访问上面的窗格 cmd + j
访问上面的窗格 cmd + Up
问下面的窗格 cmd + k
问下面的窗格 cmd + Down
访问右边的窗格 cmd + l
访问右边的窗格 cmd + Right
按数字切换选项卡 cmd + 1cmd + 9
切换到最近一次访问的选项卡 cmd + b
切换到上一个选项卡 cmd + [
切换到下一个选项卡 cmd + ]
切换窗口 cmd + `
布局操作
向左边的窗格推进 cmd + shift + h
向左边的窗格推进 cmd + shift + Left
向上面的窗格推进 cmd + shift + j
向上面的窗格推进 cmd + shift + Up
向下面的窗推进 cmd + shift + k
向下面的窗推进 cmd + shift + Down
向右边的窗格推进 cmd + shift + l
向右边的窗格推进 cmd + shift + Right
将窗格移动到指定的选项卡中 cmd + shift + 1cmd + shift + 9
缩放当前窗格 cmd + z
使用预设置的五种布局重新调整窗格 cmd + shift + z
修改选项卡名称 cmd + ,
输入 tmux 命令 cmd + i
调整更大的字体 cmd + +
调整更小的字体 cmd + -
恢复默认大小的字体 cmd + 0
复制模式
进入 Vi 复制模式,从上往下的方向查找关键词 cmd + f
进入 Vi 复制模式,从下往上的方向查找关键词 cmd + shift + f

补充:

v 按字选择

V 按行选择

Ctrl + v 按块状选择

Esc 取消选择

A 复制选择的文本追加到剪贴板,并退出 Vi 复制模式。

D 复制当前行到行尾的文本到剪贴板,并退出 Vi 复制模式。

y 复制选择的文本到剪贴板,并退出 Vi 复制模式。

Y 复制选择的文本到剪贴板,并保持 Vi 复制模式。

q 退出 Vi 复制模式

ref: https://juejin.cn/post/7152747783152697375

0x25 Arc Browser

Action Key Combination
打开URL或者搜索内容 cmd + t
根据网页结构截图 shift + 2
同一页面右侧分割打开某个URL ctrl + shift + =
关闭分割页面 ctrl + shift + -
同一页面右侧分割打开点击的URL alt + 鼠标点击
打开上次关闭的页面 shift + cmd + t
查看历史记录 cmd + y
关闭所有窗口 shift + cmd + w
关闭当前页面 cmd + w
切换 workspace ctrl + 数字
打开 arc 设置(注意不是 chrome) cmd + ,
复制当前页面的 URL(仅URL) shift + cmd + c
复制当前页面的 URL(markdown 格式) shift + option + c
把临时打开的小窗口加入到主浏览器里面 cmd + o
Go back cmd + [
Go forward cmd + ]
显示or隐藏侧边栏 cmd + s
DeepL插件翻译 alt + z
Immersive Translate 插件全文翻译 alt + w

0x26 For Raycast

Action Key Combination
打开Floating Notes alt + .
显示/隐藏Floating Notes alt + ,

0x27 For Zotero

Action Key Combination
打开快捷命令窗口 [zotero-style] shift + P
标记已读文献 [Zotero IF Pro Max] ctrl + 1

0x28 For Obsidian

Action Key Combination
插入双向链接 cmd + shift + K

0x29 For Notion

Action Key Combination
转换行内代码 cmd + E

0x03 Reference

https://github.com/FelixKratz/dotfiles

https://github.com/z20240/yabai

https://github.com/qingshan/dotfiles/blob/main/.tmux.conf

https://github.com/damianveltkamp/dotfiles/blob/master/tmux/.tmux.conf

https://github.com/nicknisi/dotfiles

https://github.com/ayamir/nvimdots