diff --git a/.github/workflows/shell-check.yml b/.github/workflows/shell-check.yml new file mode 100644 index 0000000..65c11c6 --- /dev/null +++ b/.github/workflows/shell-check.yml @@ -0,0 +1,68 @@ +name: Shell Script Check & Format + +on: + push: + paths: + - '**.sh' + - '**.bash' + - '**.zsh' + - '**.bashrc' + - 'justfile' + pull_request: + paths: + - '**.sh' + - '**.bash' + - '**.zsh' + - '**.bashrc' + - 'justfile' + +jobs: + shell-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install just + uses: extractions/setup-just@v2 + + - name: Install shellcheck + run: | + sudo apt-get update + sudo apt-get install -y shellcheck + + - name: Install go + uses: actions/setup-go@v5 + with: + go-version: '>=1.17.0' + - run: go version + # run: | + # sudo apt-get update + # sudo apt-get install -y go + + - name: Install shfmt + run: | + go install mvdan.cc/sh/v3/cmd/shfmt@latest + echo "$HOME/go/bin" >> $GITHUB_PATH + + - name: fish-actions/install-fish + uses: fish-actions/install-fish@v1.1.0 + + - name: Run shell script check + run: just check + + - name: Run shell script format + run: just format + + - name: Check for changes + id: git-check + run: | + git diff --exit-code || echo "format_changes=true" >> $GITHUB_OUTPUT + + - name: Commit changes + if: steps.git-check.outputs.format_changes == 'true' + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add -A + git commit -m "style: format shell scripts" + git push diff --git a/Justfile b/Justfile index 675329d..fbf5d52 100644 --- a/Justfile +++ b/Justfile @@ -1,6 +1,16 @@ set shell := ["fish", "-c"] set windows-shell := ["pwsh", "-c"] +check_info: + shellcheck -x -s sh ./bootstrap/**/*.sh + shellcheck -x -s bash **/*.bash tools/bash/* scripts/*.{sh,zsh,bash} **/*.bashrc +check: + shellcheck -x -s sh --severity=error ./bootstrap/**/*.sh + shellcheck -x -s bash --severity=error **/*.bash tools/bash/* **/*.bashrc +format: + # shfmt -w -d -i 2 -ci -bn **/*.sh tools/bash/* scripts/*.{sh,bash,zsh} **/*.bashrc + shfmt -w -d -i 2 -ci -bn -p ./bootstrap/**/*.sh + shfmt -w -d -i 2 -ci -bn -ln bash ./bootstrap/**/*.bash pull: git pull github master git pull codeberg master diff --git a/bootstrap/common-pm.txt b/bootstrap/common-pm.txt deleted file mode 100644 index c7c52a4..0000000 --- a/bootstrap/common-pm.txt +++ /dev/null @@ -1,17 +0,0 @@ -# nodejs -npm install -g typescript -npm install -g tsx - -# dotnet -dotnet tool install -g dotnet-script -dotnet tool install -g dotnet-repl - -# python -pip install neovim -pip install requests -pip install ipython -pip install jupyter -pip install numpy -pip install matplotlib -pip install pandas -pip install scipy diff --git a/bootstrap/components/emacs.sh b/bootstrap/components/emacs.sh index e0c8f0e..1784a0a 100644 --- a/bootstrap/components/emacs.sh +++ b/bootstrap/components/emacs.sh @@ -1,9 +1,11 @@ +#!/bin/sh +# shellcheck shell=sh 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 +git clone --depth 1 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 +git clone --depth 1 https://github.com/js0ny/Rime.git ~/.config/emacs/.local/cache/rime diff --git a/bootstrap/temp/setup_powershell.ps1 b/bootstrap/components/pwsh.ps1 similarity index 100% rename from bootstrap/temp/setup_powershell.ps1 rename to bootstrap/components/pwsh.ps1 diff --git a/bootstrap/components/rime.sh b/bootstrap/components/rime.sh index 8e951a2..85af366 100644 --- a/bootstrap/components/rime.sh +++ b/bootstrap/components/rime.sh @@ -1,4 +1,3 @@ - echo "[INFO] Installing Rime" git clone --depth 1 https://github.com/js0ny/rime_wanxiang_pro.git ~/Library/Rime @@ -8,4 +7,3 @@ just init # just install_rime ## Rime is installed via Brewfile just clone_plum - diff --git a/bootstrap/components/symlinks.bash b/bootstrap/components/symlinks.bash new file mode 100644 index 0000000..1ddb99b --- /dev/null +++ b/bootstrap/components/symlinks.bash @@ -0,0 +1,110 @@ +#!/usr/bin/env bash +# vim:ft=bash +# shellcheck disable=SC1090 shell=bash +# This should be run with bash > 4.0 or zsh +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}" +GUI_SETUP="${GUI_SETUP:-1}" +WHEEL="${WHEEL:-0}" + +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" + ) + # WSL1 : Microsoft + # WSL2 : microsoft + # if [ "$(uname -r)" = *icrosoft* ]; then + # echo "[INFO] Running on WSL" + # : # NOP + if [ "$GUI_SETUP" -eq 1 ]; then + echo "[INFO] Setting up Linux GUI Applications" + 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 + if [ "$WHEEL" -eq 1 ]; then + echo "[INFO] Setting up system environment variables" + echo "[ACTION] Elevation required!" + sudo cp "$DOTFILES/platforms/linux/etc/environment" "/etc/environment" + fi + 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/symlinks.sh b/bootstrap/components/symlinks.sh deleted file mode 100644 index c46024b..0000000 --- a/bootstrap/components/symlinks.sh +++ /dev/null @@ -1,109 +0,0 @@ -# This should be run with bash > 4.0 or zsh -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}" -GUI_SETUP="${GUI_SETUP:-1}" -WHEEL="${WHEEL:-0}" - -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" - ) - # WSL1 : Microsoft - # WSL2 : microsoft - # if [ "$(uname -r)" = *icrosoft* ]; then - # echo "[INFO] Running on WSL" - # : # NOP - if [ "$GUI_SETUP" -eq 1 ]; then - echo "[INFO] Setting up Linux GUI Applications" - 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 - if [ "$WHEEL" -eq 1 ]; then - echo "[INFO] Setting up system environment variables" - echo "[ACTION] Elevation required!" - sudo cp "$DOTFILES/platforms/linux/etc/environment" "/etc/environment" - fi - 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 index eb7e081..128ead0 100644 --- a/bootstrap/components/zsh.sh +++ b/bootstrap/components/zsh.sh @@ -7,22 +7,20 @@ echo "[INFO] WHEEL = $WHEEL" echo "[ACTION] Press any key to proceed" read -n 1 - if [ "$WHEEL" -eq 1 ]; then - echo "[INFO] Setting up system-wide zsh configuration" - echo "[ACTION] Elevation required" - test -f "/etc/zsh/zshenv" && sudo cp "$DOTFILES/tools/zsh/global.zshenv" "/etc/zsh/zshenv" - test -f "/etc/zshenv" && sudo cp "$DOTFILES/tools/zsh/global.zshenv" "/etc/zshenv" - if [ $(uname) = "Darwin" ]; then - sudo cp "$DOTFILES/tools/zsh/global.zshenv" "/etc/zshenv" - fi + echo "[INFO] Setting up system-wide zsh configuration" + echo "[ACTION] Elevation required" + test -f "/etc/zsh/zshenv" && sudo cp "$DOTFILES/tools/zsh/global.zshenv" "/etc/zsh/zshenv" + test -f "/etc/zshenv" && sudo cp "$DOTFILES/tools/zsh/global.zshenv" "/etc/zshenv" + if [ $(uname) = "Darwin" ]; then + sudo cp "$DOTFILES/tools/zsh/global.zshenv" "/etc/zshenv" + fi else - echo "[INFO] Setting up user zsh configuration" - # A fallback case to set $ZDOTDIR in ~/.zshenv if the user cannot access global zshenv - ln -sf "$DOTFILES/tools/zsh/zshenv" "$HOME/.zshenv" + echo "[INFO] Setting up user zsh configuration" + # A fallback case to set $ZDOTDIR in ~/.zshenv if the user cannot access global zshenv + ln -sf "$DOTFILES/tools/zsh/zshenv" "$HOME/.zshenv" fi - 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 diff --git a/bootstrap/linux/appman.bash b/bootstrap/linux/appman.bash index 3525925..4de1113 100644 --- a/bootstrap/linux/appman.bash +++ b/bootstrap/linux/appman.bash @@ -1,3 +1,5 @@ +#!/usr/bin/env bash +# vim:ft=bash echo "[INFO] Installing AppMan" echo "[ACTION] Type [2] to install AppMan" wget -q https://raw.githubusercontent.com/ivan-hc/AM/main/AM-INSTALLER && chmod a+x ./AM-INSTALLER && ./AM-INSTALLER @@ -5,6 +7,6 @@ wget -q https://raw.githubusercontent.com/ivan-hc/AM/main/AM-INSTALLER && chmod APPMAN_PATH="$HOME/.local/bin/appman" if command -v $APPMAN_PATH >/dev/null 2>&1; then - $APPMAN_PATH install wezterm - $APPMAN_PATH install nvim + $APPMAN_PATH install wezterm + $APPMAN_PATH install nvim fi diff --git a/bootstrap/linux/chromium-flags.bash b/bootstrap/linux/chromium-flags.bash index dd8dd68..01731a7 100755 --- a/bootstrap/linux/chromium-flags.bash +++ b/bootstrap/linux/chromium-flags.bash @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +# vim:ft=bash # chromium-flags.sh # Set Chromium & Electron Flags @@ -12,35 +13,34 @@ ELECTRON_FLAG=$DOTFILES/platforms/linux/electron-flags.conf # Browser Flags browser_flags_path=( - "$XDG_CONFIG_HOME/chromium-flags.conf" # Chromium - "$XDG_CONFIG_HOME/chrome-flags.conf" # Google Chrome - "$XDG_CONFIG_HOME/thorium-flags.conf" # Thorium - "$XDG_CONFIG_HOME/vivaldi-flags.conf" # Vivaldi - "$XDG_CONFIG_HOME/vivaldi-stable.conf" # Vivaldi + "$XDG_CONFIG_HOME/chromium-flags.conf" # Chromium + "$XDG_CONFIG_HOME/chrome-flags.conf" # Google Chrome + "$XDG_CONFIG_HOME/thorium-flags.conf" # Thorium + "$XDG_CONFIG_HOME/vivaldi-flags.conf" # Vivaldi + "$XDG_CONFIG_HOME/vivaldi-stable.conf" # Vivaldi ) electron_flags_path=( - "$XDG_CONFIG_HOME/electron-flags.conf" # General - "$XDG_CONFIG_HOME/code-flags.conf" # VSCode - "$XDG_CONFIG_HOME/qq-electron-flags.conf" # Slack + "$XDG_CONFIG_HOME/electron-flags.conf" # General + "$XDG_CONFIG_HOME/code-flags.conf" # VSCode + "$XDG_CONFIG_HOME/qq-electron-flags.conf" # Slack ) for path in "${browser_flags_path[@]}"; do - if [ -f "$path" ]; then - echo "[INFO] Found Browser Flags: $path" - else - echo "[INFO] Creating Browser Flags: $path" - ln -s $BROWSER_FLAG $path - fi + if [ -f "$path" ]; then + echo "[INFO] Found Browser Flags: $path" + else + echo "[INFO] Creating Browser Flags: $path" + ln -s $BROWSER_FLAG $path + fi done - for path in "${electron_flags_path[@]}"; do - if [ -f "$path" ]; then - echo "[INFO] Found Electron Flags: $path" - else - echo "[INFO] Creating Electron Flags: $path" - ln -s $ELECTRON_FLAG $path - fi + if [ -f "$path" ]; then + echo "[INFO] Found Electron Flags: $path" + else + echo "[INFO] Creating Electron Flags: $path" + ln -s $ELECTRON_FLAG $path + fi done diff --git a/bootstrap/linux/main.bash b/bootstrap/linux/main.bash index ccc5435..c47344a 100644 --- a/bootstrap/linux/main.bash +++ b/bootstrap/linux/main.bash @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # vim:ft=bash set -e @@ -21,15 +21,15 @@ fi export WHEEL - GUI_SETUP=0 -if [ "$(uname -r)" = *Microsoft* ]; then +# NOTE: This is NOT a POSIX-compliant way, for POSIX-compliant way, use case/esac +if [[ "$(uname -r)" = *Microsoft* ]]; then echo "[INFO] Running on WSL1 Skipping GUI setup" else read -p "[ACTION] Do you want to setup Linux GUI? (y/N) " choice case "$choice" in - y|Y) + y | Y) GUI_SETUP=1 ;; *) @@ -70,8 +70,8 @@ fi if [ "$WHEEL" -eq 0 ]; then read -p "[ACTION] Do you want to install some AppImages (by AppMan)? (y/N) " choice case "$choice" in - y|Y) - source "$DOTFILES/bootstrap/linux/appman.bash" + y | Y) + source "$DOTFILES/bootstrap/linux/appman.bash" ;; *) echo "[INFO] Skipping AppMan installation" @@ -96,7 +96,7 @@ if command -v zsh >/dev/null 2>&1; then read -p "[ACTION] Do you want to setup zsh? (Y/n) " choice case "$choice" in - n|N) + n | N) : ;; *) @@ -105,7 +105,6 @@ if command -v zsh >/dev/null 2>&1; then esac fi - if [ "$WHEEL" -eq 0 ]; then echo "Done!" exit 0 @@ -113,7 +112,7 @@ fi read -p "[ACTION] Do you want to use other package managers? (y/N) " choice case "$choice" in - y|Y) + y | Y) : ;; *) @@ -143,5 +142,4 @@ echo "[INFO] Installing Color Scheme (Catppuccin Mocha)" fish $DOTFILES/bootstrap/temp/mocha_port.fish - echo "Done!" diff --git a/bootstrap/linux/symlinks.bash b/bootstrap/linux/symlinks.bash index 0422fc2..47a5172 100644 --- a/bootstrap/linux/symlinks.bash +++ b/bootstrap/linux/symlinks.bash @@ -1,9 +1,10 @@ +#!/usr/bin/env bash +# vim:ft=bash set -e # Exit immediately if a command exits with a non-zero status declare -A linkDots - -source "$DOTFILES/bootstrap/components/symlinks.sh" +source "$DOTFILES/bootstrap/components/symlinks.bash" echo "[INFO] DOTFILES = $DOTFILES" @@ -13,16 +14,16 @@ read -n 1 echo "[INFO] Setting up symbolic links" for src in "${!linkDots[@]}"; do - dest="${linkDots[$src]}" - echo "Linking $src to $dest" - if [ -d "$src" ]; then - test -d "$dest" && mv "$dest" "$dest.bak" - 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 + dest="${linkDots[$src]}" + echo "Linking $src to $dest" + if [ -d "$src" ]; then + test -d "$dest" && mv "$dest" "$dest.bak" + 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/macOS/main.zsh b/bootstrap/macOS/main.zsh index 5f03f9c..2255b41 100644 --- a/bootstrap/macOS/main.zsh +++ b/bootstrap/macOS/main.zsh @@ -1,6 +1,8 @@ #! /bin/zsh echo "Running the setup script" +set -e +set -x # VARIABLES @@ -10,7 +12,6 @@ export DOTFILES="${DOTFILES:-$HOME/.dotfiles}" export WHEEL=1 export GUI_SETUP=1 - # Xcode Command Line Tools echo "[INFO] Installing Xcode Command Line Tools" echo "[ACTION] Request Human Takeover" @@ -34,7 +35,6 @@ echo "[INFO] Installing Homebrew" echo "[ACTION] Request Human Input" /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - echo "[ACTION] Press any key to continue when xcode CLI tools are installed" read -n 1 @@ -55,7 +55,6 @@ brew bundle --file=$DOTFILES/bootstrap/macOS/Brewfile # Setting up emacs ln -s /usr/local/opt/emacs-mac/Emacs.app /Applications/Emacs.app - # Setting Default Apps source $DOTFILES/bootstrap/macOS/duti.zsh @@ -77,14 +76,12 @@ 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 diff --git a/bootstrap/macOS/plist.zsh b/bootstrap/macOS/plist.zsh index fa043e5..9d7982c 100644 --- a/bootstrap/macOS/plist.zsh +++ b/bootstrap/macOS/plist.zsh @@ -1,10 +1,10 @@ ## 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 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 @@ -25,7 +25,7 @@ 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 autohide-delay -float 0 # Immediately Autohide Dock defaults write com.apple.dock show-recents -bool false # Hide Recent Applications killall Dock ## Trackpad diff --git a/bootstrap/macOS/symlinks.zsh b/bootstrap/macOS/symlinks.zsh index df3a241..a6dda56 100644 --- a/bootstrap/macOS/symlinks.zsh +++ b/bootstrap/macOS/symlinks.zsh @@ -4,7 +4,7 @@ set -e # Exit immediately if a command exits with a non-zero status typeset -A linkDots # 从通用配置文件加载 -source "$DOTFILES/bootstrap/components/symlinks.sh" +source "$DOTFILES/bootstrap/components/symlinks.bash" echo "[INFO] DOTFILES = $DOTFILES" diff --git a/bootstrap/set_path.ps1 b/bootstrap/set_path.ps1 deleted file mode 100644 index 08d1a40..0000000 --- a/bootstrap/set_path.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -[System.Environment]::SetEnvironmentVariable("Path_EXT_0", "D:\bin", "User") -[System.Environment]::SetEnvironmentVariable("Path_EXT_0", "$Env:LocalAppData\Cargo\bin", "User") -[System.Environment]::SetEnvironmentVariable("Path_EXT_1", "$Env:LocalAppData\Go\bin", "User") -[System.Environment]::SetEnvironmentVariable("Path_EXT_2", "$Env:LocalAppData\Cargo\bin", "User") -[System.Environment]::SetEnvironmentVariable("Path_EXT_2", "", "User") diff --git a/bootstrap/set_symlink_unix.sh b/bootstrap/set_symlink_unix.sh deleted file mode 100644 index 1f4f4b4..0000000 --- a/bootstrap/set_symlink_unix.sh +++ /dev/null @@ -1,142 +0,0 @@ -#! /usr/bin/env bash -# $DOTFILES/bootstrap/set_symlink_unix.sh -# Date: 2025-01-28 -# Author: js0ny -# Set symbolic links for Unix-like systems -# IMPORTANT: The default `bash` in macOS is outdated, run with zsh or install the latest `bash` via Homebrew - -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}" - -mkdir -p $ZDOTDIR/plugins - -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] Setting up symbolic links" -for src in "${!linkDots[@]}"; do - echo "Linking $src to ${linkDots[$src]}" - dest="${linkDots[$src]}" - 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 - -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 - -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] Copying example files" -test -d $XDG_CONFIG_HOME/git || mkdir -p $XDG_CONFIG_HOME/git -cp $DOTFILES/common/gitconfig.example $XDG_CONFIG_HOME/git/config -echo "[INFO] Don't forget to update your gitconfig!" - -echo "[INFO] Installing DOOM Emacs" -echo "[ACTION] Request Human Takeover" -test -d ~/.config/emacs && mv ~/.config/emacs ~/.config/emacs.bak -git clone --depth 1 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 - - -echo "[INFO] Done!" - -export ZDOTDIR -export DOTFILES -export NPM_CONFIG_USERCONFIG diff --git a/bootstrap/setup.sh b/bootstrap/setup.sh index 794a515..bd6c661 100644 --- a/bootstrap/setup.sh +++ b/bootstrap/setup.sh @@ -1,10 +1,12 @@ #!/usr/bin/env bash +# shellcheck disable=SC1090 shell=sh # 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 +set -o errexit +set -o xtrace DOTFILES="${DOTFILES:-$HOME/.dotfiles}" @@ -14,13 +16,13 @@ export DOTFILES case "$(uname)" in Linux) - curl https://raw.githubusercontent.com/js0ny/dotfiles/refs/heads/master/bootstrap/linux/main.bash -o ~/.local/.tmp/main.bash - source ~/.local/.tmp/main.bash - rm -rf ~/.local/.tmp/main.bash - ;; + curl https://raw.githubusercontent.com/js0ny/dotfiles/refs/heads/master/bootstrap/linux/main.bash -o ~/.local/.tmp/main.bash + source ~/.local/.tmp/main.bash + rm -rf ~/.local/.tmp/main.bash + ;; 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 - ;; + 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/bootstrap/tmp.zsh b/bootstrap/tmp.zsh deleted file mode 100644 index 71e32c8..0000000 --- a/bootstrap/tmp.zsh +++ /dev/null @@ -1,19 +0,0 @@ -export DOTFILES=~/.dotfiles -export ZDOTDIR=~/.config/zsh - -mkdir -p $ZDOTDIR -mkdir -p $DOTFILES - -git clone https://github.com/js0ny/dotfiles $DOTFILES - -sudo cp $DOTFILES/tools/zsh/global.zshenv /etc/zsh/zshenv - -export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" -export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" -export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}" -export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" -export XDG_RUNTIME_DIR="/run/user/$(id -u)" - - -mkdir -p $XDG_CONFIG_HOME $XDG_DATA_HOME $XDG_STATE_HOME $XDG_CACHE_HOME - diff --git a/bootstrap/set_symlink_win.ps1 b/bootstrap/win/symlinks.ps1 similarity index 100% rename from bootstrap/set_symlink_win.ps1 rename to bootstrap/win/symlinks.ps1