refractor(bootstrap): Format with shfmt

This commit is contained in:
js0ny 2025-02-24 00:42:55 +00:00
parent f015467b1b
commit 0ce74497cd
21 changed files with 271 additions and 377 deletions

68
.github/workflows/shell-check.yml vendored Normal file
View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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!"

View file

@ -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!"

View file

@ -7,7 +7,6 @@ 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"
@ -22,7 +21,6 @@ else
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

View file

@ -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

View file

@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
# vim:ft=bash
# chromium-flags.sh
# Set Chromium & Electron Flags
@ -35,7 +36,6 @@ for path in "${browser_flags_path[@]}"; do
fi
done
for path in "${electron_flags_path[@]}"; do
if [ -f "$path" ]; then
echo "[INFO] Found Electron Flags: $path"

View file

@ -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,7 +70,7 @@ 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)
y | Y)
source "$DOTFILES/bootstrap/linux/appman.bash"
;;
*)
@ -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!"

View file

@ -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"

View file

@ -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

View file

@ -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"

View file

@ -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")

View file

@ -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

View file

@ -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}"

View file

@ -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