better tmux ecetera

This commit is contained in:
2026-03-16 11:25:10 +00:00
parent 241b50501b
commit 8e0d415afa
7 changed files with 115 additions and 82 deletions

View File

@@ -6,10 +6,11 @@ BACKUP_DIR="$HOME/dotfiles.bak"
USER="$(whoami)" USER="$(whoami)"
usage() { usage() {
echo "Usage: ./bootstrap.sh [--pull]" echo "Usage: ./bootstrap.sh [--pull | --copy]"
echo "" echo ""
echo " (no args) Install packages, sync repo -> system" echo " (no args) Install packages, sync repo -> system"
echo " --pull Sync system -> repo (pull changes back)" echo " --pull Sync system -> repo (pull changes back)"
echo " --copy Sync repo -> home only (skip packages and shell tooling)"
exit 0 exit 0
} }
@@ -36,8 +37,36 @@ pull_back() {
exit 0 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 if [[ "${1:-}" == "--pull" ]]; then
pull_back pull_back
elif [[ "${1:-}" == "--copy" ]]; then
copy_home
elif [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then elif [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
usage usage
fi fi
@@ -61,6 +90,21 @@ echo "Detected OS: $OS"
echo "" echo ""
# --- Package installation --- # --- 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() { install_packages() {
case "$OS" in case "$OS" in
macos) macos)
@@ -70,7 +114,13 @@ install_packages() {
eval "$(/opt/homebrew/bin/brew shellenv)" eval "$(/opt/homebrew/bin/brew shellenv)"
fi fi
echo "==> Installing packages via brew..." 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) arch)
if ! command -v yay &>/dev/null; then if ! command -v yay &>/dev/null; then
@@ -78,12 +128,17 @@ install_packages() {
sudo pacman -S --needed --noconfirm git base-devel sudo pacman -S --needed --noconfirm git base-devel
tmpdir=$(mktemp -d) tmpdir=$(mktemp -d)
git clone https://aur.archlinux.org/yay.git "$tmpdir/yay" git clone https://aur.archlinux.org/yay.git "$tmpdir/yay"
cd "$tmpdir/yay" && makepkg -si --noconfirm (cd "$tmpdir/yay" && makepkg -si --noconfirm)
cd "$DOTFILES_DIR"
rm -rf "$tmpdir" rm -rf "$tmpdir"
fi fi
echo "==> Installing packages via yay..." 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." echo " Unknown OS, skipping package install."
@@ -139,6 +194,15 @@ if [ ! -d "$OVERLAY_HOME" ]; then
OVERLAY_HOME="$DOTFILES_DIR/home/benk" OVERLAY_HOME="$DOTFILES_DIR/home/benk"
fi 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" echo "==> Syncing $OVERLAY_HOME -> $HOME"
mkdir -p "$BACKUP_DIR/home" mkdir -p "$BACKUP_DIR/home"
rsync -av --itemize-changes --backup --backup-dir="$BACKUP_DIR/home" \ rsync -av --itemize-changes --backup --backup-dir="$BACKUP_DIR/home" \

View File

@@ -15,5 +15,36 @@ require'nvim-treesitter.configs'.setup {
}, },
highlight = { highlight = {
enable = true 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 = { ['<leader>a'] = '@parameter.inner' },
swap_previous = { ['<leader>A'] = '@parameter.inner' },
},
},
} }

View File

@@ -134,15 +134,17 @@ return {
end end
}, },
{ {
'nvim-treesitter/nvim-treesitter-context', 'nvim-treesitter/nvim-treesitter',
branch = 'master',
build = ':TSUpdate', build = ':TSUpdate',
dependencies = {
'nvim-treesitter/nvim-treesitter',
},
config = function() config = function()
require('plugin-config/nvim-treesitter') require('plugin-config/nvim-treesitter')
end end
}, },
{
'nvim-treesitter/nvim-treesitter-context',
dependencies = { 'nvim-treesitter/nvim-treesitter' },
},
{ {
'mrjones2014/smart-splits.nvim', 'mrjones2014/smart-splits.nvim',
config = function() config = function()
@@ -160,7 +162,7 @@ return {
{ {
'gorbit99/codewindow.nvim', 'gorbit99/codewindow.nvim',
lazy = false, lazy = false,
opts = {}, dependencies = { 'nvim-treesitter/nvim-treesitter' },
config = function() config = function()
require('codewindow').apply_default_keybinds() require('codewindow').apply_default_keybinds()
end end
@@ -269,19 +271,6 @@ return {
opts = {}, opts = {},
}, },
-- FUNCTIONAL CODING STUFF -- FUNCTIONAL CODING STUFF
{
'zbirenbaum/copilot.lua',
event = 'InsertEnter',
opts = {
suggestion = {
enabled = true,
auto_trigger = true,
keymap = {
accept = '<C-y>',
}
},
}
},
{ {
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
build = "make install_jsregexp" build = "make install_jsregexp"
@@ -372,41 +361,6 @@ return {
{ {
'nvim-treesitter/nvim-treesitter-textobjects', 'nvim-treesitter/nvim-treesitter-textobjects',
dependencies = { 'nvim-treesitter/nvim-treesitter' }, 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 = { ['<leader>a'] = '@parameter.inner' },
swap_previous = { ['<leader>A'] = '@parameter.inner' },
},
},
})
end,
}, },
-- Format on save / manual format (clang-format, prettier, etc.) -- Format on save / manual format (clang-format, prettier, etc.)
{ {

View File

@@ -17,7 +17,6 @@ if is_macos then
else else
config.default_prog = { '/usr/bin/fish' } config.default_prog = { '/usr/bin/fish' }
config.enable_wayland = true config.enable_wayland = true
config.kde_window_background_blur = true
end end
config.hide_tab_bar_if_only_one_tab = true config.hide_tab_bar_if_only_one_tab = true

0
home/benk/.ssh/.gitkeep Normal file
View File

View File

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

View File

@@ -4,9 +4,10 @@ set -ga terminal-overrides ",xterm*:Tc"
set -sg escape-time 0 set -sg escape-time 0
set -g history-limit 50000 set -g history-limit 50000
# Set Fish as default shell (Apple Silicon path) # Set Fish as default shell (OS-aware path)
set-option -g default-shell /opt/homebrew/bin/fish if-shell "uname | grep -q Darwin" \
set-option -g default-command /opt/homebrew/bin/fish "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 unbind C-Enter
@@ -72,12 +73,12 @@ set -g status-right ""
set -g status-style 'bg=#f5bde6 fg=#24273a' set -g status-style 'bg=#f5bde6 fg=#24273a'
set -g pane-active-border-style "bg=default fg=#f5bde6" 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 set -g set-clipboard on
setw -g mode-keys vi setw -g mode-keys vi
bind -T copy-mode-vi v send -X begin-selection 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 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-selection 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 --- # --- Plugins ---
set -g @plugin 'tmux-plugins/tmux-resurrect' set -g @plugin 'tmux-plugins/tmux-resurrect'