Add script log for elevation scripts.

This commit is contained in:
js0ny 2025-11-08 08:13:06 +00:00
parent 2a1127bf10
commit 6ee67769a6
25 changed files with 102 additions and 99 deletions

View file

@ -68,7 +68,7 @@ Determining headless
{{- $ephemeral = true -}}
{{- $headless = true -}}
{{- end -}}
{{ if not .headless }}
{{ if not $headless }}
{{ if eq .chezmoi.os "linux" }}
{{/* Fedora Server */}}
{{ if eq .chezmoi.osRelease.variantID "server" }}

View file

@ -0,0 +1,27 @@
[".local/share/fonts/maple-nf"]
type = "archive"
url = {{ gitHubLatestReleaseAssetURL "subframe7536/maple-font" (printf "MapleMono-NF-CN-unhinted.zip") | quote }}
refreshPeriod = "672h"
exact = true
executable = false
[".local/share/fonts/jetbrainsmono-nf"]
type = "archive"
url = {{ gitHubLatestReleaseAssetURL "ryanoasis/nerd-fonts" (printf "JetBrainsMono.zip") | quote }}
refreshPeriod = "672h"
exact = true
executable = false
[".local/share/fonts/lxgw-wenkai"]
type = "archive"
url = {{ gitHubLatestReleaseAssetURL "lxgw/LxgwWenKai" (printf "lxgw-wenkai-v*.zip") | quote }}
refreshPeriod = "168h"
exact = true
executable = false
[".local/share/fonts/lxgw-neoxihei"]
type = "file"
url = {{ gitHubLatestReleaseAssetURL "lxgw/LxgwNeoXiHei" (printf "LXGWNeoXiHei.ttf") | quote }}
refreshPeriod = "168h"
exact = true
executable = false

View file

@ -8,10 +8,15 @@ vim:ft=gotmpl
{{/* Secret Directory, always ignored, access via templates */}}
secrets/**
{{/* Install appimages only on non-wheel linux systems */}}
{{/* Non-wheel */}}
{{ if eq .chezmoi.os "linux" }}
{{ if .wheel }}
{{/* Install appimages only on non-wheel linux systems */}}
.local/bin/ghostty
{{/* If wheel, source bashrc directly from global bashrc */}}
.bashrc
.bash_profile
.zshenv
{{ end }}
{{ end }}
@ -41,6 +46,8 @@ vim:ft=gotmpl
{{/* Managed by home-manager */}}
{{ if .nix }}
.bashrc
.bash_profile
.zshenv
.chezmoiscripts/linux/**
.chezmoiscripts/unixlike/**
.chezmoiexternals/**

View file

@ -1,6 +1,8 @@
#!/bin/sh
# shellcheck shell=sh
echo "[INFO] Running neovim healthcheck"
if command -v nvim > /dev/null 2>&1; then
nvim --headless +checkhealth +"w nvim-healthcheck.txt" +qall
fi

View file

@ -1,3 +1,7 @@
#!/bin/sh
set -x
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
set +x

View file

@ -1,15 +1,16 @@
#!/bin/sh
echo "Use TouchID to authenticate before running sudo commands."
echo "WARNING: This operation modifies critical system files."
echo "If something goes wrong, you may need to boot into macOS Recovery Mode to restore your system."
echo "To continue, type EXACTLY 'yes' and press Enter."
echo "[INFO] Use TouchID to authenticate before running sudo commands."
echo "[WARNING] This operation modifies critical system files."
echo " If something goes wrong, you may need to boot into macOS Recovery Mode to restore your system."
echo "[ACTION] To continue, type EXACTLY 'yes' and press Enter."
read -p "Do you want to continue? (yes/no): " response
if [ "$response" != "yes" ]; then
echo "Operation cancelled."
echo "[INFO] Operation cancelled."
exit 0 # Exit with success status code
fi
echo ""
set -x
sudo cp ~/.dotfiles/misc/mac/etc/pam.d/sudo /etc/pam.d/sudo
set +x

View file

@ -0,0 +1,5 @@
#!/bin/sh
echo "[INFO] Rebuilding fonts cache..."
fc-cache -fv

View file

@ -1,8 +1,15 @@
#!/bin/sh
# Check if firefox is installed
if ! command -v firefox &> /dev/null; then
echo "[WARNING] Firefox is not installed. Skip this script."
exit 0
fi
src=~/.dotfiles/misc/firefox/search.json.mozlz4
dest=~/.mozilla/firefox/*.default/search.json.mozlz4
if ! cmp -s "$src" "$dest" 2>/dev/null; then
echo "[INFO] search.json.mozlz4 is updated, copying..."
cp "$src" "$dest"
fi
@ -11,7 +18,9 @@ fi
src=~/.dotfiles/misc/firefox/policies.json
dest=/etc/firefox/policies/policies.json
if ! cmp -s "$src" "$dest" 2>/dev/null; then
sudo cp "$src" "$dest"
echo "[INFO] policies.json is updated, copying..."
echo "[ACTION] elevation required"
sudo cp "$src" "$dest" && exit 0
fi
{{ end }}

View file

@ -1,3 +0,0 @@
#!/bin/sh
fc-cache -fv

View file

@ -1,4 +0,0 @@
#!/bin/sh
# shellcheck shell=sh
sudo cp $CHEZMOI_SOURCE_DIR/dot_config/bash/xdg-compat.sh /etc/profile.d/xdg-compat.sh

View file

@ -0,0 +1,12 @@
#!/bin/sh
# shellcheck shell=sh
{{ if .wheel }}
echo "[ACTION] Elevation required: "
echo " Setting XDG Environment Variables to global scope"
sudo cp $CHEZMOI_SOURCE_DIR/.chezmoitemplates/bash_profile /etc/profile.d/xdg-compat.sh
{{ else }}
{{ end }}

View file

@ -1,9 +1,13 @@
#!/bin/sh
echo "[INFO] Running: zsh-set-env.sh"
XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
{{ if .wheel }}
echo "[INFO] "
if [ -f /etc/zshenv ]; then
sudo cp "$CHEZMOI_SOURCE_DIR/dot_config/zsh/global.zshenv" /etc/zshenv
fi

View file

@ -0,0 +1,15 @@
# Location: /etc/profile.d/xdg-compat.sh
# If elevated: copy it to /etc/profile.d/xdg-compat.sh
# Else: Set as .bash_profile
# Set XDG Base Directory Path
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
# Source user's XDG-compliant Bash configs
if [ -f "$XDG_CONFIG_HOME/bash/profile" ]; then
. "$XDG_CONFIG_HOME/bash/profile"
fi

View file

@ -0,0 +1 @@
{{ template "bash_profile" . }}

1
home/dot_bashrc.tmpl Normal file
View file

@ -0,0 +1 @@
{{ template "bashrc" }}

View file

@ -0,0 +1 @@
{{ template "bashrc" }}

View file

@ -11,10 +11,6 @@ if [ -n "$BASH_VERSION" ] && [ -f "$HOME/.bash_profile" ]; then
. "$HOME/.bash_profile"
fi
if [ -n "$BASH_VERSION" ] && [ -f "$XDG_CONFIG_HOME/bash/bashrc" ]; then
. "$XDG_CONFIG_HOME/bash/bashrc"
fi
pathadd() {
# 检查是否存在且不在 PATH 中
if [[ -d "$1" && ":$PATH:" != *":$1:"* ]]; then

View file

@ -1,76 +0,0 @@
# vim:ft=gotmpl
# $DOTFILES/common/gitconfig.example
# Date: 2024-12-22
# Author: js0ny
# Location:
# Windows: %USERPROFILE%\.gitconfig
# *nix: ~/.config/git/config
# Linking: (Note that this file is an example, only copy this then edit)
# cp $DOTFILES/common/gitconfig.example ~/.config/git/config
[user]
name = {{ .username }}
email = {{ .email }}
[alias]
cl = clone
clnh = clone --depth 1 # Clone with no history
cma = commit -am # Add and commit
logs = log --oneline --graph --decorate --all # Show logs
last = log -1 HEAD # Show last commit
undo = reset --hard HEAD # Undo the last commit
[core]
editor = nvim
pager = delta
# autocrlf:
# true: Keep crlf in Windows, lf in *nix
# input: Keep lf in all platforms
autocrlf = input
safecrlf = true
excludesfile = $XDG_CONFIG_HOME/git/ignore
quotePath = false # zh-CN: 解决中文路径问题
eol = lf
[core]
{{- if eq .chezmoi.os "windows" }}
editor = vim
{{- else }}
editor = nvim
{{- end }}
pager = delta
autocrlf = input # Force End of Line in different platforms
[interactive]
diffFilter = delta --color-only
[delta]
navigate = true
dark = true
features = catppuccin-mocha # Colorscheme
[diff]
tool = nvimdiff
[difftool]
prompt = false
[difftool "nvimdiff"]
cmd = "nvim -d \"$LOCAL\" \"$REMOTE\""
[merge]
tool = nvimdiff
[mergetool]
prompt = false
[mergetool "nvimdiff"]
cmd = "nvim -d \"$LOCAL\" \"$MERGED\" \"$REMOTE\""
[color]
ui = auto
[pull]
ff = only
[init]
defaultBranch = master
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
# Force ssh
# Don't use ssh in GitHub since ssh-agent doesn't work in non-interactive environment
# While GitHub holds many plugins, it's better to use https
# This prevents from Neovide `publickey` error when installing plugins
# [url "git@github.com:"]
# insteadOf = https://github.com/
[url "git@codeberg.org:"]
insteadOf = https://codeberg.org/

View file

@ -0,0 +1 @@
{{ template "zshenv" }}

View file

@ -1 +1 @@
{{ includeTemplate "dot_config/git/_gitconfig.shared.tmpl" . }}
{{ template "gitconfig" . }}

1
home/dot_zshenv.tmpl Normal file
View file

@ -0,0 +1 @@
{{ template "zshenv" }}

View file

@ -1 +0,0 @@
/home/js0ny/.config/bash/bashrc