- Merge sunbather dark/light into one background-aware color scheme - Fold uninstall.sh into install.sh as a subcommand; drop clone logic - Inline bash_tools/ helpers; remove fct and odict - Remove TPM, tmux-sensible, and tmux-fuzzback; tmux has no plugins now - Remove vim-repeat, vim-fugitive, vim-gitgutter, vim-tmux-navigator, and moonfly; everforest is the default dark theme - Fetch vim-plug via git instead of curl; require git, not curl - Guard termguicolors on Windows consoles without VT support and set nomore before the vimrc loads so headless installs cannot hang - Fall back to sunbather when a color scheme fails to load, without overwriting the saved preference - Append config/vim to runtimepath so netrw stops writing into the repo - Fix .editorconfig Python indent; trim .gitignore; update CI and README Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBfsAH6iJg9inkNLKq11YC
This commit is contained in:
+33
-45
@@ -2,17 +2,7 @@
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
readonly APP_NAME='dotfiles'
|
||||
readonly REPO_URI="${REPO_URI:-https://github.com/Donaldttt/dotfiles.git}"
|
||||
readonly REPO_BRANCH="${REPO_BRANCH:-main}"
|
||||
|
||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" 2>/dev/null && pwd -P || true)"
|
||||
if [[ -n "$SCRIPT_DIR" && -e "$SCRIPT_DIR/.git" ]]; then
|
||||
APP_PATH="${APP_PATH:-$SCRIPT_DIR}"
|
||||
else
|
||||
APP_PATH="${APP_PATH:-$HOME/.$APP_NAME}"
|
||||
fi
|
||||
readonly APP_PATH
|
||||
readonly APP_PATH="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
readonly VIM_PATH="${VIM_PATH:-$HOME/.vim}"
|
||||
readonly MANAGED_START='# >>> dotfiles >>>'
|
||||
readonly MANAGED_END='# <<< dotfiles <<<'
|
||||
@@ -23,28 +13,18 @@ warn() { printf '\033[33m[!]\033[0m %s\n' "$*" >&2; }
|
||||
die() { printf '\033[31m[✘]\033[0m %s\n' "$*" >&2; exit 1; }
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage: ./install.sh [all|vim|shell|tmux]...
|
||||
cat <<'USAGE'
|
||||
Usage: ./install.sh [all|vim|shell|tmux|uninstall]...
|
||||
|
||||
With no arguments, installs every component. Components can be combined, for
|
||||
example: ./install.sh vim tmux
|
||||
EOF
|
||||
USAGE
|
||||
}
|
||||
|
||||
require() {
|
||||
command -v "$1" >/dev/null 2>&1 || die "Required program not found: $1"
|
||||
}
|
||||
|
||||
ensure_repo() {
|
||||
require git
|
||||
if [[ -d "$APP_PATH/.git" ]]; then
|
||||
return
|
||||
fi
|
||||
[[ ! -e "$APP_PATH" ]] || die "$APP_PATH exists but is not a Git repository."
|
||||
info "Cloning $REPO_URI into $APP_PATH"
|
||||
git clone --branch "$REPO_BRANCH" --depth 1 "$REPO_URI" "$APP_PATH"
|
||||
}
|
||||
|
||||
backup_path() {
|
||||
local target=$1
|
||||
if [[ -e "$target" || -L "$target" ]]; then
|
||||
@@ -59,19 +39,26 @@ backup_path() {
|
||||
}
|
||||
|
||||
link_config() {
|
||||
local source=$1 target=$2 current=''
|
||||
if [[ -L "$target" ]]; then
|
||||
current=$(readlink "$target" || true)
|
||||
[[ "$current" == "$source" ]] && return
|
||||
local source=$1 target=$2
|
||||
if [[ -L "$target" && "$(readlink "$target" || true)" == "$source" ]]; then
|
||||
return
|
||||
fi
|
||||
backup_path "$target"
|
||||
ln -s "$source" "$target"
|
||||
success "Linked $target -> $source"
|
||||
}
|
||||
|
||||
remove_managed_link() {
|
||||
local target=$1 expected=$2
|
||||
if [[ -L "$target" && "$(readlink "$target")" == "$expected" ]]; then
|
||||
rm -- "$target"
|
||||
info "Removed $target"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_managed_block() {
|
||||
local file=$1 temp
|
||||
[[ -f "$file" ]] || return
|
||||
[[ -f "$file" ]] || return 0
|
||||
temp=$(mktemp)
|
||||
awk -v start="$MANAGED_START" -v end="$MANAGED_END" '
|
||||
$0 == start { managed = 1; next }
|
||||
@@ -84,22 +71,21 @@ remove_managed_block() {
|
||||
|
||||
install_vim() {
|
||||
require vim
|
||||
require curl
|
||||
require git
|
||||
if ! vim --clean -Nu NONE -n -es \
|
||||
'+if v:version < 900 | cquit | endif' '+qall'; then
|
||||
die 'Vim 9 or newer is required.'
|
||||
fi
|
||||
|
||||
link_config "$APP_PATH/.vimrc" "$HOME/.vimrc"
|
||||
mkdir -p "$VIM_PATH/autoload"
|
||||
local temp
|
||||
temp=$(mktemp)
|
||||
curl --fail --location --silent --show-error \
|
||||
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim \
|
||||
--output "$temp"
|
||||
mv "$temp" "$VIM_PATH/autoload/plug.vim"
|
||||
temp=$(mktemp -d)
|
||||
git clone --depth 1 --quiet https://github.com/junegunn/vim-plug "$temp"
|
||||
cp "$temp/plug.vim" "$VIM_PATH/autoload/plug.vim"
|
||||
rm -rf "$temp"
|
||||
link_config "$APP_PATH/.vimrc" "$HOME/.vimrc"
|
||||
vim -Nu "$APP_PATH/.vimrc" -n -es \
|
||||
'+set nomore' '+PlugInstall --sync' '+qall'
|
||||
--cmd 'set nomore' '+PlugInstall --sync' '+qall'
|
||||
success 'Installed Vim configuration and plugins.'
|
||||
}
|
||||
|
||||
@@ -120,13 +106,15 @@ install_shell() {
|
||||
install_tmux() {
|
||||
require tmux
|
||||
link_config "$APP_PATH/.tmux.conf" "$HOME/.tmux.conf"
|
||||
local tpm="$HOME/.tmux/plugins/tpm"
|
||||
if [[ ! -d "$tpm/.git" ]]; then
|
||||
[[ ! -e "$tpm" ]] || die "$tpm exists but is not a Git repository."
|
||||
mkdir -p "$(dirname "$tpm")"
|
||||
git clone --depth 1 https://github.com/tmux-plugins/tpm "$tpm"
|
||||
fi
|
||||
success 'Installed tmux configuration and TPM.'
|
||||
success 'Installed tmux configuration.'
|
||||
}
|
||||
|
||||
uninstall() {
|
||||
remove_managed_link "$HOME/.vimrc" "$APP_PATH/.vimrc"
|
||||
remove_managed_link "$HOME/.tmux.conf" "$APP_PATH/.tmux.conf"
|
||||
remove_managed_block "$HOME/.bashrc"
|
||||
success 'Removed dotfile links and the managed Bash block.'
|
||||
info 'The repository, Vim data/plugins, and backups were retained.'
|
||||
}
|
||||
|
||||
main() {
|
||||
@@ -134,7 +122,6 @@ main() {
|
||||
-h|--help) usage; return ;;
|
||||
esac
|
||||
|
||||
ensure_repo
|
||||
local components=("$@") component
|
||||
((${#components[@]})) || components=(all)
|
||||
for component in "${components[@]}"; do
|
||||
@@ -147,6 +134,7 @@ main() {
|
||||
vim) install_vim ;;
|
||||
shell) install_shell ;;
|
||||
tmux) install_tmux ;;
|
||||
uninstall) uninstall ;;
|
||||
*) usage; die "Unknown component: $component" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user