diff --git a/bootstrap/components/emacs.sh b/bootstrap/components/emacs.sh new file mode 100644 index 0000000..e0c8f0e --- /dev/null +++ b/bootstrap/components/emacs.sh @@ -0,0 +1,9 @@ +echo "[INFO] Installing DOOM Emacs" +echo "[ACTION] Request Human Takeover" +test -d ~/.config/emacs && mv ~/.config/emacs ~/.config/emacs.bak +git clnh https://github.com/doomemacs/doomemacs ~/.config/emacs +~/.config/emacs/bin/doom install +~/.config/emacs/bin/doom sync + +echo "[INFO] Installing Emacs-Rime" +git clnh https://github.com/js0ny/Rime.git ~/.config/emacs/.local/cache/rime diff --git a/bootstrap/components/symlinks.sh b/bootstrap/components/symlinks.sh new file mode 100644 index 0000000..018af03 --- /dev/null +++ b/bootstrap/components/symlinks.sh @@ -0,0 +1,102 @@ +set -e # Exit immediately if a command exits with a non-zero status + +DOTFILES="${DOTFILES:-$HOME/.dotfiles}" +ZDOTDIR="${ZDOTDIR:-$HOME/.config/zsh}" +XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +NPM_CONFIG_USERCONFIG="${NPM_CONFIG_USERCONFIG:-$XDG_CONFIG_HOME/npm/npmrc}" + +XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" +XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" +XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}" + +echo "[INFO] Setting up some local directories" +test -d $XDG_CACHE_HOME || mkdir -p $XDG_CACHE_HOME +test -d $XDG_DATA_HOME || mkdir -p $XDG_DATA_HOME +test -d $XDG_STATE_HOME || mkdir -p $XDG_STATE_HOME +test -d ~/.local/state/zsh || mkdir -p ~/.local/state/zsh + +# echo "[INFO] Setting up system-wide zsh configuration" +# echo "[ACTION] Elevation required!" +# test -f "/etc/zsh/zshenv" && sudo cp "$DOTFILES/tools/zsh/zshenv" "/etc/zsh/zshenv" +# test -f "/etc/zshenv" && sudo cp "$DOTFILES/tools/zsh/zshenv" "/etc/zshenv" + +declare -A linkDots + +linkDots=( + ["$DOTFILES/common/condarc.yaml"]="$XDG_CONFIG_HOME/conda/.condarc" + # ["$DOTFILES/common/gitconfig"]="$XDG_CONFIG_HOME/git/config" + ["$DOTFILES/common/glow.yaml"]="$HOME/.config/glow/config.yml" + ["$DOTFILES/common/haskeline"]="$HOME/.haskeline" + ["$DOTFILES/common/ideavimrc"]="$XDG_CONFIG_HOME/ideavim/ideavimrc" + ["$DOTFILES/common/lazygit.yaml"]="$XDG_CONFIG_HOME/lazygit/config.yml" + ["$DOTFILES/common/lesskey"]="$XDG_CONFIG_HOME/lesskey" + ["$DOTFILES/common/npmrc"]="$NPM_CONFIG_USERCONFIG" + ["$DOTFILES/common/NuGet.Config"]="$XDG_CONFIG_HOME/NuGet/NuGet.Config" + ["$DOTFILES/common/pip.conf"]="$XDG_CONFIG_HOME/pip/pip.conf" + ["$DOTFILES/common/starship.toml"]="$HOME/.config/starship.toml" + ["$DOTFILES/common/tmux.conf"]="$XDG_CONFIG_HOME/tmux/tmux.conf" + ["$DOTFILES/common/vimrc"]="$XDG_CONFIG_HOME/vim/vimrc" + ["$DOTFILES/common/zellij.config.kdl"]="$HOME/.config/zellij/config.kdl" + # ["$DOTFILES/tools/emacs.d"]="$HOME/.emacs.d" + ["$DOTFILES/tools/doom"]="$HOME/.config/doom" + ["$DOTFILES/tools/fish"]="$HOME/.config/fish" + ["$DOTFILES/tools/ipython"]="$XDG_CONFIG_HOME/ipython" + ["$DOTFILES/tools/nvim"]="$XDG_CONFIG_HOME/nvim" + ["$DOTFILES/tools/yazi"]="$HOME/.config/yazi" + ["$DOTFILES/tools/zsh/zshrc"]="$ZDOTDIR/.zshrc" + ["$DOTFILES/tools/zsh/zshenv"]="$ZDOTDIR/.zshenv" + ["$DOTFILES/platforms/mac/pwshProfile.ps1"]="$HOME/.config/powershell/Microsoft.PowerShell_profile.ps1" +) + +if [ $(uname) = "Darwin" ]; then + echo "[INFO] Running on macOS" + linkDots+=( + ["$DOTFILES/platforms/mac/karabiner"]="$HOME/.config/karabiner" + ["$DOTFILES/platforms/mac/skhdrc"]="$XDG_CONFIG_HOME/skhd/skhdrc" + ["$DOTFILES/platforms/mac/sketchybarrc"]="$XDG_CONFIG_HOME/sketchybar/sketchybarrc" + ["$DOTFILES/platforms/mac/yabairc"]="$XDG_CONFIG_HOME/yabai/yabairc" + ["$DOTFILES/tools/wezterm"]="$HOME/.config/wezterm" + ["$DOTFILES/tools/zed"]="$HOME/.config/zed" + ["$DOTFILES/tools/sioyek"]="$HOME/.config/sioyek" + ) +else + echo "[INFO] Running on Linux" + linkDots+=( + ["$DOTFILES/common/inputrc"]="$HOME/.inputrc" + ) + if [ "$(uname -r)" = *Microsoft* ]; then + echo "[INFO] Running on WSL1" + : # NOP + else + echo "[INFO] Running on Native Linux" + linkDots+=( + ["$DOTFILES/platforms/linux/awesome"]="$HOME/.config/awesome" + ["$DOTFILES/platforms/linux/hypr"]="$HOME/.config/hypr" + ["$DOTFILES/platforms/linux/waybar"]="$HOME/.config/waybar" + ["$DOTFILES/platforms/linux/wlogout"]="$HOME/.config/wlogout" + ["$DOTFILES/platforms/linux/mako-config"]="$HOME/.config/mako/config" + ["$DOTFILES/tools/wezterm"]="$HOME/.config/wezterm" + ["$DOTFILES/tools/zed"]="$HOME/.config/zed" + ["$DOTFILES/tools/sioyek"]="$HOME/.config/sioyek" + ) + for kde in "$DOTFILES/platforms/linux/kde/"*; do + linkDots+=["$kde"]="$HOME/.config/kde/$(basename $kde)" + # echo "Linking $kde to $HOME/.config/kde/$(basename $kde)" + done + echo "[INFO] Setting up system environment variables" + echo "[ACTION] Elevation required!" + sudo cp "$DOTFILES/platforms/linux/etc/environment" "/etc/environment" + fi +fi + + + +echo "[INFO] Copying example files" +test -d $XDG_CONFIG_HOME/git || mkdir -p $XDG_CONFIG_HOME/git +test -f $XDG_CONFIG_HOME/git/config && mv $XDG_CONFIG_HOME/git/config $XDG_CONFIG_HOME/git/config.bak +cp $DOTFILES/common/gitconfig.example $XDG_CONFIG_HOME/git/config +echo "[INFO] Don't forget to update your gitconfig!" + +test -f ~/.wakatime.cfg && mv ~/.wakatime.cfg ~/.wakatime.cfg.bak +cp $DOTFILES/common/wakatime.example.cfg ~/.wakatime.cfg +echo "[INFO] Don't forget to update your wakatime config!" diff --git a/bootstrap/components/zsh.sh b/bootstrap/components/zsh.sh new file mode 100644 index 0000000..793ab7c --- /dev/null +++ b/bootstrap/components/zsh.sh @@ -0,0 +1,16 @@ +echo "[INFO] ZDOTDIR = $ZDOTDIR" +echo "[INFO] DOTFILES = $DOTFILES" + +echo "[ACTION] Press any key to proceed" +read -n 1 -s -r + +echo "[INFO] Setting up system-wide zsh configuration" +echo "[ACTION] Elevation required!" +test -f "/etc/zsh/zshenv" && sudo cp "$DOTFILES/tools/zsh/zshenv" "/etc/zsh/zshenv" +test -f "/etc/zshenv" && sudo cp "$DOTFILES/tools/zsh/zshenv" "/etc/zshenv" + +echo "[INFO] Installing zsh plugins" +test -d $ZDOTDIR/plugins/zsh-autosuggestions || git clone --depth 1 https://github.com/zsh-users/zsh-autosuggestions.git $ZDOTDIR/plugins/zsh-autosuggestions +test -d $ZDOTDIR/plugins/zsh-syntax-highlighting || git clone --depth 1 https://github.com/zsh-users/zsh-syntax-highlighting.git $ZDOTDIR/plugins/zsh-syntax-highlighting +test -d $ZDOTDIR/plugins/zsh-history-substring-search || git clone --depth 1 https://github.com/zsh-users/zsh-history-substring-search.git $ZDOTDIR/plugins/zsh-history-substring-search +test -d $ZDOTDIR/plugins/zsh-completions || git clone --depth 1 https://github.com/zsh-users/zsh-completions.git $ZDOTDIR/plugins/zsh-completions diff --git a/bootstrap/macOS.zsh b/bootstrap/macOS.zsh deleted file mode 100644 index d88c98b..0000000 --- a/bootstrap/macOS.zsh +++ /dev/null @@ -1,291 +0,0 @@ -#! /bin/zsh -# $DOTFILES/bootstrap/macOS.zsh -# Run this script to set up macOS -# 运行此脚本以设置 macOS - -echo "Running the setup script" - -# Xcode Command Line Tools -echo "[INFO] Installing Xcode Command Line Tools" -echo "[ACTION] Request Human Takeover" -xcode-select --install - -# Press any key to continue (if Xcode Command Line Tools are installed) -read -n 1 -s -r -p "Press any key to continue when xcode CLI tools are installed" - -# System Preferences -# Installation Sources -echo "[INFO] Setting Installation Sources" -# sudo spctl --master-disable -# In Mac OS Sequoia, the command above is not working -# Should be set up manually (System Preferences -> Security & Privacy -> General -> Allow apps downloaded from: Anywhere) -## Finder -echo "[INFO] Setting Finder Preferences" -defaults write com.apple.finder QuitMenuItem -bool true # Quit with CMD+Q -defaults write com.apple.finder AppleShowAllFiles -bool false # Don't show Hidden Files -defaults write com.apple.finder ShowPathbar -bool true # Show Path Bar -defaults write com.apple.finder ShowStatusBar -bool true # Show Status Bar -defaults write NSGlobalDomain AppleShowAllExtensions -bool true # Show All File Extensions -defaults write com.apple.finder AppleShowAllFiles -bool true # Show Hidden Files -defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Documents" # Open New Finder Windows in Documents -defaults write com.apple.finder _FXSortFoldersFirst -bool true -defaults write com.apple.finder FinderSpawnTab -bool true -# Don't show External Hard Drives on Desktop -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 -# No DS_Store on Network -defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true -# Keyboard -# Disable Accent Menu -defaults write NSGlobalDomain ApplePressAndHoldEnabled -boolean false -killall Finder -killall Dock -## Dock -echo "[INFO] Setting Dock Preferences" -defaults write com.apple.dock persistent-apps -array -defaults write com.apple.dock persistent-others -array -defaults write com.apple.dock autohide -bool true # Autohide Dock -defaults write com.apple.dock autohide-time-modifier -float 0.5 -defaults write com.apple.dock autohide-delay -float 0 # Immediately Autohide Dock -defaults write com.apple.dock show-recents -bool false # Hide Recent Applications -killall Dock -## Trackpad -echo "[INFO] Setting Trackpad Preferences" -defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerDrag -bool true -defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -bool true -defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true -defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true -# Development # -### Dotfiles Setup ### -echo "[INFO] Setting Up Dotfiles" -export DOTFILES="$HOME/.dotfiles" -git clone https://www.github.com/js0ny/dotfiles.git ~/.dotfiles -sudo cp ~/.dotfiles/zsh/.zshenv /etc/zshenv -echo "[INFO] 'source etc/zshenv' to use XDG_CONFIG_HOME" -source /etc/zshenv - # export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" - # export ZDOTDIR="${XDG_CONFIG_HOME}/zsh" -echo "[INFO] Setting Up Zsh for Initial Use" -mkdir -p $ZDOTDIR -ln -sf $DOTFILES/zsh/.zshenv $ZDOTDIR/.zshenv -ln -sf $DOTFILES/mac/.zshrc $ZDOTDIR/.zshrc -mv ~/.zprofile $ZDOTDIR/.zprofile -source $ZDOTDIR/.zshrc -# sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" -mkdir -p $ZDOTDIR/plugins -git clone https://github.com/zsh-users/zsh-autosuggestions $ZDOTDIR/plugins/zsh-autosuggestions -git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZDOTDIR/plugins/zsh-syntax-highlighting -source /etc/zshenv -source $ZDOTDIR/.zshrc -rm -f ~/.zshrc ~/.zprofile ~/.zsh_history ~/.zshenv -rm -rf ~/.zsh_sessions - -echo "[INFO] Setting Up dotfiles" -. $DOTFILES/setup/set_symblink_unix.sh -# $DOTFILES/mac -ln -sf $DOTFILES/mac/neovide.toml $XDG_CONFIG_HOME/neovide/config.toml -ln -sf $DOTFILES/mac/Microsoft.PowerShell_profile.ps1 $XDG_CONFIG_HOME/powershell/Microsoft.PowerShell_profile.ps1 - -# Brew -echo "[INFO] Installing Homebrew" -echo "[ACTION] Request Human Input" -/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -echo "[INFO] Installing Softwares" -# Tap -brew tap daipeihust/tap # for `im-select` -brew tap homebrew/cask-fonts - -brew install mas # Mac App Store CLI - - -# CLI -# brew install --formula cfiles # Not Available -# File Management -brew install --formula bat -brew install --formula fzf -brew install --formula glow # Markdown Preview -brew install --formula less # Pager, overwrites system less, no XDG support -brew install --formula ripgrep -brew install --formula tree -brew install --formula lsd -# Network -brew install --formula wget -brew install --formula wget2 -brew install --formula speedtest-cli -# Development -brew install --formula cmake -brew install --formula lazygit -# Shell -brew install --formula starship # Shell Prompt -brew install --formula tmux -brew install --formula zellij -# System Info -brew install --formula fastfetch # 這輩子有了 -# Utilities -brew install --formula ffmpeg -brew install --formula daipeihust/tap/im-select # IME Selector (for Vim modes) -brew install --formula pandoc -brew install --formula tldr - -# File Management -brew install --cask keka # Archiver -brew install --cask google-drive # `sudo` # Cloud Storage - -# Editors -brew install --formula vim # Overwrite System Vim since no XDG support -brew install --cask visual-studio-code -brew install --formula neovim -brew install --formula neovide - -# IDE -brew install --cask qt-creator -brew install --cask rider - -# Programming Languages -brew install --formula lua -brew install --formula luajit -brew install --formula luarocks -brew install --formula node -brew install --formula dotnet -brew install --formula go -# brew install --formula rust -brew install --cask miniconda - -# PowerShells -brew install --cask powershell # `sudo` - -# Launchers -brew install --cask raycast -brew install --cask utools - -# Terminals -brew install --cask iterm2 - - -# IME -brew install --cask squirrel # `sudo` - -# PKM -brew install --cask obsidian -brew install --cask typora -brew install --cask notion -brew install --cask notion-calendar - -# Media -brew install --cask iina - -# Security -brew install --cask keyguard -brew install --cask protonmail-bridge - -# Engineering -brew install --cask ltspice # `sudo` - -# Office -brew install --cask mactex-no-gui - -# Browser -brew install --cask microsoft-edge # Default -brew install --cask arc -brew install --cask firefox@nightly - -# Fonts -brew install --cask font-caskaydia-cove-nerd-font -brew install --cask font-lxgw-wenkai - -# Quick Look -brew install --cask qlcolorcode qlstephen qlmarkdown quicklook-json qlimagesize suspicious-package apparency quicklookase qlvideo - -# Utilities -brew install --cask rustdesk -# brew install --cask logi-options+ # NBCS -mas install 1452453066 # Hidden Bar -brew install ticktick # To-do List -brew install --cask zotero # Reference Manager -brew install --cask betterdisplay -brew install --cask karabiner-elements # Keyboard Customization -brew install --cask scroll-reverser # Let Trackpad and Mouse Scroll in the Same Direction like Windows -# brew install --cask orbstack # VM -# brew install --cask docker -brew install --cask clash-verge-rev -brew install --cask chatbox # LLM API Caller -brew install --cask follow # RSS Reader - - -# Social -brew install --cask telegram-desktop -mas install 836500024 # WeChat -mas install 451108668 # QQ - -# plum (Rime IME) -curl -fsSL https://raw.githubusercontent.com/rime/plum/master/rime-install -o $HOME | bash - -# Set default apps (duti) -# The id of the app can be found by running -# `osascript -e 'id of app "AppName"'` -brew install --formula duti -echo "[INFO] Setting Default Apps" -# Markdown -> Typora -duti -s abnerworks.Typora .md all -duti -s abnerworks.Typora .markdown all -# PDF -> Skim -duti -s net.sourceforge.skim-app.skim .pdf all -# Raw Text -> Neovide -duti -s com.neovide.neovide .txt all -# Archive -> Keka -duti -s com.aone.keka .zip all -duti -s com.aone.keka .rar all -duti -s com.aone.keka .7z all -duti -s com.aone.keka .tar all -# Source Code Light -> Neovim -duti -s com.neovide.neovide .gitingore all -duti -s com.neovide.neovide .vimrc all -duti -s com.neovide.neovide .vim all -duti -s com.neovide.neovide .lua all -duti -s com.neovide.neovide .py all -duti -s com.neovide.neovide .jl all -# Source Code Heavy -> VSCode -duti -s com.microsoft.VSCode .c all -# Source Code DOTNET -> VSCode -duti -s com.microsoft.VSCode .cs all -duti -s com.microsoft.VSCode .fs all -duti -s com.microsoft.VSCode .fsx all -duti -s com.microsoft.VSCode .csx all -duti -s com.microsoft.VSCode .ps1 all -# Source Code Web -> VSCode -duti -s com.microsoft.VSCode .js all -duti -s com.microsoft.VSCode .ts all -duti -s com.microsoft.VSCode .jsx all -duti -s com.microsoft.VSCode .tsx all -duti -s com.microsoft.VSCode .css all -duti -s com.microsoft.VSCode .scss all -duti -s com.microsoft.VSCode .sass all -duti -s com.microsoft.VSCode .vue all -# Source Code Config -> Neovim -duti -s com.neovide.neovide .json all -duti -s com.neovide.neovide .yaml all -duti -s com.neovide.neovide .yml all -duti -s com.neovide.neovide .toml all -duti -s com.neovide.neovide .ini all -duti -s com.neovide.neovide .cfg all -duti -s com.neovide.neovide .conf all -duti -s com.neovide.neovide .kdl all -duti -s com.neovide.neovide .xml all -# Source Code Jupyter -> VSCode -duti -s com.microsoft.VSCode .ipynb all -# Source Code DotNet Project -> Rider -duti -s com.jetbrains.rider .sln all -duti -s com.jetbrains.rider .csproj all -duti -s com.jetbrains.rider .fsproj all -# Video -> IINA -duti -s com.colliderli.iina .mp4 all -duti -s com.colliderli.iina .mkv all - -mkdir -p $DOTFILES/powershell_private - -mkdir -p ~/Documents/Source/Forks -mkdir -p ~/Documents/Source/Projects -mkdir -p ~/Documents/Source/Scripts -mkdir -p ~/Documents/Source/Tutorials diff --git a/bootstrap/macOS/Brewfile b/bootstrap/macOS/Brewfile new file mode 100644 index 0000000..ab56c89 --- /dev/null +++ b/bootstrap/macOS/Brewfile @@ -0,0 +1,150 @@ +tap "daipeihust/tap" +tap "felixkratz/formulae" +tap "homebrew/bundle" +tap "homebrew/services" +tap "koekeishiya/formulae" +tap "nikitabobko/tap" +tap "railwaycat/emacsmacport" +brew "age" +brew "aichat" +brew "bat" +brew "bottom" +brew "broot" +brew "btop" +brew "cmake" +brew "composer" +brew "coreutils" +brew "curlie" +brew "dark-mode" +brew "dos2unix" +brew "duf" +brew "dust" +brew "duti" +brew "fastfetch" +brew "fd" +brew "ffmpeg" +brew "fish" +brew "fzf" +brew "gh" +brew "ghcup" +brew "git-delta" +brew "glow" +brew "go" +brew "hugo" +brew "hyperfine" +brew "imagemagick" +brew "ipython" +brew "julia" +brew "just" +brew "lazygit" +brew "less" +brew "pkgconf" +brew "lua" +brew "librime" +brew "lsd" +brew "luajit" +brew "luarocks" +brew "macvim", link: false +brew "node" +brew "markdownlint-cli" +brew "mas" +brew "neovim" +brew "nowplaying-cli" +brew "nushell" +brew "openjdk@21" +brew "pandoc" +brew "pipx" +brew "pnpm" +brew "procs" +brew "ripgrep" +brew "ripgrep-all" +brew "rlwrap" +brew "rust" +brew "rustup" +brew "screenfetch" +brew "sd" +brew "sevenzip" +brew "speedtest-cli" +brew "starship" +brew "switchaudio-osx" +brew "tldr" +brew "tmux" +brew "tree" +brew "uv" +brew "vim" +brew "wget" +brew "wget2" +brew "yarn" +brew "yazi" +brew "zellij" +brew "zoxide" +brew "daipeihust/tap/im-select" +brew "felixkratz/formulae/borders" +brew "felixkratz/formulae/sketchybar" +brew "koekeishiya/formulae/skhd" +brew "koekeishiya/formulae/yabai" +brew "railwaycat/emacsmacport/emacs-mac" +cask "activitywatch" +cask "alacritty" +cask "alex313031-thorium" +cask "alt-tab" +cask "apparency" +cask "appcleaner" +cask "arc" +cask "betterdisplay" +cask "chatgpt" +cask "discord" +cask "dotnet-sdk" +cask "font-caskaydia-cove-nerd-font" +cask "font-iosevka-nerd-font" +cask "font-jetbrains-mono-nerd-font" +cask "font-lxgw-wenkai" +cask "font-sf-mono" +cask "font-sf-pro" +cask "google-drive" +cask "iina" +cask "iterm2" +cask "jordanbaird-ice" +cask "karabiner-elements" +cask "keka" +cask "keyguard" +cask "kitty" +cask "localsend" +cask "ltspice" +cask "macfuse" +cask "neovide" +cask "obsidian" +cask "onedrive" +cask "orbstack" +cask "powershell" +cask "protonvpn" +cask "qlcolorcode" +cask "qlimagesize" +cask "qlmarkdown" +cask "qlstephen" +cask "qlvideo" +cask "qspace-pro" +cask "quicklook-json" +cask "quicklookase" +cask "r" +cask "raycast" +cask "rider" +cask "rstudio" +cask "rustdesk" +cask "scroll-reverser" +cask "sf-symbols" +cask "sioyek" +cask "skim" +cask "squirrel" +cask "steam" +cask "suspicious-package" +cask "telegram-desktop" +cask "typora" +cask "visual-studio-code" +cask "vivaldi" +cask "warp" +cask "wezterm" +cask "zen-browser" +mas "QQ", id: 451108668 +mas "SnippetsLab", id: 1006087419 +mas "微信", id: 836500024 diff --git a/bootstrap/macOS/duti.zsh b/bootstrap/macOS/duti.zsh new file mode 100644 index 0000000..740b8c5 --- /dev/null +++ b/bootstrap/macOS/duti.zsh @@ -0,0 +1,62 @@ +# Set default apps (duti) +# The id of the app can be found by running +# `osascript -e 'id of app "AppName"'` +brew install --formula duti +echo "[INFO] Setting Default Apps" +# Markdown -> Typora +duti -s abnerworks.Typora .md all +duti -s abnerworks.Typora .markdown all +# PDF -> Sioyek +duti -s info.sioyek.sioyek .pdf all +# Raw Text -> Neovide +duti -s com.neovide.neovide .txt all +# Archive -> Keka +duti -s com.aone.keka .zip all +duti -s com.aone.keka .rar all +duti -s com.aone.keka .7z all +duti -s com.aone.keka .tar all +# Source Code Light -> Neovim +duti -s com.neovide.neovide .gitignore all +duti -s com.neovide.neovide .vimrc all +duti -s com.neovide.neovide .vim all +duti -s com.neovide.neovide .lua all +duti -s com.neovide.neovide .py all +duti -s com.neovide.neovide .jl all +duti -s com.neovide.neovide .sh all +duti -s com.neovide.neovide .c all +# Source Code DOTNET -> VSCode +duti -s com.microsoft.VSCode .cs all +duti -s com.microsoft.VSCode .fs all +duti -s com.microsoft.VSCode .fsx all +duti -s com.microsoft.VSCode .csx all +duti -s com.microsoft.VSCode .ps1 all +# Source Code Web -> VSCode +duti -s com.microsoft.VSCode .js all +duti -s com.microsoft.VSCode .ts all +duti -s com.microsoft.VSCode .jsx all +duti -s com.microsoft.VSCode .tsx all +duti -s com.microsoft.VSCode .css all +duti -s com.microsoft.VSCode .scss all +duti -s com.microsoft.VSCode .sass all +duti -s com.microsoft.VSCode .vue all +# Source Code Config -> Neovim +duti -s com.neovide.neovide .json all +duti -s com.neovide.neovide .yaml all +duti -s com.neovide.neovide .yml all +duti -s com.neovide.neovide .toml all +duti -s com.neovide.neovide .ini all +duti -s com.neovide.neovide .cfg all +duti -s com.neovide.neovide .conf all +duti -s com.neovide.neovide .kdl all +duti -s com.neovide.neovide .xml all +# Source Code Jupyter -> VSCode +duti -s com.microsoft.VSCode .ipynb all +# Source Code DotNet Project -> Rider +duti -s com.jetbrains.rider .sln all +duti -s com.jetbrains.rider .csproj all +duti -s com.jetbrains.rider .fsproj all +# Video -> IINA +duti -s com.colliderli.iina .mp4 all +duti -s com.colliderli.iina .mkv all + +mkdir -p $DOTFILES/powershell_private diff --git a/bootstrap/macOS/main.zsh b/bootstrap/macOS/main.zsh new file mode 100644 index 0000000..33590cb --- /dev/null +++ b/bootstrap/macOS/main.zsh @@ -0,0 +1,88 @@ +#! /bin/zsh + +echo "Running the setup script" + +# VARIABLES + +export DOTFILES="${DOTFILES:-$HOME/.dotfiles}" + + +# Xcode Command Line Tools +echo "[INFO] Installing Xcode Command Line Tools" +echo "[ACTION] Request Human Takeover" + +xcode-select --install + +# Press any key to continue (if Xcode Command Line Tools are installed) +read -n 1 -s -r -p "Press any key to continue when xcode CLI tools are installed" + +# System Preferences +# Installation Sources +echo "[INFO] Setting Installation Sources" +echo "[ACTION] Request Human Takeover" +echo "In macOS Sequoia, setup manually (System preferences -> Security & Privacy -> General -> Allow apps downloaded from: Anywhere)" +# sudo spctl --master-disable +# In Mac OS Sequoia, the command above is not working +# Should be set up manually (System Preferences -> Security & Privacy -> General -> Allow apps downloaded from: Anywhere) + +echo "[INFO] Installing Homebrew" +echo "[ACTION] Request Human Input" +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + +read -n 1 -s -r -p "Press any key to continue when xcode CLI tools are installed" + +echo "[INFO] Cloning Dotfiles" + +git clone https://github.com/js0ny/dotfiles.git $DOTFILES + +echo "[INFO] Setting up system properties" + +source $DOTFILES/bootstrap/macOS/plist.zsh + +echo "[INFO] Installing Homebrew Packages" + +# Load Brewfile +eval "$(/opt/homebrew/bin/brew shellenv)" +brew bundle --file=$DOTFILES/bootstrap/macOS/Brewfile + +# Setting Default Apps + +source $DOTFILES/bootstrap/macOS/duti.zsh + +# Setting up Dotfiles + +source $DOTFILES/bootstrap/macOS/symlinks.zsh +source $DOTFILES/bootstrap/components/zsh.sh + +source $DOTFILES/tools/zsh/global.zshenv +source $DOTFILES/tools/zsh/zshenv +source $DOTFILES/tools/zsh/zshrc + +# Rime + +echo "[INFO] Installing Rime" + +git clone --depth 1 https://github.com/js0ny/Rime.git ~/Library/Rime +cd ~/Library/Rime + +just set_remote +just clone_plum + +echo "[INFO] Installing Doom Emacs" + +source $DOTFILES/bootstrap/components/emacs.sh + + +echo "[INFO] Installing Color Scheme (Catppuccin Mocha)" + +fish $DOTFILES/bootstrap/temp/mocha_port.fish + +# Misc + + +dotnet tool install --global dotnet-repl + +pnpm install -g typescript +pnpm install -g tsx + +echo "Done!" diff --git a/bootstrap/macOS/plist.zsh b/bootstrap/macOS/plist.zsh new file mode 100644 index 0000000..fa043e5 --- /dev/null +++ b/bootstrap/macOS/plist.zsh @@ -0,0 +1,37 @@ +## Finder +echo "[INFO] Setting Finder Preferences" +defaults write com.apple.finder QuitMenuItem -bool true # Quit with CMD+Q +defaults write com.apple.finder ShowPathbar -bool true # Show Path Bar +defaults write com.apple.finder ShowStatusBar -bool true # Show Status Bar +defaults write NSGlobalDomain AppleShowAllExtensions -bool true # Show All File Extensions +defaults write com.apple.finder AppleShowAllFiles -bool true # Show Hidden Files +defaults write com.apple.finder _FXSortFoldersFirst -bool true +defaults write com.apple.finder FinderSpawnTab -bool true +# Don't show External Hard Drives on Desktop +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 +# No DS_Store on Network +defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true +# Keyboard +# Disable Accent Menu +defaults write NSGlobalDomain ApplePressAndHoldEnabled -boolean false +killall Finder +killall Dock +## Dock +echo "[INFO] Setting Dock Preferences" +defaults write com.apple.dock persistent-apps -array +defaults write com.apple.dock persistent-others -array +defaults write com.apple.dock autohide -bool true # Autohide Dock +defaults write com.apple.dock autohide-time-modifier -float 0.5 +defaults write com.apple.dock autohide-delay -float 0 # Immediately Autohide Dock +defaults write com.apple.dock show-recents -bool false # Hide Recent Applications +killall Dock +## Trackpad +echo "[INFO] Setting Trackpad Preferences" +defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerDrag -bool true +defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -bool true +defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true +defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true +defaults write -g NSWindowShouldDragOnGesture -bool true diff --git a/bootstrap/macOS/symlinks.zsh b/bootstrap/macOS/symlinks.zsh new file mode 100644 index 0000000..416d174 --- /dev/null +++ b/bootstrap/macOS/symlinks.zsh @@ -0,0 +1,30 @@ +set -e # Exit immediately if a command exits with a non-zero status + +# 声明为关联数组 +typeset -A linkDots + +# 从通用配置文件加载 +source "$DOTFILES/bootstrap/components/symlinks.sh" + +echo "[INFO] DOTFILES = $DOTFILES" + +echo "[ACTION] Press any key to proceed" +read -n 1 + +echo "[INFO] Setting up symbolic links" +# 使用 zsh 的关联数组语法 +for src in ${(k)linkDots}; do + dest="${linkDots[$src]}" + echo "Linking $src to $dest" + # if [ -d "$src" ]; then + # test -d $dest && mv $dest $dest.bak + # mkdir -p $dest + # ln -sf $src $dest + # elif [ -f "$src" ]; then + # dest_parent=$(dirname $dest) + # test -d $dest_parent || mkdir -p $dest_parent + # ln -sf $src $dest + # else + # echo "[ERROR] $src does not exist" + # fi +done diff --git a/bootstrap/set_symlink_unix.sh b/bootstrap/set_symlink_unix.sh index f7269be..1f4f4b4 100644 --- a/bootstrap/set_symlink_unix.sh +++ b/bootstrap/set_symlink_unix.sh @@ -42,7 +42,7 @@ linkDots=( ["$DOTFILES/tools/ipython"]="$XDG_CONFIG_HOME/ipython" ["$DOTFILES/tools/nvim"]="$XDG_CONFIG_HOME/nvim" ["$DOTFILES/tools/yazi"]="$HOME/.config/yazi" - ["$DOTFILES/tools/zsh/common.zshrc"]="$ZDOTDIR/.zshrc" + ["$DOTFILES/tools/zsh/zshrc"]="$ZDOTDIR/.zshrc" ["$DOTFILES/tools/zsh/zshenv"]="$ZDOTDIR/.zshenv" ["$DOTFILES/platforms/mac/pwshProfile.ps1"]="$HOME/.config/powershell/Microsoft.PowerShell_profile.ps1" ) diff --git a/bootstrap/setup.sh b/bootstrap/setup.sh new file mode 100644 index 0000000..0bbc212 --- /dev/null +++ b/bootstrap/setup.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# Date: 2025-02-11 +# Author: js0ny +# IMPORTANT: The default `bash` in macOS is outdated, run with zsh or install the latest `bash` via Homebrew +# If you are macOS, run `xcode select --install` first + +set -e # Exit immediately if a command exits with a non-zero status + +DOTFILES="${DOTFILES:-$HOME/.dotfiles}" + +mkdir -p ~/.local/.tmp + +export DOTFILES + +case "$(uname)" in + Linux) + : + Darwin) + curl https://raw.githubusercontent.com/js0ny/dotfiles/refs/heads/master/bootstrap/macOS/main.zsh -o ~/.local/.tmp/main.zsh + zsh ~/.local/.tmp/main.zsh + rm -rf ~/.local/.tmp/main.zsh +esac diff --git a/tools/fish/conf.d/alias.fish b/tools/fish/conf.d/alias.fish index 9fb59c1..7f3c6f2 100644 --- a/tools/fish/conf.d/alias.fish +++ b/tools/fish/conf.d/alias.fish @@ -7,6 +7,27 @@ # Linking: Link the whole directory for submodules # ln -sf $DOTFILES/tools/fish ~/.config/fish + +switch (uname) +case "Darwin" + # macOS Specific + abbr --add clip pbcopy + abbr --add paste pbpaste + # Use GNU Coreutils + alias cp=gcp + alias ln=gln + alias mkdir=gmkdir + alias mv=gmv + alias rm=grm + alias rmdir=grmdir + alias touch=gtouch + abbr --add reboot "sudo reboot" +case "Linux" + # Linux Specific +case '*' + # Default / Fallback case +end + # Powershell equivalent abbr --add ni touch abbr --add cls clear diff --git a/tools/fish/config.fish b/tools/fish/config.fish index d794ca3..6a1a6bb 100644 --- a/tools/fish/config.fish +++ b/tools/fish/config.fish @@ -11,25 +11,6 @@ if status is-interactive # Commands to run in interactive sessions can go here set fish_greeting - switch (uname) - case "Darwin" - # macOS Specific - abbr --add clip pbcopy - abbr --add paste pbpaste - # Use GNU Coreutils - alias cp=gcp - alias ln=gln - alias mkdir=gmkdir - alias mv=gmv - alias rm=grm - alias rmdir=grmdir - alias touch=gtouch - - case "Linux" - # Linux Specific - case '*' - # Default / Fallback case - end end # bun diff --git a/tools/zsh/common.zshrc b/tools/zsh/zshrc similarity index 100% rename from tools/zsh/common.zshrc rename to tools/zsh/zshrc