mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 08:43:00 +00:00
feat(bootstrap): Bootstrap script for GNU/Linux without admin
This commit is contained in:
parent
cb81dc8d53
commit
8aa9daf582
12 changed files with 340 additions and 80 deletions
11
bootstrap/components/rime.sh
Normal file
11
bootstrap/components/rime.sh
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
echo "[INFO] Installing Rime"
|
||||
|
||||
git clone --depth 1 https://github.com/js0ny/rime_wanxiang_pro.git ~/Library/Rime
|
||||
cd ~/Library/Rime
|
||||
|
||||
just init
|
||||
# just install_rime
|
||||
## Rime is installed via Brewfile
|
||||
just clone_plum
|
||||
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
# 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}"
|
||||
|
|
@ -64,8 +65,10 @@ else
|
|||
linkDots+=(
|
||||
["$DOTFILES/common/inputrc"]="$HOME/.inputrc"
|
||||
)
|
||||
if [ "$(uname -r)" = *Microsoft* ]; then
|
||||
echo "[INFO] Running on WSL1"
|
||||
# WSL1 : Microsoft
|
||||
# WSL2 : microsoft
|
||||
if [ "$(uname -r)" = *icrosoft* ]; then
|
||||
echo "[INFO] Running on WSL"
|
||||
: # NOP
|
||||
else
|
||||
echo "[INFO] Running on Native Linux"
|
||||
|
|
|
|||
|
|
@ -1,19 +1,28 @@
|
|||
WHEEL="${WHEEL:-1}"
|
||||
|
||||
echo "[INFO] ZDOTDIR = $ZDOTDIR"
|
||||
echo "[INFO] DOTFILES = $DOTFILES"
|
||||
echo "[INFO] WHEEL = $WHEEL"
|
||||
|
||||
# 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 "[ACTION] Press any key to proceed"
|
||||
read -n 1
|
||||
|
||||
|
||||
if [ $(uname) = "Darwin" ]; then
|
||||
sudo cp "$DOTFILES/tools/zsh/zshenv" "/etc/zshenv"
|
||||
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
|
||||
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"
|
||||
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
|
||||
|
|
|
|||
7
bootstrap/linux/appman.bash
Normal file
7
bootstrap/linux/appman.bash
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
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
|
||||
if [ command -v appman ]; then
|
||||
appman install wezterm
|
||||
appman install nvim
|
||||
fi
|
||||
46
bootstrap/linux/chromium-flags.bash
Executable file
46
bootstrap/linux/chromium-flags.bash
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
# chromium-flags.sh
|
||||
# Set Chromium & Electron Flags
|
||||
|
||||
echo "[INFO] Set Chromium & Electron Flags"
|
||||
|
||||
DOTFILES="${DOTFILES:-$HOME/.dotfiles}"
|
||||
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
BROWSER_FLAG=$DOTFILES/platforms/linux/chromium-flags.conf
|
||||
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
|
||||
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
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
|
||||
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
|
||||
done
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env false
|
||||
# TODO: This script is not ready for use yet
|
||||
# -*- coding: utf-8 -*-
|
||||
# Append Electron argument (for wayland) to *.desktop files
|
||||
|
||||
|
|
|
|||
146
bootstrap/linux/main.bash
Normal file
146
bootstrap/linux/main.bash
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
#!/bin/bash
|
||||
# vim:ft=bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "Running the setup script"
|
||||
|
||||
# Variables
|
||||
|
||||
export DOTFILES="${DOTFILES:-$HOME/.dotfiles}"
|
||||
|
||||
# If is in the sudo or wheel group, set the WHEEL variable to 1
|
||||
WHEEL=0
|
||||
groups "$(whoami)" | grep -E -q '\b(sudo|wheel)\b' && WHEEL=1
|
||||
|
||||
if [ "$WHEEL" -eq 1 ]; then
|
||||
echo "[INFO] Running as sudo or wheel group"
|
||||
else
|
||||
echo "[INFO] Not running as sudo or wheel group"
|
||||
fi
|
||||
|
||||
export WHEEL
|
||||
|
||||
|
||||
GUI_SETUP=0
|
||||
|
||||
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)
|
||||
GUI_SETUP=1
|
||||
;;
|
||||
*)
|
||||
echo "[INFO] Skipping GUI setup"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
export GUI_SETUP
|
||||
|
||||
# base-devel
|
||||
|
||||
if [ "$WHEEL" -eq 1 ]; then
|
||||
echo "[INFO] Installing basic build tools"
|
||||
if [ command -v apt ]; then
|
||||
sudo apt update
|
||||
sudo apt install -y build-essential
|
||||
elif [ command -v pacman ]; then
|
||||
sudo pacman -Syu --noconfirm
|
||||
sudo pacman -S --noconfirm base-devel
|
||||
else
|
||||
echo "[ERROR] Unsupported package manager"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "[INFO] Cloning Dotfiles"
|
||||
|
||||
if [ -d "$DOTFILES" ]; then
|
||||
echo "[INFO] Dotfiles already cloned"
|
||||
elif [ command -v git ]; then
|
||||
git clone https://github.com/js0ny/dotfiles.git "$DOTFILES" --depth 1
|
||||
else
|
||||
echo "[ERROR] Git is not installed"
|
||||
exit 1
|
||||
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"
|
||||
;;
|
||||
*)
|
||||
echo "[INFO] Skipping AppMan installation"
|
||||
:
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "[INFO] Setting up symbolic links"
|
||||
|
||||
source $DOTFILES/bootstrap/linux/symlinks.bash
|
||||
|
||||
if [ "$WHEEL" -eq 1 ]; then
|
||||
source $DOTFILES/tools/bash/xdg-compact.sh
|
||||
source $DOTFILES/tools/bash/global.bashrc
|
||||
fi
|
||||
source $DOTFILES/tools/bash/profile
|
||||
source $DOTFILES/tools/bash/bashrc
|
||||
source $DOTFILES/tools/bash/bash_aliases
|
||||
|
||||
if [ command -v zsh ]; then
|
||||
read -p "[ACTION] Do you want to setup zsh? (Y/n) " choice
|
||||
case "$choice" in
|
||||
n|N)
|
||||
:
|
||||
;;
|
||||
*)
|
||||
source $DOTFILES/bootstrap/components/zsh.sh
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
if [ "$WHEEL" -eq 0 ]; then
|
||||
echo "Done!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
read -p "[ACTION] Do you want to use other package managers? (y/N) " choice
|
||||
case "$choice" in
|
||||
y|Y)
|
||||
:
|
||||
;;
|
||||
*)
|
||||
:
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "[INFO] Installing Doom Emacs"
|
||||
|
||||
source $DOTFILES/bootstrap/components/emacs.sh
|
||||
|
||||
if [ "$GUI_SETUP" -eq 0 ]; then
|
||||
echo "Done!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Wayland
|
||||
|
||||
source $DOTFILES/bootstrap/linux/chromium-flags.sh
|
||||
|
||||
# Rime
|
||||
|
||||
source $DOTFILES/bootstrap/components/rime.sh
|
||||
|
||||
# TODO: Rewrite the script(mocha_port.fish) in bash/zsh or POSIX-compliant shell
|
||||
echo "[INFO] Installing Color Scheme (Catppuccin Mocha)"
|
||||
|
||||
fish $DOTFILES/bootstrap/temp/mocha_port.fish
|
||||
|
||||
|
||||
echo "Done!"
|
||||
28
bootstrap/linux/symlinks.bash
Normal file
28
bootstrap/linux/symlinks.bash
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
set -e # Exit immediately if a command exits with a non-zero status
|
||||
|
||||
declare -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"
|
||||
|
||||
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
|
||||
done
|
||||
|
|
@ -1,62 +1,74 @@
|
|||
#!/bin/zsh
|
||||
# duti.zsh
|
||||
# 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
|
||||
# Define an associative array with file extensions and corresponding app IDs
|
||||
typeset -A app_defaults
|
||||
app_defaults=(
|
||||
# Markdown -> Typora
|
||||
.md abnerworks.Typora
|
||||
.markdown abnerworks.Typora
|
||||
# PDF -> Sioyek
|
||||
.pdf info.sioyek.sioyek
|
||||
# Raw Text -> Neovide
|
||||
.txt com.neovide.neovide
|
||||
# Archive -> Keka
|
||||
.zip com.aone.keka
|
||||
.rar com.aone.keka
|
||||
.7z com.aone.keka
|
||||
.tar com.aone.keka
|
||||
# Source Code Light -> Neovim
|
||||
.gitignore com.neovide.neovide
|
||||
.vimrc com.neovide.neovide
|
||||
.vim com.neovide.neovide
|
||||
.lua com.neovide.neovide
|
||||
.py com.neovide.neovide
|
||||
.jl com.neovide.neovide
|
||||
.sh com.neovide.neovide
|
||||
.c com.neovide.neovide
|
||||
# Source Code DOTNET -> VSCode
|
||||
.cs com.microsoft.VSCode
|
||||
.fs com.microsoft.VSCode
|
||||
.fsx com.microsoft.VSCode
|
||||
.csx com.microsoft.VSCode
|
||||
.ps1 com.microsoft.VSCode
|
||||
# Source Code Web -> VSCode
|
||||
.js com.microsoft.VSCode
|
||||
.ts com.microsoft.VSCode
|
||||
.jsx com.microsoft.VSCode
|
||||
.tsx com.microsoft.VSCode
|
||||
.css com.microsoft.VSCode
|
||||
.scss com.microsoft.VSCode
|
||||
.sass com.microsoft.VSCode
|
||||
.vue com.microsoft.VSCode
|
||||
# Source Code Config -> Neovim
|
||||
.json com.neovide.neovide
|
||||
.yaml com.neovide.neovide
|
||||
.yml com.neovide.neovide
|
||||
.toml com.neovide.neovide
|
||||
.ini com.neovide.neovide
|
||||
.cfg com.neovide.neovide
|
||||
.conf com.neovide.neovide
|
||||
.kdl com.neovide.neovide
|
||||
.xml com.neovide.neovide
|
||||
# Source Code Jupyter -> VSCode
|
||||
.ipynb com.microsoft.VSCode
|
||||
# Source Code DotNet Project -> Rider
|
||||
.sln com.jetbrains.rider
|
||||
.csproj com.jetbrains.rider
|
||||
.fsproj com.jetbrains.rider
|
||||
# Video -> IINA
|
||||
.mp4 com.colliderli.iina
|
||||
.mkv com.colliderli.iina
|
||||
)
|
||||
|
||||
# Loop through the array and set the default apps
|
||||
for ext app_id in ${(kv)app_defaults}; do
|
||||
duti -s $app_id $ext all
|
||||
done
|
||||
|
||||
unset app_defaults
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ echo "Running the setup script"
|
|||
|
||||
export DOTFILES="${DOTFILES:-$HOME/.dotfiles}"
|
||||
|
||||
# In macOS, consider the user as sudoer by default
|
||||
export WHEEL=1
|
||||
export GUI_SETUP=1
|
||||
|
||||
|
||||
# Xcode Command Line Tools
|
||||
echo "[INFO] Installing Xcode Command Line Tools"
|
||||
|
|
@ -67,15 +71,7 @@ source $DOTFILES/tools/zsh/zshrc
|
|||
|
||||
# Rime
|
||||
|
||||
echo "[INFO] Installing Rime"
|
||||
|
||||
git clone --depth 1 https://github.com/js0ny/rime_wanxiang_pro.git ~/Library/Rime
|
||||
cd ~/Library/Rime
|
||||
|
||||
just init
|
||||
# just install_rime
|
||||
## Rime is installed via Brewfile
|
||||
just clone_plum
|
||||
source $DOTFILES/bootstrap/components/rime.sh
|
||||
|
||||
echo "[INFO] Installing Doom Emacs"
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ for src in ${(k)linkDots}; do
|
|||
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)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ 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
|
||||
;;
|
||||
Darwin)
|
||||
curl https://raw.githubusercontent.com/js0ny/dotfiles/refs/heads/master/bootstrap/macOS/main.zsh -o ~/.local/.tmp/main.zsh
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue