From 8e0d415afa2382d8030a7339ad048bd90a8d0d0e Mon Sep 17 00:00:00 2001 From: Ben Kyd Date: Mon, 16 Mar 2026 11:25:10 +0000 Subject: [PATCH] better tmux ecetera --- bootstrap.sh | 74 +++++++++++++++++-- .../lua/plugin-config/nvim-treesitter.lua | 33 ++++++++- home/benk/.config/nvim/lua/plugins.lua | 60 ++------------- home/benk/.config/wezterm/wezterm.lua | 1 - home/benk/.ssh/.gitkeep | 0 home/benk/.ssh/config | 16 ---- home/benk/.tmux.conf | 13 ++-- 7 files changed, 115 insertions(+), 82 deletions(-) create mode 100644 home/benk/.ssh/.gitkeep delete mode 100644 home/benk/.ssh/config diff --git a/bootstrap.sh b/bootstrap.sh index a068c48..282d5d5 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -6,10 +6,11 @@ BACKUP_DIR="$HOME/dotfiles.bak" USER="$(whoami)" usage() { - echo "Usage: ./bootstrap.sh [--pull]" + echo "Usage: ./bootstrap.sh [--pull | --copy]" echo "" echo " (no args) Install packages, sync repo -> system" echo " --pull Sync system -> repo (pull changes back)" + echo " --copy Sync repo -> home only (skip packages and shell tooling)" exit 0 } @@ -36,8 +37,36 @@ pull_back() { exit 0 } +# --- Copy mode: sync repo -> $HOME only, no packages or tooling --- +copy_home() { + OVERLAY_HOME="$DOTFILES_DIR/home/$USER" + if [ ! -d "$OVERLAY_HOME" ]; then + echo "WARNING: No home overlay for user '$USER', falling back to home/benk/" + OVERLAY_HOME="$DOTFILES_DIR/home/benk" + fi + + echo "==> Creating directory structure..." + mkdir -p \ + "$HOME/.config" \ + "$HOME/.local/bin" \ + "$HOME/.local/share" \ + "$HOME/.local/state" \ + "$HOME/.ssh" + chmod 700 "$HOME/.ssh" + + echo "==> Syncing $OVERLAY_HOME -> $HOME" + mkdir -p "$BACKUP_DIR/home" + rsync -av --itemize-changes --backup --backup-dir="$BACKUP_DIR/home" \ + "$OVERLAY_HOME/" "$HOME/" + echo "" + echo "Done. Backups at ~/dotfiles.bak/" + exit 0 +} + if [[ "${1:-}" == "--pull" ]]; then pull_back +elif [[ "${1:-}" == "--copy" ]]; then + copy_home elif [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then usage fi @@ -61,6 +90,21 @@ echo "Detected OS: $OS" echo "" # --- Package installation --- +install_with_prompt() { + local cmd="$1" + local pkg="$2" + if ! $cmd "$pkg" 2>&1; then + echo "" + echo " [!] Failed to install: $pkg" + read -p " Continue anyway? [y/N] " -n 1 -r + echo "" + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo " Aborting." + exit 1 + fi + fi +} + install_packages() { case "$OS" in macos) @@ -70,7 +114,13 @@ install_packages() { eval "$(/opt/homebrew/bin/brew shellenv)" fi echo "==> Installing packages via brew..." - xargs brew install < "$DOTFILES_DIR/packages/brew.txt" + set +e + while IFS= read -r pkg || [[ -n "$pkg" ]]; do + [[ -z "$pkg" || "$pkg" == \#* ]] && continue + echo " brew install $pkg" + install_with_prompt "brew install" "$pkg" + done < "$DOTFILES_DIR/packages/brew.txt" + set -e ;; arch) if ! command -v yay &>/dev/null; then @@ -78,12 +128,17 @@ install_packages() { sudo pacman -S --needed --noconfirm git base-devel tmpdir=$(mktemp -d) git clone https://aur.archlinux.org/yay.git "$tmpdir/yay" - cd "$tmpdir/yay" && makepkg -si --noconfirm - cd "$DOTFILES_DIR" + (cd "$tmpdir/yay" && makepkg -si --noconfirm) rm -rf "$tmpdir" fi echo "==> Installing packages via yay..." - xargs yay -S --needed --noconfirm < "$DOTFILES_DIR/packages/arch.txt" + set +e + while IFS= read -r pkg || [[ -n "$pkg" ]]; do + [[ -z "$pkg" || "$pkg" == \#* ]] && continue + echo " yay -S $pkg" + install_with_prompt "yay -S --needed --noconfirm" "$pkg" + done < "$DOTFILES_DIR/packages/arch.txt" + set -e ;; *) echo " Unknown OS, skipping package install." @@ -139,6 +194,15 @@ if [ ! -d "$OVERLAY_HOME" ]; then OVERLAY_HOME="$DOTFILES_DIR/home/benk" fi +echo "==> Creating directory structure..." +mkdir -p \ + "$HOME/.config" \ + "$HOME/.local/bin" \ + "$HOME/.local/share" \ + "$HOME/.local/state" \ + "$HOME/.ssh" +chmod 700 "$HOME/.ssh" + echo "==> Syncing $OVERLAY_HOME -> $HOME" mkdir -p "$BACKUP_DIR/home" rsync -av --itemize-changes --backup --backup-dir="$BACKUP_DIR/home" \ diff --git a/home/benk/.config/nvim/lua/plugin-config/nvim-treesitter.lua b/home/benk/.config/nvim/lua/plugin-config/nvim-treesitter.lua index 18b100b..9a34405 100644 --- a/home/benk/.config/nvim/lua/plugin-config/nvim-treesitter.lua +++ b/home/benk/.config/nvim/lua/plugin-config/nvim-treesitter.lua @@ -15,5 +15,36 @@ require'nvim-treesitter.configs'.setup { }, highlight = { enable = true - } + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + }, + }, + move = { + enable = true, + set_jumps = true, + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { ['a'] = '@parameter.inner' }, + swap_previous = { ['A'] = '@parameter.inner' }, + }, + }, } diff --git a/home/benk/.config/nvim/lua/plugins.lua b/home/benk/.config/nvim/lua/plugins.lua index a22d91b..8e6a54e 100644 --- a/home/benk/.config/nvim/lua/plugins.lua +++ b/home/benk/.config/nvim/lua/plugins.lua @@ -134,15 +134,17 @@ return { end }, { - 'nvim-treesitter/nvim-treesitter-context', + 'nvim-treesitter/nvim-treesitter', + branch = 'master', build = ':TSUpdate', - dependencies = { - 'nvim-treesitter/nvim-treesitter', - }, config = function() require('plugin-config/nvim-treesitter') end }, + { + 'nvim-treesitter/nvim-treesitter-context', + dependencies = { 'nvim-treesitter/nvim-treesitter' }, + }, { 'mrjones2014/smart-splits.nvim', config = function() @@ -160,7 +162,7 @@ return { { 'gorbit99/codewindow.nvim', lazy = false, - opts = {}, + dependencies = { 'nvim-treesitter/nvim-treesitter' }, config = function() require('codewindow').apply_default_keybinds() end @@ -269,19 +271,6 @@ return { opts = {}, }, -- FUNCTIONAL CODING STUFF - { - 'zbirenbaum/copilot.lua', - event = 'InsertEnter', - opts = { - suggestion = { - enabled = true, - auto_trigger = true, - keymap = { - accept = '', - } - }, - } - }, { "L3MON4D3/LuaSnip", build = "make install_jsregexp" @@ -372,41 +361,6 @@ return { { 'nvim-treesitter/nvim-treesitter-textobjects', dependencies = { 'nvim-treesitter/nvim-treesitter' }, - config = function() - require('nvim-treesitter.configs').setup({ - textobjects = { - select = { - enable = true, - lookahead = true, - keymaps = { - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - }, - }, - move = { - enable = true, - set_jumps = true, - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', - }, - goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - }, - swap = { - enable = true, - swap_next = { ['a'] = '@parameter.inner' }, - swap_previous = { ['A'] = '@parameter.inner' }, - }, - }, - }) - end, }, -- Format on save / manual format (clang-format, prettier, etc.) { diff --git a/home/benk/.config/wezterm/wezterm.lua b/home/benk/.config/wezterm/wezterm.lua index 46b0164..1e0ca84 100644 --- a/home/benk/.config/wezterm/wezterm.lua +++ b/home/benk/.config/wezterm/wezterm.lua @@ -17,7 +17,6 @@ if is_macos then else config.default_prog = { '/usr/bin/fish' } config.enable_wayland = true - config.kde_window_background_blur = true end config.hide_tab_bar_if_only_one_tab = true diff --git a/home/benk/.ssh/.gitkeep b/home/benk/.ssh/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/home/benk/.ssh/config b/home/benk/.ssh/config deleted file mode 100644 index 3ac1d6a..0000000 --- a/home/benk/.ssh/config +++ /dev/null @@ -1,16 +0,0 @@ -host github.com - HostName ssh.github.com - IdentityFile ~/.ssh/github - -host git.chamit.co.uk - HostName git.chamit.co.uk - IdentityFile ~/.ssh/github - -Host vps - HostName *** - IdentityFile ~/.ssh/vps - User ben - -host remarkable - HostName 192.168.0.18 - User root diff --git a/home/benk/.tmux.conf b/home/benk/.tmux.conf index 7d55d24..a351540 100644 --- a/home/benk/.tmux.conf +++ b/home/benk/.tmux.conf @@ -4,9 +4,10 @@ set -ga terminal-overrides ",xterm*:Tc" set -sg escape-time 0 set -g history-limit 50000 -# Set Fish as default shell (Apple Silicon path) -set-option -g default-shell /opt/homebrew/bin/fish -set-option -g default-command /opt/homebrew/bin/fish +# Set Fish as default shell (OS-aware path) +if-shell "uname | grep -q Darwin" \ + "set-option -g default-shell /opt/homebrew/bin/fish; set-option -g default-command /opt/homebrew/bin/fish" \ + "set-option -g default-shell /usr/bin/fish; set-option -g default-command /usr/bin/fish" unbind C-Enter @@ -72,12 +73,12 @@ set -g status-right "" set -g status-style 'bg=#f5bde6 fg=#24273a' set -g pane-active-border-style "bg=default fg=#f5bde6" -# --- Copy/paste (system clipboard via OSC 52 — works over SSH) --- +# --- Copy/paste (system clipboard) --- set -g set-clipboard on setw -g mode-keys vi bind -T copy-mode-vi v send -X begin-selection -bind -T copy-mode-vi y send -X copy-selection -bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection +bind -T copy-mode-vi y send -X copy-pipe-and-cancel "wl-copy 2>/dev/null || xclip -selection clipboard 2>/dev/null || xsel --clipboard --input" +bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "wl-copy 2>/dev/null || xclip -selection clipboard 2>/dev/null || xsel --clipboard --input" # --- Plugins --- set -g @plugin 'tmux-plugins/tmux-resurrect'