From 6ae3048c2824aa19bd187ff186fbe83d6c916433 Mon Sep 17 00:00:00 2001 From: Jeremie Fraeys Date: Fri, 16 May 2025 03:23:25 -0400 Subject: [PATCH] more changes --- aerospace/.config/aerospace/aerospace.toml | 70 ++++--- bash/.bash_profile | 113 +++++------ bash/.bashrc | 184 ++++++++++++----- bash/.fzf.bash | 56 +++--- conda/.condarc | 1 + git/.gitconfig | 26 ++- nix-darwin/.config/nix-darwin/flake.nix | 57 +++--- nvim/.config/nvim | 2 +- setup.sh | 148 +++++++------- starship/.config/starship.toml | 48 ++--- wezterm/.config/wezterm/theme-switcher.lua | 7 +- wezterm/.config/wezterm/util.lua | 20 ++ wezterm/.config/wezterm/workspace.lua | 106 ++++++++++ wezterm/.wezterm.lua | 220 +++++++++++++++------ zathura/.config/zathura/zathurarc | 3 + zsh/.fzf.zsh | 40 ++-- zsh/.zprofile | 62 ++---- zsh/.zshenv | 125 +++++------- zsh/.zshrc | 151 +++++++------- 19 files changed, 880 insertions(+), 559 deletions(-) create mode 100644 wezterm/.config/wezterm/workspace.lua create mode 100644 zathura/.config/zathura/zathurarc diff --git a/aerospace/.config/aerospace/aerospace.toml b/aerospace/.config/aerospace/aerospace.toml index 5353740..8bfd892 100644 --- a/aerospace/.config/aerospace/aerospace.toml +++ b/aerospace/.config/aerospace/aerospace.toml @@ -9,6 +9,7 @@ after-login-command = [] # You can use it to add commands that run after AeroSpace startup. # 'after-startup-command' is run after 'after-login-command' # Available commands : https://nikitabobko.github.io/AeroSpace/commands +# after-startup-command = ['exec-and-forget sketchybar'] after-startup-command = [] # Start AeroSpace at login @@ -36,7 +37,7 @@ default-root-container-orientation = 'auto' # See https://nikitabobko.github.io/AeroSpace/guide#on-focus-changed-callbacks # See https://nikitabobko.github.io/AeroSpace/commands#move-mouse # Fallback value (if you omit the key): on-focused-monitor-changed = [] -on-focused-monitor-changed = ['move-mouse monitor-lazy-center'] +# on-focused-monitor-changed = ['move-mouse monitor-lazy-center'] # on-focus-changed = ['move-mouse window-lazy-center'] # You can effectively turn off macOS "Hide application" (cmd-h) feature by toggling this flag @@ -47,6 +48,13 @@ automatically-unhide-macos-hidden-apps = false # Disable window opening animation # disable-window-opening-animation = true +# Notify Sketchybar about workspace change +# exec-on-workspace-change = [ +# '/bin/bash', +# '-c', +# 'sketchybar --trigger aerospace_workspace_change FOCUSED_WORKSPACE=$AEROSPACE_FOCUSED_WORKSPACE', +# ] + # Possible values: (qwerty|dvorak) # See https://nikitabobko.github.io/AeroSpace/guide#key-mapping [key-mapping] @@ -60,12 +68,12 @@ preset = 'qwerty' # Monitor pattern is the same as for 'workspace-to-monitor-force-assignment'. # See: https://nikitabobko.github.io/AeroSpace/guide#assign-workspaces-to-monitors [gaps] +outer.left = 3 +outer.right = 3 +outer.top = 3 +outer.bottom = 5 inner.horizontal = 3 inner.vertical = 3 -outer.left = 5 -outer.bottom = 5 -outer.top = 5 -outer.right = 5 # 'main' binding mode declaration # See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes @@ -119,8 +127,10 @@ alt-shift-k = 'move up' alt-shift-l = 'move right' # See: https://nikitabobko.github.io/AeroSpace/commands#resize -# alt-shift-minus = 'resize smart -50' -# alt-shift-equal = 'resize smart +50' +alt-shift-minus = 'resize smart -50' +alt-shift-equal = 'resize smart +50' + +alt-shift-r = 'resize # See: https://nikitabobko.github.io/AeroSpace/commands#workspace alt-1 = 'workspace 1' @@ -143,6 +153,15 @@ alt-z = 'workspace Z' alt-shift-1 = 'move-node-to-workspace 1' alt-shift-2 = 'move-node-to-workspace 2' alt-shift-3 = 'move-node-to-workspace 3' +alt-shift-c = 'move-node-to-workspace C' +alt-shift-e = 'move-node-to-workspace E' +alt-shift-g = 'move-node-to-workspace G' +alt-shift-n = 'move-node-to-workspace N' +alt-shift-m = 'move-node-to-workspace M' +alt-shift-o = 'move-node-to-workspace O' +alt-shift-s = 'move-node-to-workspace S' +alt-shift-t = 'move-node-to-workspace T' +alt-shift-v = 'move-node-to-workspace V' alt-shift-x = 'move-node-to-workspace X' alt-shift-y = 'move-node-to-workspace Y' alt-shift-z = 'move-node-to-workspace Z' @@ -154,7 +173,9 @@ alt-shift-tab = 'move-workspace-to-monitor --wrap-around next' # See: https://nikitabobko.github.io/AeroSpace/commands#mode alt-shift-semicolon = 'mode service' -alt-shift-r = 'mode resize' +alt-shift-r = 'mode resize' + +alt-f = 'fullscreen' # 'service' binding mode declaration. # See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes [mode.service.binding] @@ -185,6 +206,8 @@ alt-shift-l = ['join-with right', 'mode main'] [workspace-to-monitor-force-assignment] 1 = 'main' +2 = 'main' +3 = 'main' X = ['secondary', 'dell'] Y = ['secondary', 'dell'] Z = ['secondary', 'dell'] @@ -194,17 +217,13 @@ if.app-id = 'com.apple.iCal' run = "move-node-to-workspace C" [[on-window-detected]] -if.app-id = 'org.mozilla.firefox' +if.app-id = 'com.apple.finder' +run = "move-node-to-workspace E" + +[[on-window-detected]] +if.app-id = 'app.zen-browser.zen' run = "move-node-to-workspace G" -[[on-window-detected]] -if.app-id = 'com.github.wez.wezterm' -run = "move-node-to-workspace T" - -[[on-window-detected]] -if.app-id = 'com.spotify.client' -run = "move-node-to-workspace S" - [[on-window-detected]] if.app-id = 'com.apple.MobileSMS' run = "move-node-to-workspace N" @@ -217,15 +236,18 @@ run = "move-node-to-workspace M" if.app-id = 'md.obsidian' run = "move-node-to-workspace O" +[[on-window-detected]] +if.app-id = 'com.spotify.client' +run = "move-node-to-workspace S" + +[[on-window-detected]] +if.app-id = 'com.github.wez.wezterm' +run = "move-node-to-workspace T" + [[on-window-detected]] if.app-id = 'com.vscodium' run = "move-node-to-workspace V" [[on-window-detected]] -if.app-id = 'com.apple.finder' -run = "move-node-to-workspace E" - -# after-startup-command = [ -# 'exec-and-forget borders active_color=0xffe1e3e4 inactive_color=0xff494d64 width=5.0' -# ] - +if.app-id = 'com.apple.Safari' +run = "move-node-to-workspace X" diff --git a/bash/.bash_profile b/bash/.bash_profile index 2697d82..81a097c 100755 --- a/bash/.bash_profile +++ b/bash/.bash_profile @@ -1,77 +1,70 @@ -# Ensure XDG_CONFIG_HOME is set -: "${XDG_CONFIG_HOME:=$HOME/.config}" +#!/usr/bin/env bash -# Set default pager +# ------------- Environment Setup ------------- +export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" +export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" + +# Default tools export PAGER="less -i -N -S -R" +export EDITOR="nvim" +export BROWSER="firefox" -# Ensure PYENV_ROOT is set and its bin directory is in PATH -if [ -n "$PYENV_ROOT" ] && [[ ! "$PATH" =~ (^|:)${PYENV_ROOT}/bin(:|$) ]]; then - export PATH="$PYENV_ROOT/bin:$PATH" -fi -eval "$(pyenv init -)" +# ------------- Platform-Specific Setup ------------- +OS_TYPE="$(uname -s)" -# Add ~/.local/bin to PATH if it exists -if [ -d "$HOME/.local/bin" ] && [[ ! "$PATH" =~ (^|:)${HOME}/.local/bin(:|$) ]]; then - export PATH="$HOME/.local/bin:$PATH" +# Default package manager setup (only for Debian-based systems) +if [[ "$OS_TYPE" == "Linux" ]]; then + # Debian/Ubuntu-based systems (and derivatives like WSL Ubuntu) + if command -v apt &>/dev/null; then + PACKAGE_MANAGER="apt" + export PACKAGE_MANAGER + fi fi -[[ -n ${SSH_CONNECTION} ]] && export EDITOR='vim' +# ------------- Helper Functions ------------- +safe_path_add() { + [[ -d "$1" && ":$PATH:" != *":$1:"* ]] && export PATH="$1:$PATH" +} -# Set permissions for ~/.local/bin -chmod -R ug+rwx "$HOME/.local/bin/" +# ------------- PATH Setup ------------- +safe_path_add "$HOME/.local/bin/scripts" -# Read fzf theme options if the file exists -if [ -f "$HOME/.local/bin/scripts/fzf_theme" ]; then - FZF_OPTIONS=$("$HOME/.local/bin/scripts/fzf_theme") - export FZF_DEFAULT_OPTS="$FZF_OPTIONS" +# Python Paths +[[ -n "$PYENV_ROOT" ]] && safe_path_add "$PYENV_ROOT/bin" + +# Go Paths +if command -v go &>/dev/null; then + export GOPATH="${GOPATH:-$HOME/.go}" + safe_path_add "$GOPATH/bin" fi -# Source fzf configuration -if command -v fzf >/dev/null 2>&1; then - eval "$(fzf --bash)" +# Rust +export PATH="$HOME/.cargo/bin:$PATH" + +# NVM Setup +if [[ -d "$HOME/.nvm" ]]; then + export NVM_DIR="$HOME/.nvm" + [[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh" + [[ -s "$NVM_DIR/bash_completion" ]] && source "$NVM_DIR/bash_completion" fi -[ -f ~/.fzf.bash ] && . ~/.fzf.bash - -# Add RVM to PATH if not already included -if [[ ! "$PATH" =~ (^|:)${HOME}/.rvm/bin(:|$) ]]; then - export PATH="$PATH:$HOME/.rvm/bin" +# ------------- FZF and Nix Setup ------------- +# Determine FZF installation path +if command -v fzf &>/dev/null; then + if [[ "$(command -v fzf)" == "/run/current-system/sw/bin/fzf" ]]; then + FZF_PATH="/run/current-system/sw" + else + FZF_PATH="" + fi fi -# Add Golang to PATH if not already included -if [ -n "$(go env GOPATH)" ] && [[ ! "$PATH" =~ (^|:)$(go env GOPATH)/bin(:|$) ]]; then - export GOPATH="$HOME/Documents/projects:$HOME/go" - export PATH="$PATH:$(go env GOPATH)/bin" +# Add FZF to PATH if not already there +if [[ -n "$FZF_PATH" && ! "$PATH" =~ (^|:)"$FZF_PATH"(:|$) ]]; then + export PATH="$FZF_PATH:$PATH" fi -# Cargo setup -if [ -d "$HOME/.cargo/bin" ] && [[ ! "$PATH" =~ (^|:)${HOME}/.cargo/bin(:|$) ]]; then - export PATH="$HOME/.cargo/bin:$PATH" -fi - -# >>> conda initialize >>> -# !! Contents within this block are managed by 'conda init' !! -__conda_setup="$('/usr/local/Caskroom/miniforge/base/bin/conda' 'shell.bash' 'hook' 2>/dev/null)" -if [ $? -eq 0 ]; then - eval "$__conda_setup" -else - if [ -f "/usr/local/Caskroom/miniforge/base/etc/profile.d/conda.sh" ]; then - . "/usr/local/Caskroom/miniforge/base/etc/profile.d/conda.sh" - else - export PATH="/usr/local/Caskroom/miniforge/base/bin:$PATH" - fi -fi -unset __conda_setup -# <<< conda initialize <<< - -# Check for WSL and adjust configurations -if grep -q Microsoft /proc/version; then - # Ensure WSL compatibility for Conda if using Miniforge - if [ -f "/mnt/c/Users/$USER/AppData/Local/Miniconda3/etc/profile.d/conda.sh" ]; then - . "/mnt/c/Users/$USER/AppData/Local/Miniconda3/etc/profile.d/conda.sh" - fi -else - # Unix-specific configuration (Linux/macOS) - # Add any Unix-specific paths or configurations here - export PATH="/usr/local/bin:$PATH" +# Ensure Nix user profile is in PATH (for NixOS users) +if [[ -d "$HOME/.nix-profile/bin" && ! "$PATH" =~ (^|:)"$HOME/.nix-profile/bin"(:|$) ]]; then + export PATH="$HOME/.nix-profile/bin:$PATH" fi diff --git a/bash/.bashrc b/bash/.bashrc index b4b5528..253b4dc 100755 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -1,62 +1,148 @@ -# Load bash completion -if [[ -f /etc/bash_completion ]]; then - . /etc/bash_completion +#!/usr/bin/env bash + +# ================ Basic Settings ================ +# Disable auto title (not applicable to Bash directly, but can be handled through prompts) +DISABLE_AUTO_TITLE="true" + +# Miscellaneous settings (uncomment as needed) +# DISABLE_LS_COLORS="true" +# ENABLE_CORRECTION="true" +# COMPLETION_WAITING_DOTS="true" + +# ================ Path Optimizations ================ +# Ensure no duplicates in PATH +typeset -U PATH + +# ================ Bash Completion Settings ================ +# Enable Bash completions (assuming Bash-completion is installed) +if command -v "$PACKAGE_MANAGER" &>/dev/null; then + # Install bash-completion if not already installed + if ! command -v bash-completion &>/dev/null; then + echo "Installing bash-completion..." + "$PACKAGE_MANAGER" install bash-completion + fi + # Source bash-completion if installed + if [ -f "/usr/local/etc/bash_completion" ]; then + . "/usr/local/etc/bash_completion" + fi fi -# Check for WSL and adjust accordingly -if grep -q Microsoft /proc/version; then - # WSL-specific configuration - - # Set path to Windows executables for easy access - export PATH="/mnt/c/Windows/System32:$PATH" - export PATH="/mnt/c/Program Files:$PATH" - export PATH="/mnt/c/Windows:$PATH" - - # Use Windows Notepad or other executables from WSL - alias notepad="notepad.exe" - alias explorer="explorer.exe" -else - # Unix-specific configuration (Linux or macOS) - # You can add Unix-specific tools and paths here if needed - # For example, add custom Linux paths if they are different from default - export PATH="/usr/local/bin:$PATH" +# ================ Plugin Manager (Bash-it) ================ +# Setup and initialize Bash-it, a Bash plugin manager +if [ -z "$BASH_IT" ]; then + export BASH_IT="$HOME/.bash_it" fi -# Custom aliases -alias python="python3" +# Install Bash-it if it's not already installed +if [ ! -d "$BASH_IT" ]; then + git clone --depth=1 https://github.com/Bash-it/bash-it.git "$BASH_IT" + "$BASH_IT/install.sh" +fi + +# Source the Bash-it script to enable plugin management +. "$BASH_IT/bash_it.sh" + +# ================ Bash-it Plugin Configuration ================ +# Enable essential plugins using Bash-it (it will handle checks internally) +bash-it enable plugin git +bash-it enable plugin history +bash-it enable plugin fasd +bash-it enable plugin autojump + +# Enable themes +bash-it enable theme bobby + +# ================ Docker Completions ================ +# Check for Docker completion file and source it if exists +if [ -f "$HOME/.docker-completion.bash" ]; then + . "$HOME/.docker-completion.bash" +fi + +# ================ zoxide Plugin ================ +# Install zoxide (navigation tool for frequently used directories) +if ! command -v zoxide &>/dev/null; then + echo "zoxide is not installed. Installing..." + if ! command -v "$PACKAGE_MANAGER" &>/dev/null; then + echo "Package manager is not available!" + else + "$PACKAGE_MANAGER" install zoxide + fi +fi + +# Initialize zoxide +eval "$(zoxide init bash)" + +# ================ fzf Plugin ================ +# Install fzf, a command-line fuzzy finder +if ! command -v fzf &>/dev/null; then + git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf + ~/.fzf/install --no-key-bindings --no-completion --no-update-rc +fi + +# Load fzf shell integration if available +if [ -f "$HOME/.fzf.bash" ]; then + . "$HOME/.fzf.bash" +fi + +# ================ eza Installation ================ +# Install eza (enhanced 'ls' command) +if ! command -v eza &>/dev/null; then + echo "eza is not installed. Installing..." + if ! command -v "$PACKAGE_MANAGER" &>/dev/null; then + echo "Package manager is not available!" + else + "$PACKAGE_MANAGER" install eza + fi +fi + +# ================ Additional Programs Initialization ================ +# Initialize direnv (uncomment if needed) +# eval "$(direnv hook bash)" + +# Initialize Starship prompt +if ! command -v starship &>/dev/null; then + curl -fsSL https://starship.rs/install.sh | bash +fi +eval "$(starship init bash)" +export STARSHIP_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/starship.toml" + +# ================ Conda Initialization ================ +# Initialize Conda (uncomment if you use Conda) +# eval "$(conda init bash)" + +# ================ Pyenv Setup ================ +# Initialize Pyenv if installed +if command -v pyenv &>/dev/null; then + export PYENV_ROOT="$HOME/.pyenv" + [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" + eval "$(pyenv init --path)" +fi + +# ================ Custom Aliases ================ +# Define commonly used aliases alias grep="grep --color=auto" - alias ..="cd .." alias ...="cd ../.." alias ....="cd ../../.." alias .....="cd ../../../.." +alias v='nvim' -# Load custom check_aliases if it exists -if [[ -f "$HOME/.local/bin/scripts/check_aliases" ]]; then - . "$HOME/.local/bin/scripts/check_aliases" +# Use eza for enhanced 'ls' command +alias ls='eza' +alias ll='eza -lh --group-directories-first' +alias la='eza -a' +alias lla='eza -la --group-directories-first' +alias l='eza --classify' + +# Source additional alias checks if available +if [[ -f ~/.local/bin/scripts/check_aliases ]]; then + . ~/.local/bin/scripts/check_aliases.sh fi -# Set the default editor -export EDITOR='nvim' +# ================ Conditional Settings ================ +# Set the editor to vim if using SSH +[[ -n ${SSH_CONNECTION} ]] && export EDITOR='vim' -# Add eza completions to BASH_COMPLETION if not already included -if [[ ! "$BASH_COMPLETION" =~ (^|:)${HOME}/.local/bin/eza/completions/bash(:|$) ]]; then - export BASH_COMPLETION="$HOME/.local/bin/eza/completions/bash:$BASH_COMPLETION" -fi - -# Initialize zoxide -if command -v zoxide &>/dev/null; then - eval "$(zoxide init bash)" -fi - -# Initialize Starship -if command -v starship &>/dev/null; then - eval "$(starship init bash)" -fi - -# Optionally, initialize other tools for Unix and WSL environments -if command -v wslpath &>/dev/null; then - # Adjust paths between WSL and Windows if necessary - export PATH="$(wslpath 'C:\Program Files'):$PATH" - export PATH="/mnt/c/Program Files/neovim/bin:$PATH" -fi +# ================ Profiling (Optional) ================ +# Uncomment to enable profiling (useful for debugging) +# bash-profiler # Comment out if profiling is not needed diff --git a/bash/.fzf.bash b/bash/.fzf.bash index a282583..3c573b8 100755 --- a/bash/.fzf.bash +++ b/bash/.fzf.bash @@ -1,32 +1,40 @@ -# Setup fzf -# --------- -# Get the path to fzf installed by Nix or from a general location -FZF_PATH="$(command -v fzf | xargs dirname)" +#!/usr/bin/env bash -# Ensure the fzf binary is in the PATH (if not already added) -if [[ ! "$PATH" == *"$FZF_PATH/bin"* ]]; then - PATH="${PATH:+${PATH}:}$FZF_PATH/bin" +# Indicate the shell explicitly +export FZF_SHELL="bash" + +# Detect OS and environment +IS_WSL=false + +if [[ -f /proc/sys/kernel/osrelease ]] && grep -qi "microsoft" /proc/sys/kernel/osrelease; then + IS_WSL=true fi -# Auto-completion -# --------------- -if [[ -f "$FZF_PATH/shell/completion.bash" ]]; then - source "$FZF_PATH/shell/completion.bash" +# Determine fzf path if installed +if command -v fzf >/dev/null; then + export FZF_PATH="$(dirname "$(command -v fzf)")" +else + export FZF_PATH="" fi -# Key bindings -# ------------ -if [[ -f "$FZF_PATH/shell/key-bindings.bash" ]]; then - source "$FZF_PATH/shell/key-bindings.bash" +# Source fzf key bindings and completions based on environment +if command -v fzf >/dev/null; then + # Linux or macOS typical install + [ -f "$FZF_PATH/key-bindings.bash" ] && source "$FZF_PATH/key-bindings.bash" + [ -f "$FZF_PATH/completion.bash" ] && source "$FZF_PATH/completion.bash" +elif $IS_WSL; then + # Windows install accessed via WSL + WIN_FZF_DIR="/mnt/c/Program Files/fzf/shell" + [ -f "$WIN_FZF_DIR/key-bindings.bash" ] && source "$WIN_FZF_DIR/key-bindings.bash" + [ -f "$WIN_FZF_DIR/completion.bash" ] && source "$WIN_FZF_DIR/completion.bash" fi -# Check for WSL and ensure compatibility -if grep -q Microsoft /proc/version; then - # WSL-specific path handling (if needed) - if [[ -f "/mnt/c/Program Files/fzf/shell/completion.bash" ]]; then - source "/mnt/c/Program Files/fzf/shell/completion.bash" - fi - if [[ -f "/mnt/c/Program Files/fzf/shell/key-bindings.bash" ]]; then - source "/mnt/c/Program Files/fzf/shell/key-bindings.bash" - fi +# Load fzf theme if available +FZF_THEME_SCRIPT="$HOME/.local/bin/scripts/fzf_theme.sh" +if [[ -f "$FZF_THEME_SCRIPT" ]]; then + # Use custom theme script if it exists + export FZF_DEFAULT_OPTS="$($FZF_THEME_SCRIPT) --height 40% --layout=reverse --border" +else + # Fallback to default options + export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border" fi diff --git a/conda/.condarc b/conda/.condarc index cfc6671..2c3f45e 100755 --- a/conda/.condarc +++ b/conda/.condarc @@ -4,3 +4,4 @@ auto_activate_base: false changeps1: false channel_priority: strict + diff --git a/git/.gitconfig b/git/.gitconfig index 8d723e9..08154c9 100755 --- a/git/.gitconfig +++ b/git/.gitconfig @@ -4,8 +4,30 @@ name = Jeremie Fraeys email = jfaeys@gmail.com [credential] - helper = store -[credentials] helper = osxkeychain [init] defaultBranch = main +[core] + compression = 9 + whitespace = error + pager = delta + side-by-side = true + line-numbers = true + preload = true +[interactive] + diffFilter = delta --color-only +[delta] + navigate = true +[merge] + conflictStyle = zdiff3 +[status] + branch = true + showStash = true + showUntrackedFiles = all + +[url "git@github.com:"] + insteadOf = "gh:" + +[url "git@github.com:jfraeys/"] + insteadOf = "cj:" + diff --git a/nix-darwin/.config/nix-darwin/flake.nix b/nix-darwin/.config/nix-darwin/flake.nix index 74fc670..a319788 100644 --- a/nix-darwin/.config/nix-darwin/flake.nix +++ b/nix-darwin/.config/nix-darwin/flake.nix @@ -28,27 +28,22 @@ }; # System packages - environment.systemPackages = with pkgs; [ - neovim wezterm git ripgrep fd pyenv mos docker docker-compose gh rustup - sd sphinx starship stow tree zoxide spotify direnv unibilium uv raycast skim - eza fzf zsh gettext python3 ruff lua luarocks bat go openssl topgrade vault - yamllint - - (zathura.overrideAttrs (finalAttrs: previousAttrs: { - pname = previousAttrs.pname + "-with-synctex"; - nativeBuildInputs = previousAttrs.nativeBuildInputs or [] ++ [ pkgs.pkg-config ]; - enableSynctex = true; - zathuraPlugins = [ "zathura-pdf-poppler" ]; - })) - ]; + environment.systemPackages = with pkgs; [ + neovim wezterm git ripgrep fd pyenv mos docker docker-compose gh rustup + sd sphinx starship stow tree zoxide spotify unibilium uv raycast skim + eza fzf zsh gettext python3 lua luarocks bat go openssl topgrade vault + yamllint jq yq lazydocker delta bottom luarocks zig pkg-config cmake cairo + k3d kubectl kubectx golangci-lint ollama duckdb + ]; # Fonts - fonts.packages = with pkgs; [ nerd-fonts.meslo-lg ]; + fonts.packages = with pkgs; [ nerd-fonts.meslo-lg nerd-fonts.fira-code ]; # Homebrew setup homebrew = { enable = true; - brews = [ "mas" "shpotify" "zathura-pdf-poppler" "girara" ]; + brews = [ "mas" "shpotify" "colima" "ruff" "zathura" "zathura-pdf-poppler" ]; + # brews = [ "mas" "shpotify" "colima" "ruff" ]; casks = [ { name = "zotero"; greedy = true; } { name = "microsoft-teams"; greedy = true; } @@ -61,10 +56,17 @@ { name = "google-drive"; greedy = true; } { name = "vscodium"; greedy = true; } { name = "mactex-no-gui"; greedy = true; } - { name = "notion"; greedy = true;} - { name = "obsidian"; greedy = true;} + { name = "notion"; greedy = true; } + { name = "obsidian"; greedy = true; } + { name = "display-pilot"; greedy = true; } + { name = "zen-browser"; greedy = true; } ]; - masApps = { "notability" = 360593530; }; + masApps = { + "notability" = 360593530; + "keynote" = 409183694; + "pages" = 409201541; + "numbers" = 409203825; + }; taps = [ "nikitabobko/tap" "zegervdv/zathura" ]; onActivation = { cleanup = "zap"; @@ -112,7 +114,8 @@ "/System/Applications/Calendar.app" "/System/Applications/FaceTime.app" "/System/Applications/System Settings.app" - "/Applications/Firefox.app" + # "/Applications/Firefox.app" + "/Applications/Zen.app/" ]; persistent-others = [ "/Users/jfraeys/Downloads" @@ -151,8 +154,8 @@ ''; # Enable Nix daemon and Touch ID - services.nix-daemon.enable = true; - security.pam.enableSudoTouchIdAuth = true; + # services.nix-daemon.enable = true; + security.pam.services.sudo_local.touchIdAuth = true; # Home Manager integration home-manager = { @@ -162,18 +165,24 @@ backupFileExtension = "backup"; }; + nixpkgs.hostPlatform = "aarch64-darwin"; + # Nix configuration nix = { - configureBuildUsers = true; - useDaemon = true; + # configureBuildUsers = true; + # useDaemon = true; settings.experimental-features = [ "nix-command" "flakes" ]; + extraOptions = '' + extra-platforms = x86_64-darwin aarch64-darwin + ''; + }; }; in { darwinConfigurations = { "${hostname}" = nix-darwin.lib.darwinSystem { - system = "aarch64-darwin"; + # system = "aarch64-darwin"; modules = [ configuration nix-homebrew.darwinModules.nix-homebrew diff --git a/nvim/.config/nvim b/nvim/.config/nvim index a357fc9..9759205 160000 --- a/nvim/.config/nvim +++ b/nvim/.config/nvim @@ -1 +1 @@ -Subproject commit a357fc959ed9abcfd3c66cc9796282d229f03871 +Subproject commit 9759205e22863960be91cfe626e3141a240df198 diff --git a/setup.sh b/setup.sh index 388c242..56b17d2 100755 --- a/setup.sh +++ b/setup.sh @@ -2,8 +2,8 @@ # Check for Git if ! command -v git &>/dev/null; then - echo "Git is not installed. Aborting." >&2 - exit 1 + echo "Git is not installed. Aborting." >&2 + exit 1 fi # Make sure we have pulled in and updated any submodules @@ -12,87 +12,84 @@ git submodule update # What directories should be installable by all users including the root user base=( - vim - nvim - # tmux - git - wezterm - nix-darwin + vim + nvim + # tmux + git + wezterm ) # Folders that should, or only need to be installed for a local user on macOS useronly_macos=( - zsh - # yabai - # skhd - aerospace - # oh-my-zsh + zsh + aerospace + # sketchybar ) #Folders that should, or only need to be installed for a local user on Linux useronly_linux=( - bash - i3 + bash + i3 ) # Folders that should, or only need to be installed for a local user useronly=( - zoxide - conda - dask - gh - jupyter - parallel - tox - firefox - # direnv - starship - # p10k + zoxide + conda + dask + direnv + gh + jupyter + parallel + tox + firefox + starship + zathura ) # Files to ignore during stow ignore_files=( - ".DS_Store" - "__setup" - "bin" - ".git" - ".gitignore" - "setup.sh" + ".DS_Store" + "__setup" + "bin" + ".git" + ".gitignore" + "setup.sh" ) # Function to run the stow command for the passed-in directory ($2) in location $1 stowit() { - usr=$1 - app=$2 - # -v verbose - # -R recursive - # -t target - # --ignore files to ignore - stow -v -R -t "${usr}" --ignore "$( - IFS="|" - echo "${ignore_files[*]}" - )" "${app}" + usr=$1 + app=$2 + # -v verbose + # -R recursive + # -t target + # --ignore files to ignore + stow -v -R -t "${usr}" --ignore "$( + IFS="|" + echo "${ignore_files[*]}" + )" "${app}" } # Function to check if the OS is macOS get_os() { - case "$(uname)" in - Darwin) echo "macos" ;; - Linux) echo "linux" ;; - *) echo "unknown" ;; - esac + case "$(uname)" in + Darwin) echo "macos" ;; + Linux) echo "linux" ;; + *) echo "unknown" ;; + esac } # Function to automate firefox profile updater with expect expect_yes() { - profile_dir=$(find ~/Library/Application\ Support/Firefox/Profiles -type d -name '*.default-release' -print -quit) + profile_dir=$(find ~/Library/Application\ Support/Firefox/Profiles -type d -name '*.default-release' -print -quit) - if [ -z "$profile_dir" ]; then - echo "Error: Firefox profile directory not found." - exit 1 - fi + if [ -z "$profile_dir" ]; then + echo "Error: Firefox profile directory not found." + exit 1 + fi - expect -c " + expect -c " set timeout 1 log_user 0 spawn bash -c \"cd '$profile_dir' && $1\" > /dev/null 2>&1 @@ -111,39 +108,36 @@ echo "Stowing apps for user: ${USER}" # Setup apps available to local users and root for app in "${base[@]}"; do - stowit "${HOME}" "${app}" + stowit "${HOME}" "${app}" done current_os=$(get_os) case "${current_os}" in "macos") - for app in "${useronly_macos[@]}"; do - if [ "$(id -u)" -ne 0 ]; then - stowit "${HOME}" "${app}" - fi - done - ;; + for app in "${useronly_macos[@]}"; do + if [ "$(id -u)" -ne 0 ]; then + stowit "${HOME}" "${app}" + fi + done + ;; "linux") - for app in "${useronly_linux[@]}"; do - if [ "$(id -u)" -ne 0 ]; then - stowit "${HOME}" "${app}" - fi - done - ;; + for app in "${useronly_linux[@]}"; do + if [ "$(id -u)" -ne 0 ]; then + stowit "${HOME}" "${app}" + fi + done + ;; "unknown") - echo "Unknown OS." - ;; + echo "Unknown OS." + ;; esac # Setup useronly folders for app in "${useronly[@]}"; do - if [ "$(id -u)" -ne 0 ]; then - stowit "${HOME}" "${app}" - if [[ "${app}" = "firefox" ]]; then - expect_yes "./updater.sh" - fi - fi + if [ "$(id -u)" -ne 0 ]; then + stowit "${HOME}" "${app}" + if [[ "${app}" = "firefox" ]]; then + expect_yes "./updater.sh" + fi + fi done - -echo "" -echo "##### ALL DONE" diff --git a/starship/.config/starship.toml b/starship/.config/starship.toml index 50bf6cf..5ccd25b 100644 --- a/starship/.config/starship.toml +++ b/starship/.config/starship.toml @@ -8,7 +8,9 @@ command_timeout = 5000 # Customize your prompt to ensure everything is on a single line format = """\ + $character\ $directory\ + $direnv\ $docker_context\ $conda\ $golang\ @@ -19,7 +21,6 @@ format = """\ $package\ $line_break\ $jobs\ - $character\ """ right_format = """\ @@ -31,30 +32,30 @@ right_format = """\ # Git branch configuration [git_branch] -format = "[ $branch(:$remote_branch)]($style)" +format = "[$branch(:$remote_branch) ]($style)" style = "bold red" # Git status configuration [git_status] -format = '[ $all_status]($style)' +format = '[$all_status ]($style)' style = "bold green" # Git metric configuration [git_metrics] -format = '([ $added]($added_style))([ $deleted]($deleted_style))' +format = '([$added ]($added_style))([$deleted ]($deleted_style))' added_style = "green" deleted_style = "red" -disabled = false +disabled = true # Configure the overall look of the prompt [character] -success_symbol = "[ ❯](bold green)" -error_symbol = "[ ✗](bold red)" -vimcmd_symbol = "[ V](bold green)" +success_symbol = "[❯](bold green)" +error_symbol = "[✗](bold red)" +vimcmd_symbol = "[V](bold green)" # Directory [directory] -format = "[$path]($style)[$read_only]($read_only_style)" +format = "[$path ]($style)[$read_only]($read_only_style)" style = "bright-cyan" truncation_length = 3 truncation_symbol = "…/" @@ -63,59 +64,63 @@ truncation_symbol = "…/" disabled = true [jobs] -format = '[ $symbol$count]($style)' +format = '[$symbol$count ]($style)' number_threshold = 4 [cmd_duration] -format = "[ $duration]($style)" +format = "[$duration ]($style)" style = "yellow" +[direnv] +format = '[$symbol$loaded/$allowed ]($style)' +disabled = false + # Container [container] -format = '[ $symbol \[$name\]]($style)' +format = '[$symbol \[$name\] ]($style)' style = "orange" # Docker [docker_context] -format = '[ $symbol$container]($style)' +format = '[$symbol$container ]($style)' style = "blue" # C [c] -format = "[ $symbol($version(-$name) )]($style)" +format = "[$symbol($version(-$name)) ]($style)" style = "bold green" detect_files = ["Makefile"] # Conda [conda] -format = "[ $environment]($style)" -style = "green" +format = "[$environment ]($style)" +style = "dimmed green" # Python [python] -format = "[ ${symbol}(${version})(\\($virtualenv\\) )]($style)" +format = "[${symbol}(${version})(\\($virtualenv\\)) ]($style)" # pyenv_version_name = true style = "blue" detect_files = ["Pipfile", "pyproject.toml", "poetry.lock", "requirements.txt"] # Golang [golang] -format = "[ $symbol($version)($mod_version)]($style)" +format = "[$symbol($version)($mod_version) ]($style)" style = "blue" # Rust [rust] -format = "[ $symbol$version]($style)" +format = "[$symbol$version ]($style)" style = "purple" # Lua [lua] -format = "[ $symbol$version]($style)" +format = "[$symbol$version ]($style)" style = "purple" # Package [package] -format = "[ $symbol$version]($style)" +format = "[$symbol$version ]($style)" style = "208 bold" # Directory substitutions @@ -182,4 +187,3 @@ surface0 = "#fdf6e3" base = "#fdf6e3" mantle = "#fdf6e3" crust = "#fdf6e3" - diff --git a/wezterm/.config/wezterm/theme-switcher.lua b/wezterm/.config/wezterm/theme-switcher.lua index 9061f67..f8237b0 100644 --- a/wezterm/.config/wezterm/theme-switcher.lua +++ b/wezterm/.config/wezterm/theme-switcher.lua @@ -42,6 +42,8 @@ local tab_bar_colors = { -- Check if a command is available (more reliable implementation) local function is_command_available(cmd) + wezterm.log_info(os.execute("/usr/bin/env bash -c 'command -v " .. cmd .. "'")) + wezterm.log_info("WezTerm PATH: " .. os.getenv("PATH")) return os.execute("type " .. cmd .. " >/dev/null 2>&1") == 0 end @@ -67,6 +69,9 @@ local function update_starship_palette(palette_name) local replace_command = string.format("%s 's/palette = .*/palette = \"%s\"/' %s", sed_inplace, palette_name, starship_config_path) + wezterm.log_info("Starship config path: " .. starship_config_path) + wezterm.log_info("Generated reaplce command: " .. replace_command) + -- Use `sd` if available for consistency if is_command_available("sd") then replace_command = string.format("sd 'palette = .+' 'palette = \"%s\"' %s", palette_name, starship_config_path) @@ -84,9 +89,7 @@ end -- Apply the configuration and update Starship palette function M.apply_to_config(config) local appearance = get_appearance() - wezterm.log_info("Appearance detected: " .. appearance) config.color_scheme = scheme_for_appearance(appearance, color_schemes) - wezterm.log_info("Using color scheme: " .. config.color_scheme) config.colors = { tab_bar = scheme_for_appearance(appearance, tab_bar_colors) } -- Update the Starship palette based on appearance diff --git a/wezterm/.config/wezterm/util.lua b/wezterm/.config/wezterm/util.lua index fd7e6e1..95d5ae1 100644 --- a/wezterm/.config/wezterm/util.lua +++ b/wezterm/.config/wezterm/util.lua @@ -1,3 +1,4 @@ +local wezterm = require("wezterm") local M = {} M.filter = function(tbl, callback) @@ -11,4 +12,23 @@ M.filter = function(tbl, callback) return filt_table end +M.log_info = function(msg) + wezterm.log_info("[workspace] " .. msg) +end + +M.log_error = function(msg) + wezterm.log_error("[workspace] " .. msg) +end + +M.merge_tables = function(t1, t2) + local result = {} + for k, v in pairs(t1 or {}) do + result[k] = v + end + for k, v in pairs(t2 or {}) do + result[k] = v + end + return result +end + return M diff --git a/wezterm/.config/wezterm/workspace.lua b/wezterm/.config/wezterm/workspace.lua new file mode 100644 index 0000000..33953d2 --- /dev/null +++ b/wezterm/.config/wezterm/workspace.lua @@ -0,0 +1,106 @@ +local wezterm = require("wezterm") +local util = require("util") -- Make sure this module exports a `filter` function +local act = wezterm.action + +local M = {} + +--- Switch to a workspace and optionally spawn a command or pass SwitchToWorkspace options +-- @param window wezterm.Window: The active window +-- @param pane wezterm.Pane: The active pane +-- @param opts table: Options table containing: +-- - name (string): Name of the target workspace (required) +-- - spawn (table)?: Arguments for SpawnCommandInNewTab +-- - switch_opts (table)?: Extra options for SwitchToWorkspace +M.switch_workspace = function(window, pane, opts) + opts = opts or {} + + wezterm.log_info(opts) + + if not opts.name then + wezterm.log_error("Missing workspace name in switch_workspace()") + return + end + + local workspace_name = opts.name + local current_workspace = window:active_workspace() + + if current_workspace == workspace_name then + return + end + + wezterm.GLOBAL.previous_workspace = current_workspace + + -- Merge workspace name with user-provided SwitchToWorkspace options + local switch_args = { name = workspace_name } + if opts.switch_opts then + for k, v in pairs(opts.switch_opts) do + switch_args[k] = v + end + end + + window:perform_action(act.SwitchToWorkspace(switch_args), pane) + + if opts.spawn then + wezterm.log_info("Spawning in new tab for workspace: " .. workspace_name) + window:perform_action(act.SpawnCommandInNewTab(opts.spawn), pane) + end +end + +--- Switch back to the previously used workspace +M.switch_to_previous_workspace = function(window, pane) + local previous = wezterm.GLOBAL.previous_workspace + if not previous then + wezterm.log_info("No previous workspace is set.") + return + end + + local current = window:active_workspace() + if current == previous then + return + end + + M.switch_workspace(window, pane, { name = previous }) +end + +--- Kill all panes in a given workspace +-- @param workspace string: The name of the workspace to kill +M.kill_workspace = function(workspace) + wezterm.log_info("Killing all panes in workspace: " .. workspace) + + local success, stdout, stderr = wezterm.run_child_process({ + "wezterm", + "cli", + "list", + "--format=json", + }) + + if not success or not stdout then + wezterm.log_error("Failed to run wezterm list. Error: " .. (stderr or "unknown")) + return + end + + local panes = wezterm.json_parse(stdout) + if not panes then + wezterm.log_error("Failed to parse pane list JSON.") + return + end + + local matching = util.filter(panes, function(p) + return p.workspace == workspace + end) + + if #matching == 0 then + wezterm.log_info("No panes to kill in workspace: " .. workspace) + end + + for _, pane in ipairs(matching) do + wezterm.run_child_process({ + "wezterm", + "cli", + "kill-pane", + "--pane-id=" .. pane.pane_id, + }) + end +end + +return M diff --git a/wezterm/.wezterm.lua b/wezterm/.wezterm.lua index 361f9c5..55015b3 100644 --- a/wezterm/.wezterm.lua +++ b/wezterm/.wezterm.lua @@ -4,9 +4,9 @@ local act = wezterm.action -- Pull custom modules local theme = require("theme-switcher") --- local kill_workspace = require("kill-workspace") local sessionizer = require("sessionizer.plugin.init") -- local gpu_adapters = require("gpu-adapter") +local workspace = require("workspace") local config = {} @@ -20,21 +20,17 @@ end -- Check the platform and configure settings accordingly if wezterm.target_triple == "x86_64-pc-windows-msvc" then config.default_prog = { "wsl.exe", "~", "-d", "Ubuntu-20.04" } -elseif wezterm.target_triple == "x86_64-apple-darwin" then - config.default_prog = { "/bin/zsh", "-l" } - config.font = wezterm.font_with_fallback({ - { family = "MesloLGS NF", scale = 1.0 }, - { family = "Menlo", scale = 1.0 }, - }) -elseif wezterm.target_triple == "aarch64-apple-darwin" then - config.default_prog = { "/bin/zsh", "-l" } +elseif wezterm.target_triple == "x86_64-apple-darwin" or wezterm.target_triple == "aarch64-apple-darwin" then + config.default_prog = { "/bin/zsh" } config.font = wezterm.font_with_fallback({ + { family = "Fira Code", scale = 1.0 }, { family = "MesloLGS NF", scale = 1.0 }, { family = "Menlo", scale = 1.0 }, }) elseif wezterm.target_triple == "x86_64-unknown-linux-gnu" then - config.default_prog = { "/bin/bash", "-l" } + config.default_prog = { "/bin/bash" } config.font = wezterm.font_with_fallback({ + { family = "Fira Code", scale = 1.0 }, { family = "MesloLGS NF", scale = 1.0 }, { family = "Ubuntu Mono", scale = 1.0 }, }) @@ -43,20 +39,20 @@ end config.check_for_updates = true config.use_ime = true config.use_dead_keys = false +config.front_end = "WebGpu" config.term = "xterm-256color" theme.apply_to_config(config) config.line_height = 1.1 config.animation_fps = 240 config.max_fps = 240 -config.front_end = "WebGpu" config.webgpu_power_preference = "HighPerformance" -- config.webgpu_preferred_adapter = gpu_adapters:pick_best() config.window_padding = { left = 5, right = 10, - top = 10, + top = 5, bottom = 5, } @@ -71,7 +67,6 @@ config.inactive_pane_hsb = { config.initial_rows = 50 config.initial_cols = 140 -config.use_dead_keys = false config.enable_scroll_bar = false config.scrollback_lines = 3000 @@ -139,7 +134,7 @@ config.leader = { key = "a", mods = "CTRL", timeout_milliseconds = 1000 } local keys = { { key = "LeftArrow", mods = "OPT", action = act.SendString("\x1bb") }, - { key = "RightArrow", mods = "OPT", action = act.SendString("\x1bf") }, + { key = "RightArrow", mods = "OPT", action = act.SendString("\x1bw") }, -- The physical CMD key on OSX is the Alt key on Win/*nix, so map the common Alt-combo commands. { key = ".", mods = "CMD", action = act.SendString("\x1b.") }, @@ -175,7 +170,7 @@ local keys = { key = "]", mods = "LEADER", action = act.SpawnCommandInNewTab({ - args = { config.default_prog[1], "-c", "wzp" }, + args = { config.default_prog[1], "-c", "scripts/wzp" }, }), }, @@ -234,22 +229,21 @@ local keys = { -- }, --open wezterm config quickly - { - key = ",", - mods = "LEADER", - action = wezterm.action.SpawnCommandInNewTab({ - cwd = os.getenv("WEZTERM_CONFIG_DIR") or os.getenv("HOME"), -- Use home directory if $WEZTERM_CONFIG_DIR is not set - set_environment_variables = { - TERM = "screen-256color", - }, - args = { - config.default_prog[1], - "-c", - os.getenv("EDITOR") or "vi", -- Default to vi if $EDITOR is not set - os.getenv("WEZTERM_CONFIG_FILE"), - }, - }), - }, + -- { + -- key = ",", + -- mods = "LEADER", + -- action = wezterm.action.SpawnCommandInNewTab({ + -- set_environment_variables = { + -- TERM = "screen-256color", + -- }, + -- args = { + -- config.default_prog[1], + -- "-c", + -- os.getenv("EDITOR") or "vim", + -- os.getenv("~") .. "/.config/wezterm/.wezterm.lua", + -- }, + -- }), + -- }, { key = "r", @@ -257,29 +251,47 @@ local keys = { action = act.ReloadConfiguration, }, - -- Swich to default orkspace + -- Swich to default workspace { key = "y", mods = "CTRL | SHIFT", - action = act.SwitchToWorkspace({ - name = "default", - }), + action = wezterm.action_callback(function(window, pane) + wezterm.log_info("Switching to default workspace") + workspace.switch_workspace(window, pane, { name = "default" }) + end), + }, + + -- Switch to previous workspace + { + key = "u", + mods = "CTRL | SHIFT", + action = wezterm.action_callback(function(window, pane) + workspace.switch_to_previous_workspace(window, pane) + end), }, --Switch to monitoring workspace { key = ".", mods = "CTRL | SHIFT", - action = act.SwitchToWorkspace({ - name = "monitoring", - spawn = { - args = { "btm" }, - }, - }), + action = wezterm.action_callback(function(window, pane) + workspace.switch_workspace(window, pane, { + name = "monitoring", + spawn = { + args = { "btm" }, + }, + }) + end), }, -- Create a new workspace with a randomm name and switch to it - { key = "i", mods = "CTRL | SHIFT", action = act.SwitchToWorkspace }, + { + key = "i", + mods = "CTRL | SHIFT", + action = wezterm.action_callback(function(window, pane) + workspace.switch_workspace(window, pane) + end), + }, -- Rename workspaces { @@ -297,7 +309,7 @@ local keys = { -- Or the actual line of text they wrote if line then window:perform_action( - act.SwitchToWorkspace({ + workspace.switch_workspace({ name = line, }), pane @@ -307,6 +319,45 @@ local keys = { }), }, + -- Trigger QuickSelect for path-based file opening + { + key = "O", + mods = "CTRL|SHIFT", + action = wezterm.action.QuickSelectArgs({ + label = "Open file", + patterns = { + [[/[\w./-]+]], -- Absolute paths + [[\./[\w./-]+]], -- Relative paths + }, + action = wezterm.action_callback(function(window, pane) + local selection = window:get_selection_text_for_pane(pane) + if selection and #selection > 0 then + -- Check if the file exists + local success = wezterm.run_child_process({ + "sh", + "-c", + "test -e '" .. selection .. "'", + }) == nil + + if success then + -- Open with terminal editor in a new workspace + window:perform_action( + wezterm.action.SpawnWindow({ + workspace = "file:" .. selection, -- Workspace named after the file + args = { "nvim", selection }, -- Change to "vim" or "nano" if preferred + }), + pane + ) + else + -- Fallback to opening with the default app + wezterm.log_info("Opening with default app: " .. selection) + wezterm.open_with(selection) + end + end + end), + }), + }, + --Show launcher in fuzzy selecton mode { key = "s", @@ -410,6 +461,18 @@ local key_tables = { { key = "p", mods = "CTRL", action = act({ CopyMode = "PriorMatch" }) }, { key = "r", mods = "CTRL", action = act.CopyMode("CycleMatchType") }, { key = "u", mods = "CTRL", action = act.CopyMode("ClearPattern") }, + { + key = "PageUp", + mods = "NONE", + action = act.CopyMode("PriorMatchPage"), + }, + { + key = "PageDown", + mods = "NONE", + action = act.CopyMode("NextMatchPage"), + }, + { key = "UpArrow", mods = "NONE", action = act.CopyMode("PriorMatch") }, + { key = "DownArrow", mods = "NONE", action = act.CopyMode("NextMatch") }, }, } @@ -425,7 +488,7 @@ local projects = { wezterm.home_dir .. "/.dotfiles", wezterm.home_dir .. "/Documents", wezterm.home_dir .. "/.local/bin", - wezterm.home_dir .. "/Google\\ Drive/My\\ Drive", + wezterm.home_dir .. "/Google Drive/My Drive", } sessionizer.set_projects(projects) @@ -441,29 +504,60 @@ wezterm.on("mux-is-process-stateful", function(_) return nil end) --- wezterm.on("user-var-changed", function(window, pane, name, value) --- local overrides = window:get_config_overrides() or {} --- if name == "ZEN_MODE" then --- local incremental = value:find("+") --- local number_value = tonumber(value) --- if incremental ~= nil then --- while number_value > 0 do --- window:perform_action(wezterm.action.IncreaseFontSize, pane) --- number_value = number_value - 1 --- end --- overrides.enable_tab_bar = false --- elseif number_value < 0 then --- window:perform_action(wezterm.action.ResetFontSize, pane) --- overrides.font_size = nil --- overrides.enable_tab_bar = true --- else --- overrides.font_size = number_value --- overrides.enable_tab_bar = false +-- wezterm.on("update-right-status", function(window, pane) +-- local ssh_domain = pane:get_user_vars().SSH_CONNECTION or "" +-- +-- -- Check if '.prod' is in the SSH connection string +-- if ssh_domain:find("%.prod") then +-- -- Default to Solarized Light Red +-- local fallback_red_color = "#dc322f" +-- local overrides = window:get_config_overrides() or {} +-- +-- -- Attempt to get the red color from the current color scheme +-- local red_color = fallback_red_color +-- if overrides.color_scheme and overrides.color_scheme.red then +-- red_color = overrides.color_scheme.red -- end +-- +-- -- Set the production-specific overrides +-- window:set_config_overrides({ +-- colors = { +-- background = red_color, -- Use theme-appropriate red or fallback +-- }, +-- }) +-- +-- -- Set a clear label in the terminal +-- window:set_right_status(wezterm.format({ +-- { Text = "🚨 PRODUCTION SERVER 🚨", Foreground = "white", Background = red_color, Bold = true }, +-- })) +-- else +-- -- Reset to default background and clear status for non-prod +-- window:set_config_overrides(nil) +-- window:set_right_status("") -- end --- window:set_config_overrides(overrides) -- end) +wezterm.on("user-var-changed", function(window, pane, name, value) + local overrides = window:get_config_overrides() or {} + if name == "ZEN_MODE" then + local incremental = value:find("+") + local number_value = tonumber(value) + if incremental ~= nil then + while number_value > 0 do + window:perform_action(wezterm.action.IncreaseFontSize, pane) + number_value = number_value - 1 + end + overrides.enable_tab_bar = false + elseif number_value < 0 then + window:perform_action(wezterm.action.ResetFontSize, pane) + overrides.font_size = nil + else + overrides.font_size = number_value + end + end + window:set_config_overrides(overrides) +end) + -- wezterm.on("format-tab-title", function(tab) -- local pane = tab.active_pane -- local title = pane.title diff --git a/zathura/.config/zathura/zathurarc b/zathura/.config/zathura/zathurarc new file mode 100644 index 0000000..493f8e3 --- /dev/null +++ b/zathura/.config/zathura/zathurarc @@ -0,0 +1,3 @@ +set synctex true +# set recolor true + diff --git a/zsh/.fzf.zsh b/zsh/.fzf.zsh index baa9315..b3509b4 100755 --- a/zsh/.fzf.zsh +++ b/zsh/.fzf.zsh @@ -1,28 +1,28 @@ -# Determine the FZF path based on the available package manager +#!/usr/bin/env zsh + +# Indicate the shell explicitly +export FZF_SHELL="zsh" + +# Ensure fzf is installed and get its path if command -v fzf >/dev/null; then - FZF_PATH="$(dirname "$(command -v fzf)")" -elif [[ -x "/run/current-system/sw/bin/fzf" ]]; then - FZF_PATH="/run/current-system/sw/bin/fzf" -elif command -v brew >/dev/null; then - FZF_PATH="$(brew --prefix)/opt/fzf" + export FZF_PATH="$(dirname "$(command -v fzf)")" else - FZF_PATH="/usr/local/opt/fzf" + export FZF_PATH="" fi -# Ensure the FZF binary is in the PATH -if [[ ! "$PATH" == *"$FZF_PATH/bin"* ]]; then - PATH="${PATH:+${PATH}:}$FZF_PATH/bin" +# Load fzf key bindings and completion for zsh +if command -v fzf >/dev/null; then + [ -f "$FZF_PATH/key-bindings.zsh" ] && . "$FZF_PATH/key-bindings.zsh"] + [ -f "$FZF_PATH/completion.zsh" ] && . "$FZF_PATH/completion.zsh"] fi -# Load FZF theme dynamically -FZF_THEME_FILE="${HOME}/.local/bin/scripts/fzf_theme" -if [[ -f "$FZF_THEME_FILE" ]]; then - export FZF_DEFAULT_OPTS="$("$FZF_THEME_FILE")" -fi - -# Load fzf key-bindings and completion if available -if [[ $- == *i* ]]; then - [[ -f "$HOME/.fzf/key-bindings.zsh" ]] && . "$HOME/.fzf/key-bindings.zsh" - [[ -f "$HOME/.fzf/completion.zsh" ]] && . "$HOME/.fzf/completion.zsh" +# Load fzf theme if available +FZF_THEME_SCRIPT="$HOME/.local/bin/scripts/fzf_theme.sh" +if [[ -f "$FZF_THEME_SCRIPT" ]]; then + # If theme script is available, use it and add the default fzf options + export FZF_DEFAULT_OPTS="$($FZF_THEME_SCRIPT) --height 40% --layout=reverse --border" +else + # Set default options for fzf without any theme, with preview enabled for general use + export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border" fi diff --git a/zsh/.zprofile b/zsh/.zprofile index e430d68..6f42867 100755 --- a/zsh/.zprofile +++ b/zsh/.zprofile @@ -1,50 +1,24 @@ -# Determine the FZF path based on the available package manager -if [[ -x "$(command -v fzf)" ]] && [[ "$(command -v fzf)" == "/run/current-system/sw/bin/fzf" ]]; then - # FZF is installed via Nix - export FZF_PATH="/run/current-system/sw/bin/fzf" -elif command -v brew >/dev/null; then - # Homebrew is installed - export FZF_PATH="$(brew --prefix)/opt/fzf" -else - # Fallback to empty string if neither Nix nor Homebrew is available - export FZF_PATH="" +#!/usr/bin/env zsh + +# Determine FZF installation path +if command -v fzf &>/dev/null; then + if [[ "$(command -v fzf)" == "/run/current-system/sw/bin/fzf" ]]; then + FZF_PATH="/run/current-system/sw" + elif command -v brew &>/dev/null; then + FZF_PATH="$(brew --prefix)/opt/fzf" + else + FZF_PATH="" + fi fi -# Conditionally set the editor based on SSH connection -[[ -n ${SSH_CONNECTION} ]] && export EDITOR='vim' - -# Load fzf theme options if the file exists -FZF_THEME_FILE="${HOME}/.local/bin/scripts/fzf_theme" -[[ -f "$FZF_THEME_FILE" ]] && export FZF_DEFAULT_OPTS="$("$FZF_THEME_FILE")" - -# Source fzf configuration if installed -if [[ -n "$FZF_PATH" ]]; then - for config_file in "completion.bash" "key-bindings.bash"; do - [[ -f "$FZF_PATH/shell/$config_file" ]] && source "$FZF_PATH/shell/$config_file" - done - [[ -f "${HOME}/.fzf.zsh" ]] && source "${HOME}/.fzf.zsh" +if [[ -n "$FZF_PATH" && ! "$PATH" =~ (^|:)"$FZF_PATH"(:|$) ]]; then + export PATH="$FZF_PATH:$PATH" fi -# Initialize direnv -eval "$(direnv hook zsh)" - -# Initialize zoxide -eval "$(zoxide init --cmd cd zsh)" - -# Initialize Starship -eval "$(starship init zsh)" -export STARSHIP_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/starship.toml" - -# Initialize pyenv if available -if command -v pyenv >/dev/null; then - export PYENV_ROOT="${HOME}/.pyenv" - [[ -d "${PYENV_ROOT}/bin" && ! "${PATH}" == *"${PYENV_ROOT}/bin"* ]] && export PATH="${PYENV_ROOT}/bin:${PATH}" - eval "$(pyenv init -)" +if command -v brew &>/dev/null && brew list curl &>/dev/null; then + BREW_CURL_PATH="$(brew --prefix curl)/bin" + if [[ -d "$BREW_CURL_PATH" && ! "$PATH" =~ (^|:)"$BREW_CURL_PATH"(:|$) ]]; then + export PATH="$BREW_CURL_PATH:$PATH" + fi fi -# Initialize nvm if available -# if command -v nvm >/dev/null; then -# export NVM_DIR="${HOME}/.nvm" -# [[ -s "${NVM_DIR}/nvm.sh" ]] && source "${NVM_DIR}/nvm.sh" -# fi - diff --git a/zsh/.zshenv b/zsh/.zshenv index 49bfdb3..a462598 100755 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -1,7 +1,6 @@ -#!/bin/bash +#!/usr/bin/env zsh # ------------- Environment Setup ------------- -# XDG configuration defaults export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" @@ -12,92 +11,58 @@ export EDITOR="nvim" export BROWSER="firefox" # ------------- Platform-Specific Setup ------------- -# Determine Homebrew prefix dynamically -if [[ "$(uname -s)" == "Darwin" ]]; then - HOMEBREW_PREFIX=$( - if [[ -d "/nix/store" ]]; then - echo "/run/current-system/sw" - elif [[ "$(uname -m)" == "arm64" ]]; then - echo "/opt/homebrew" - else - echo "/usr/local" - fi - ) -else - HOMEBREW_PREFIX="/usr/local" +OS_TYPE="$(uname -s)" +HOMEBREW_PREFIX="/opt/homebrew" + +if [[ "$OS_TYPE" == "Darwin" ]]; then + if [[ "$(uname -m)" == "arm64" ]]; then + HOMEBREW_PREFIX="/opt/homebrew" # Apple Silicon + else + HOMEBREW_PREFIX="/usr/local" # Intel Mac + fi +elif [[ "$OS_TYPE" == "Linux" ]]; then + if [[ -d "/home/linuxbrew/.linuxbrew/bin" ]]; then + HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew" + elif [[ -d "/linuxbrew/bin" ]]; then + HOMEBREW_PREFIX="/linuxbrew" + fi fi -# Helper function to safely add directories to PATH +# ------------- Helper Functions ------------- safe_path_add() { - local dir="$1" - [[ -d "$dir" && ! "$PATH" =~ (^|:)$dir(:|$) ]] && export PATH="$dir:$PATH" + [[ -d "$1" && ":$PATH:" != *":$1:"* ]] && export PATH="$1:$PATH" } -# Add Homebrew binaries -safe_path_add "${HOMEBREW_PREFIX}/bin" -safe_path_add "${HOMEBREW_PREFIX}/sbin" +# ------------- PATH Setup ------------- +safe_path_add "$HOME/.local/bin/scripts" +safe_path_add "$HOMEBREW_PREFIX/bin" +safe_path_add "$HOMEBREW_PREFIX/sbin" -# ------------- PATH and Tools Setup ------------- - -# Directories to potentially add to PATH -POTENTIAL_PATHS=( - "$HOME/.local/bin" - "$HOME/.rvm/bin" - "$HOME/.cargo/bin" -) - -# Add potential paths -for dir in "${POTENTIAL_PATHS[@]}"; do - safe_path_add "$dir" -done - -# Ensure PYENV_ROOT is in PATH if set -[[ -n "$PYENV_ROOT" ]] && safe_path_add "$PYENV_ROOT/bin" - -# Go path setup -if command -v go &> /dev/null; then - export GOPATH="${GOPATH:-$HOME/.go}" - safe_path_add "$GOPATH/bin" -fi - -# NVM setup -if [[ -d "$HOME/.nvm" ]]; then - export NVM_DIR="$HOME/.nvm" - for script in nvm.sh bash_completion; do - [[ -s "$NVM_DIR/$script" ]] && . "$NVM_DIR/$script" - done -fi - -# ------------- Conda / Mamba Setup ------------- -CONDA_PATHS=( - "/opt/homebrew/Caskroom/miniforge/base" - "/usr/local/Caskroom/miniforge/base" -) - -for CONDA_PATH in "${CONDA_PATHS[@]}"; do - if [[ -d "$CONDA_PATH" ]]; then - for profile_script in conda.sh mamba.sh; do - [[ -f "$CONDA_PATH/etc/profile.d/$profile_script" ]] && . "$CONDA_PATH/etc/profile.d/$profile_script" 2>/dev/null - done - safe_path_add "$CONDA_PATH/bin" - break - fi -done - -# macOS-specific additional paths -if [[ "$(uname -s)" == "Darwin" ]]; then - MACOS_PATHS=( - "${HOMEBREW_PREFIX}/opt/coreutils/libexec/gnubin" - "/usr/local/opt/openssl@1.1/bin" - "/usr/local/opt/llvm/bin" - "/Library/TeX/texbin" - ) - - for dir in "${MACOS_PATHS[@]}"; do +if [[ "$OS_TYPE" == "Darwin" ]]; then + for dir in "$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin" \ + "$HOMEBREW_PREFIX/opt/openssl@1.1/bin" \ + "$HOMEBREW_PREFIX/opt/llvm/bin" \ + "/Library/TeX/texbin"; do safe_path_add "$dir" done fi -# Optional architecture flags (uncomment if needed) -# export ARCHFLAGS="-arch x86_64 -arch arm64" +# Python Paths +[[ -n "$PYENV_ROOT" ]] && safe_path_add "$PYENV_ROOT/bin" + +# Go Paths +if command -v go &>/dev/null; then + export GOPATH="${GOPATH:-$HOME/.go}" + safe_path_add "$GOPATH/bin" +fi + +# Rust Paths +export PATH="$HOMEBREW_PREFIX/opt/rustup/bin:$PATH" + +# NVM Setup +if [[ -d "$HOME/.nvm" ]]; then + export NVM_DIR="$HOME/.nvm" + [[ -s "$NVM_DIR/nvm.sh" ]] && . "$NVM_DIR/nvm.sh" + [[ -s "$NVM_DIR/zsh_completion" ]] && . "$NVM_DIR/bash_completion" +fi diff --git a/zsh/.zshrc b/zsh/.zshrc index 0792232..c292816 100755 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -1,8 +1,6 @@ -# ------------ Profile Information ----------- -# zmodload zsh/zprof # Load zprof for performance profiling - -# ------------ Basic Settings ------------- +#!/usr/bin/env zsh +# ================ Basic Settings ================ # Disable auto title DISABLE_AUTO_TITLE="true" @@ -10,40 +8,44 @@ DISABLE_AUTO_TITLE="true" # CASE_SENSITIVE="true" # HYPHEN_INSENSITIVE="true" -# Miscellaneous configurations (uncomment as needed) +# Miscellaneous settings (uncomment as needed) # DISABLE_MAGIC_FUNCTIONS="true" # DISABLE_LS_COLORS="true" # ENABLE_CORRECTION="true" # COMPLETION_WAITING_DOTS="true" # DISABLE_UNTRACKED_FILES_DIRTY="true" -# ------------ Path & Auto-Update Settings ------------- - -# Uncomment if using Oh-My-Zsh -# export ZSH="$HOME/.oh-my-zsh" -# export ZSH_CUSTOM="$HOME/.oh-my-zsh/custom" -# export UPDATE_ZSH_DAYS=1 -# DISABLE_UPDATE_PROMPT=true -# zstyle ':omz:update' mode reminder # remind to update - -# ------------ zsh Completion Settings ------------- +# ================ Path Optimizations ================ +# Ensure no duplicates in PATH +typeset -U PATH +# ================ Zsh Completion Settings ================ # Load zsh completions with optimization -autoload -Uz compinit -fpath=(/run/current-system/sw/bin/zsh/site-functions $fpath) +if type brew &>/dev/null; then + export HOMEBREW_AUTO_UPDATE_SECS=86400 # Update every 24 hours + export HOMEBREW_PREFIX="$(brew --prefix)" -# Optimize compinit loading and reduce .zcompdump frequency + # Ensure Homebrew path is correct for your system (Intel vs M1) + if [[ -d "$HOMEBREW_PREFIX/share/zsh/site-functions" ]]; then + FPATH="$HOMEBREW_PREFIX/share/zsh/site-functions:$FPATH" + elif [[ -d "/usr/local/share/zsh/site-functions" ]]; then + FPATH="/usr/local/share/zsh/site-functions:$FPATH" + fi +fi + +# Initialize compinit for Zsh completions +autoload -Uz compinit + +# Set the location of zcompdump for completion caching ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump" -if [[ ! -f $ZSH_COMPDUMP ]]; then +if [[ ! -f $ZSH_COMPDUMP || $ZSH_COMPDUMP -ot $ZDOTDIR/.zshrc ]]; then compinit -d "$ZSH_COMPDUMP" else compinit -C -d "$ZSH_COMPDUMP" fi -# ---------------- Plugin Manager (Zinit) ---------------- +# ================ Plugin Manager (Zinit) ================ # Setup and initialize Zinit, a Zsh plugin manager - -# Define the path for Zinit installation ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" # Install Zinit if it isn't already present @@ -55,101 +57,116 @@ fi # Source the Zinit script to enable plugin management . "${ZINIT_HOME}/zinit.zsh" -# Ensure compinit (Zsh completion system) works with Zinit +# Ensure compinit works with Zinit autoload -Uz _zinit (( ${+_comps} )) && _comps[zinit]=_zinit -# ---------------- Zinit Plugin Configuration ---------------- - -# Load essential Zsh plugins -zinit light zsh-users/zsh-completions # Enhanced tab completions for Zsh +# ================ Zinit Plugin Configuration ================ +# Essential plugins for enhanced Zsh experience +zinit light zsh-users/zsh-completions # Tab completions for Zsh zinit light zsh-users/zsh-history-substring-search # Search through command history zinit load zdharma/history-search-multi-word # Multi-word history search -# Lazy load syntax highlighting for Zsh +# Syntax highlighting for Zsh (lazy-load) zinit ice wait lucid atinit"ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)" zinit load zsh-users/zsh-syntax-highlighting -# Enable asynchronous auto-suggestions +# Asynchronous auto-suggestions (lazy-load) zinit ice wait lucid atload"zle-line-init() { zle autosuggest-enable }; zle -N zle-line-init" zinit load zsh-users/zsh-autosuggestions -# ---------------- Docker Completions ---------------- -# Add CLI completions for Docker and Docker Compose +# ================ Docker Completions ================ +# Add Docker and Docker Compose completions zinit ice wait lucid depth=1 zinit load docker/compose -zinit ice wait lucid depth=1 -zinit light zsh-users/zsh-completions -# ---------------- zoxide Plugin ---------------- +# ================ zoxide Plugin ================ # Fast navigation tool for frequently used directories zinit ice from"gh-r" as"program" pick"bin/zoxide" zinit load ajeetdsouza/zoxide -# ---------------- fzf Plugin ---------------- +# ================ fzf Plugin ================ -# Source additional fzf configuration where FZF_DEFAULT_OPTS is defined -if [ -f ~/.fzf.zsh ]; then - . ~/.fzf.zsh -fi - -# Install fzf, a general-purpose command-line fuzzy finder +# Install fzf (binary) using zinit zinit ice from"gh-r" as"program" pick"bin/fzf" zinit light junegunn/fzf-bin -# Load fzf-tab for enhanced tab completion interface using fzf -zinit ice wait lucid depth=1 -zinit load Aloxaf/fzf-tab +# Optional: fzf-git.sh for git integration (if you want) +zinit light junegunn/fzf-git.sh -# Load fzf shell integration (completion and key bindings) -zinit ice depth=1 -zinit light junegunn/fzf +# Load fzf-tab for enhanced fuzzy tab completion +zinit ice blockf +zinit light Aloxaf/fzf-tab -# ------------ Additional Programs Initialization ------------- - -# Initialize direnv -eval "$(direnv hook zsh)" +# ================ Additional Programs Initialization ================ +# Initialize direnv (uncomment if needed) +# eval "$(direnv hook zsh)" # Initialize zoxide eval "$(zoxide init --cmd cd zsh)" -# Initialize Starship +# Initialize Starship prompt eval "$(starship init zsh)" export STARSHIP_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/starship.toml" -# ------------ Pyenv Setup ------------- +# ================ Zoxide Initialization ================ +if command -v eza &>/dev/null; then + export ZO_FZF_OPTS="--preview 'eza --tree --level=2 --color=always {}' --preview-window=down:30%:wrap" +else + export ZO_FZF_OPTS="--preview 'ls -la --color=always {}' --preview-window=down:30%:wrap" +fi +# ================ Conda Initialization ================ +# Initialize Conda (uncomment if you use Conda) +# eval "$(conda init "$(basename "${SHELL}")")" + +# ================ Pyenv Setup ================ +# Initialize Pyenv if installed if command -v pyenv 1>/dev/null 2>&1; then export PYENV_ROOT="$HOME/.pyenv" [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" fi -# ------------ Custom Aliases ------------- - -alias python="python3" +# ================ Custom Aliases ================ +# Define commonly used aliases alias grep="grep --color=auto" alias ..="cd .." alias ...="cd ../.." alias ....="cd ../../.." alias .....="cd ../../../.." +alias lzd='lazydocker' +alias v='nvim' + +# Use eza for enhanced 'ls' command +alias ls='eza' +alias ll='eza -lh --group-directories-first' +alias la='eza -a --group-directories-first' +alias lla='eza -la --group-directories-first' +alias l='eza --classify' + +alias gs='git status' +alias gc='git commit' +alias gcm='git commit -m' +alias gco='git checkout' +alias gb='git branch' +alias gu='git pull' +alias gp='git push' +alias gl='git log --oneline --graph --decorate' +alias gi='git init' +alias gcl='git clone' + # Source additional alias checks if available if [[ -f ~/.local/bin/scripts/check_aliases ]]; then . ~/.local/bin/scripts/check_aliases fi -# ------------ Conditional Settings ------------- - -# Conditionally set the editor based on SSH connection +# ================ Conditional Settings ================ +# Set the editor to vim if using SSH [[ -n ${SSH_CONNECTION} ]] && export EDITOR='vim' -# ------------ Homebrew configuration ------------- - -export HOMEBREW_AUTO_UPDATE_SECS=86400 # Update Homebrew every 24 hours - -# ------------ Profiling (Optional) ------------- - -# Enable profiling -# zprof # Comment this line out if profiling is not needed +# ================ Profiling (Optional) ================ +# Uncomment to enable profiling (useful for debugging) +# zprof # Comment out if profiling is not needed