diff --git a/aerospace/.config/aerospace/aerospace.toml b/aerospace/.config/aerospace/aerospace.toml new file mode 100644 index 0000000..34201f5 --- /dev/null +++ b/aerospace/.config/aerospace/aerospace.toml @@ -0,0 +1,218 @@ +# Place a copy of this config to ~/.aerospace.toml +# After that, you can edit ~/.aerospace.toml to your liking + +# You can use it to add commands that run after login to macOS user session. +# 'start-at-login' needs to be 'true' for 'after-login-command' to work +# Available commands: https://nikitabobko.github.io/AeroSpace/commands +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 = [] + +# Start AeroSpace at login +start-at-login = true + +# Normalizations. See: https://nikitabobko.github.io/AeroSpace/guide#normalization +enable-normalization-flatten-containers = true +enable-normalization-opposite-orientation-for-nested-containers = true + +# See: https://nikitabobko.github.io/AeroSpace/guide#layouts +# The 'accordion-padding' specifies the size of accordion padding +# You can set 0 to disable the padding feature +accordion-padding = 0 + +# Possible values: tiles|accordion +default-root-container-layout = 'tiles' + +# Possible values: horizontal|vertical|auto +# 'auto' means: wide monitor (anything wider than high) gets horizontal orientation, +# tall monitor (anything higher than wide) gets vertical orientation +default-root-container-orientation = 'auto' + +# Mouse follows focus when focused monitor changes +# Drop it from your config, if you don't like this behavior +# 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-focus-changed = ['move-mouse window-lazy-center'] + +# You can effectively turn off macOS "Hide application" (cmd-h) feature by toggling this flag +# Useful if you don't use this macOS feature, but accidentally hit cmd-h or cmd-alt-h key +# Also see: https://nikitabobko.github.io/AeroSpace/goodness#disable-hide-app +automatically-unhide-macos-hidden-apps = false + +# Possible values: (qwerty|dvorak) +# See https://nikitabobko.github.io/AeroSpace/guide#key-mapping +[key-mapping] +preset = 'qwerty' + +# Gaps between windows (inner-*) and between monitor edges (outer-*). +# Possible values: +# - Constant: gaps.outer.top = 8 +# - Per monitor: gaps.outer.top = [{ monitor.main = 16 }, { monitor."some-pattern" = 32 }, 24] +# In this example, 24 is a default value when there is no match. +# Monitor pattern is the same as for 'workspace-to-monitor-force-assignment'. +# See: https://nikitabobko.github.io/AeroSpace/guide#assign-workspaces-to-monitors +[gaps] +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 +# 'main' binding mode must be always presented +# Fallback value (if you omit the key): mode.main.binding = {} +[mode.main.binding] + +# All possible keys: +# - Letters. a, b, c, ..., z +# - Numbers. 0, 1, 2, ..., 9 +# - Keypad numbers. keypad0, keypad1, keypad2, ..., keypad9 +# - F-keys. f1, f2, ..., f20 +# - Special keys. minus, equal, period, comma, slash, backslash, quote, semicolon, backtick, +# leftSquareBracket, rightSquareBracket, space, enter, esc, backspace, tab +# - Keypad special. keypadClear, keypadDecimalMark, keypadDivide, keypadEnter, keypadEqual, +# keypadMinus, keypadMultiply, keypadPlus +# - Arrows. left, down, up, right + +# All possible modifiers: cmd, alt, ctrl, shift + +# All possible commands: https://nikitabobko.github.io/AeroSpace/commands + +# See: https://nikitabobko.github.io/AeroSpace/commands#exec-and-forget +# You can uncomment the following lines to open up terminal with alt + enter shortcut (like in i3) +# alt-enter = '''exec-and-forget osascript -e ' +# tell application "Terminal" +# do script +# activate +# end tell' +# ''' + +cmd-h = [] # Disable "hide application" +cmd-alt-h = [] # Disable "hide others" + +# See: https://nikitabobko.github.io/AeroSpace/commands#layout +alt-slash = 'layout tiles horizontal vertical' +alt-comma = 'layout accordion horizontal vertical' + +# See: https://nikitabobko.github.io/AeroSpace/commands#focus +alt-h = 'focus left' +alt-j = 'focus down' +alt-k = 'focus up' +alt-l = 'focus right' + +alt-r = 'layout horizontal vertical' + +# See: https://nikitabobko.github.io/AeroSpace/commands#move +alt-shift-h = 'move left' +alt-shift-j = 'move down' +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' + +# See: https://nikitabobko.github.io/AeroSpace/commands#workspace +alt-1 = 'workspace 1' +alt-2 = 'workspace 2' +alt-3 = 'workspace 3' +alt-b = 'workspace B' +alt-c = 'workspace C' +alt-e = 'workspace E' +alt-n = 'workspace N' +alt-m = 'workspace M' +alt-s = 'workspace S' +alt-t = 'workspace T' +alt-v = 'workspace V' +alt-x = 'workspace X' +alt-y = 'workspace Y' +alt-z = 'workspace Z' + +# See: https://nikitabobko.github.io/AeroSpace/commands#move-node-to-workspace +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-x = 'move-node-to-workspace X' +alt-shift-y = 'move-node-to-workspace Y' +alt-shift-z = 'move-node-to-workspace Z' + +# See: https://nikitabobko.github.io/AeroSpace/commands#workspace-back-and-forth +alt-tab = 'workspace-back-and-forth' +# See: https://nikitabobko.github.io/AeroSpace/commands#move-workspace-to-monitor +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' +# 'service' binding mode declaration. +# See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes +[mode.service.binding] +esc = ['reload-config', 'mode main'] +r = ['flatten-workspace-tree', 'mode main'] # reset layout +f = [ + 'layout floating tiling', + 'mode main', +] # Toggle between floating and tiling layout +backspace = ['close-all-windows-but-current', 'mode main'] + +# 'resize' binding mode declaration. +[mode.resize.binding] +esc = ['mode main'] +enter = ['mode main'] +h = 'resize width -50' +j = 'resize height +50' +k = 'resize height -50' +l = 'resize width +50' + +# sticky is not yet supported https://github.com/nikitabobko/AeroSpace/issues/2 +#s = ['layout sticky tiling', 'mode main'] + +alt-shift-h = ['join-with left', 'mode main'] +alt-shift-j = ['join-with down', 'mode main'] +alt-shift-k = ['join-with up', 'mode main'] +alt-shift-l = ['join-with right', 'mode main'] + +[workspace-to-monitor-force-assignment] +1 = 'main' +X = ['secondary', 'dell'] +Y = ['secondary', 'dell'] +Z = ['secondary', 'dell'] + +[[on-window-detected]] +if.app-id = 'org.mozilla.firefox' +run = "move-node-to-workspace B" + +[[on-window-detected]] +if.app-id = 'com.apple.iCal' +run = "move-node-to-workspace C" + +[[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" + +[[on-window-detected]] +if.app-id = 'com.apple.mail' +run = "move-node-to-workspace M" + +[[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" diff --git a/bash/.fzf.bash b/bash/.fzf.bash index dea23e8..d133b02 100755 --- a/bash/.fzf.bash +++ b/bash/.fzf.bash @@ -1,13 +1,21 @@ # Setup fzf # --------- -if [[ ! "$PATH" == */usr/local/opt/fzf/bin* ]]; then - PATH="${PATH:+${PATH}:}/usr/local/opt/fzf/bin" +# Get the path to fzf installed by Nix +FZF_PATH="$(command -v fzf | xargs dirname)" + +# Ensure the fzf binary is in the PATH +if [[ ! "$PATH" == *"$FZF_PATH/bin"* ]]; then + PATH="${PATH:+${PATH}:}$FZF_PATH/bin" fi # Auto-completion # --------------- -source "/usr/local/opt/fzf/shell/completion.bash" +if [[ -f "$FZF_PATH/shell/completion.bash" ]]; then + source "$FZF_PATH/shell/completion.bash" +fi # Key bindings # ------------ -source "/usr/local/opt/fzf/shell/key-bindings.bash" +if [[ -f "$FZF_PATH/shell/key-bindings.bash" ]]; then + source "$FZF_PATH/shell/key-bindings.bash" +fi diff --git a/nix/.config/nix-darwin/flake.nix b/nix/.config/nix-darwin/flake.nix new file mode 100644 index 0000000..7c61e9a --- /dev/null +++ b/nix/.config/nix-darwin/flake.nix @@ -0,0 +1,142 @@ +{ + description = "jfraeys Darwin system flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nix-darwin.url = "github:LnL7/nix-darwin"; + nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; + nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, home-manager }: + let + configuration = { pkgs, config, ... }: { + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + nixpkgs.system = "aarch64-darwin"; + + # System packages and fonts + environment.systemPackages = with pkgs; [ + mkalias neovim wezterm git ripgrep fd pyenv mos teams docker docker-compose atac gh rustup + sd sphinx starship stow tree zoxide spotify direnv unibilium uv zathura raycast skim eza + fzf zsh gettext python3 pyright ruff lua luarocks bat go openssl + + # Nerd Font package for Meslo font + (pkgs.nerdfonts.override { fonts = [ "Meslo" ]; }) + ]; + + # Homebrew configuration + homebrew = { + enable = true; + brews = [ "mas" "shpotify" "zathura-pdf-poppler" "girara" ]; + casks = [ "zotero" "firefox" "aerospace" "logi-options+" "hiddenbar" "miniforge" "google-drive" "vscodium" "mactex-no-gui" ]; + masApps = { "notability" = 360593530; }; + taps = [ "nikitabobko/tap" "zegervdv/zathura" ]; + onActivation = { + cleanup = "zap"; + autoUpdate = true; + upgrade = true; + }; + }; + + # System activation script for Applications + system.activationScripts.applications.text = let + env = pkgs.buildEnv { + name = "system-applications"; + paths = config.environment.systemPackages; + pathsToLink = "/Applications"; + }; + in + pkgs.lib.mkForce '' + echo "Setting up /Applications..." >&2 + rm -rf /Applications/Nix\ Apps + mkdir -p /Applications/Nix\ Apps + for app in ${env}/Applications/*; do + ln -s "$app" "/Applications/Nix Apps/$(basename "$app")" + done + ''; + + # System defaults + system.defaults = { + dock.autohide = true; + loginwindow.GuestEnabled = false; + NSGlobalDomain.AppleICUForce24HourTime = true; + }; + + # Enable alternative shell support in nix-darwin. + programs = { + bash.enable = false; + zsh.enable = true; + + # Set LuaRocks local installation paths in zsh + zsh.shellInit = '' + export LUA_PATH="$HOME/.luarocks/share/lua/5.4/?.lua;$HOME/.luarocks/share/lua/5.4/?/init.lua;;" + export LUA_CPATH="$HOME/.luarocks/lib/lua/5.4/?.so;;" + ''; + }; + + # Configure LuaRocks to use local installation by default + system.activationScripts.luarocksConfig.text = '' + mkdir -p "$HOME/.luarocks" + echo 'local_by_default = true' > "$HOME/.luarocks/config-5.2.lua" + ''; + + # Track configuration version with Git commit hash + system.configurationRevision = self.rev or self.dirtyRev or null; + + # Enable nix-daemon for flake support and updates + services.nix-daemon.enable = true; + nix.settings.experimental-features = "nix-command flakes"; + + # Set state version to match nix-darwin version + system.stateVersion = 5; # Update this based on your Nix-darwin version + + # Enable Touch ID for sudo + security.pam.enableSudoTouchIdAuth = true; + + # User-specific configuration + users.users.jfraeys = { + home = "/Users/jfraeys"; + isNormalUser = true; + shell = pkgs.zsh; + }; + + # Home Manager configuration + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.jfraeys = import ./home.nix; + backupFileExtension = "backup"; + }; + + # Enable build users for nix-darwin + nix.configureBuildUsers = true; + nix.useDaemon = true; + }; + in + { + darwinConfigurations."Jays-Mac-Studio" = nix-darwin.lib.darwinSystem { + modules = [ + configuration + nix-homebrew.darwinModules.nix-homebrew + { + nix-homebrew = { + enable = true; + enableRosetta = true; # For Apple Silicon with Rosetta + user = "jfraeys"; + autoMigrate = true; + }; + } + home-manager.darwinModules.home-manager + ]; + }; + + # Expose the package set, including overlays, for convenience. + darwinPackages = self.darwinConfigurations."Jays-Mac-Studio".pkgs; + }; +} + diff --git a/nix/.config/nix-darwin/home.nix b/nix/.config/nix-darwin/home.nix new file mode 100644 index 0000000..362bdee --- /dev/null +++ b/nix/.config/nix-darwin/home.nix @@ -0,0 +1,60 @@ +{ config, pkgs, ... }: + +{ + home.username = "jfraeys"; + home.homeDirectory = "/Users/jfraeys"; + home.stateVersion = "23.05"; # Adjust according to your system's compatibility. + + # User-specific applications that shouldn't be available system-wide. + home.packages = [ + pkgs.zsh + pkgs.neovim + pkgs.wezterm + pkgs.tmux + pkgs.starship + pkgs.fzf + pkgs.ripgrep + pkgs.bat + pkgs.lazygit + pkgs.zoxide + ]; + + # Home Manager dotfiles management + home.file = { + ".zshrc".source = ~/dotfiles/zshrc/.zshrc; + ".config/wezterm".source = ~/dotfiles/wezterm; + ".config/skhd".source = ~/dotfiles/skhd; + ".config/starship.toml".source = ~/dotfiles/starship/starship.toml; + ".config/zellij".source = ~/dotfiles/zellij; + ".config/nvim".source = ~/dotfiles/nvim; + ".config/nix".source = ~/dotfiles/nix; + ".config/nix-darwin".source = ~/dotfiles/nix; + ".config/tmux".source = ~/dotfiles/tmux; + ".config/ghostty".source = ~/dotfiles/ghostty; + }; + + # Setting session variables + home.sessionVariables = { + # Setting custom PATH + PATH = "${pkgs.coreutils}/bin:${pkgs.gnugrep}/bin:/run/current-system/sw/bin:$HOME/.nix-profile/bin"; + }; + + # Adding directories to session PATH + home.sessionPath = [ + "/run/current-system/sw/bin" + "$HOME/.nix-profile/bin" + ]; + + # Zsh configuration + programs.zsh = { + enable = true; + oh-my-zsh.enable = true; + initExtra = '' + export PATH=/run/current-system/sw/bin:$HOME/.nix-profile/bin:$PATH + if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then + . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' + fi + ''; + }; +} + diff --git a/setup.sh b/setup.sh index e6642ab..07f2381 100755 --- a/setup.sh +++ b/setup.sh @@ -22,8 +22,9 @@ base=( # Folders that should, or only need to be installed for a local user on macOS useronly_macos=( zsh - yabai - skhd + # yabai + # skhd + aerospace # oh-my-zsh ) @@ -145,4 +146,3 @@ done echo "" echo "##### ALL DONE" - diff --git a/skhd/.config/skhd/skhdrc b/skhd/.config/skhd/skhdrc index 4860e4b..3bf9682 100755 --- a/skhd/.config/skhd/skhdrc +++ b/skhd/.config/skhd/skhdrc @@ -1,19 +1,32 @@ -# Change window focus within space +# --------------------------- +# WINDOW FOCUS +# --------------------------- +# Change window focus within the current space shift + cmd - j : yabai -m window --focus south shift + cmd - k : yabai -m window --focus north shift + cmd - h : yabai -m window --focus west shift + cmd - l : yabai -m window --focus east -# Resize windows -lctrl + alt - h : yabai -m window --resize left:-50:0; yabai -m window --resize right:-50:0 -lctrl + alt - j : yabai -m window --resize bottom:0:50; yabai -m window --resize top:0:50 -lctrl + alt - k : yabai -m window --resize top:0:-50; yabai -m window --resize bottom:0:-50 -lctrl + alt - l : yabai -m window --resize right:50:0; yabai -m window --resize left:50:0 +# Change focus between external displays (left and right) +cmd - h : yabai -m display --focus west +cmd - l : yabai -m display --focus east -# Equalize size of windows +# --------------------------- +# WINDOW RESIZE +# --------------------------- +# Resize windows in one direction (left, right, up, down) +lctrl + alt - h : yabai -m window --resize left:-50:0 +lctrl + alt - l : yabai -m window --resize right:50:0 +lctrl + alt - j : yabai -m window --resize bottom:0:50 +lctrl + alt - k : yabai -m window --resize top:0:-50 + +# Equalize the size of all windows in the current space lctrl + alt - e : yabai -m space --balance -# Change space +# --------------------------- +# SPACE MANAGEMENT +# --------------------------- +# Switch between spaces shift + cmd - 1 : yabai -m space --focus 1 shift + cmd - 2 : yabai -m space --focus 2 shift + cmd - 3 : yabai -m space --focus 3 @@ -22,49 +35,7 @@ shift + cmd - 5 : yabai -m space --focus 5 shift + cmd - 6 : yabai -m space --focus 6 shift + cmd - 7 : yabai -m space --focus 7 -# Change focus between external displays (left and right) -cmd - h : yabai -m display --focus west -cmd - l : yabai -m display --focus east - -# Rotate layout clockwise -shift + alt - r : yabai -m space --rotate 270 - -# Flip along y-axis -shift + alt - y : yabai -m space --mirror y-axis - -# Flip along x-axis -shift + alt - x : yabai -m space --mirror x-axis - -# Toggle window float -shift + alt - t : yabai -m window --toggle float --grid 4:4:1:1:2:2 - -# Maximize a window -shift + alt - m : yabai -m window --toggle zoom-fullscreen - -# Toggle whether the focused window should be shown on all spaces -shift + alt - a : yabai -m window --toggle sticky - -# Swap windows -shift + alt - j : yabai -m window --swap south -shift + alt - k : yabai -m window --swap north -shift + alt - h : yabai -m window --swap west -shift + alt - l : yabai -m window --swap east - -# Move window and split -ctrl + alt - j : yabai -m window --warp south -ctrl + alt - k : yabai -m window --warp north -ctrl + alt - h : yabai -m window --warp west -ctrl + alt - l : yabai -m window --warp east - -# Move window to display left and right -shift + alt - s : yabai -m window --display west; yabai -m display --focus west -shift + alt - g : yabai -m window --display east; yabai -m display --focus east - -# Move window to previous and next space -shift + alt - p : yabai -m window --space prev -shift + alt - n : yabai -m window --space next - -# Move window to space # +# Move the current window to a specific space shift + alt - 1 : yabai -m window --space 1 shift + alt - 2 : yabai -m window --space 2 shift + alt - 3 : yabai -m window --space 3 @@ -73,22 +44,65 @@ shift + alt - 5 : yabai -m window --space 5 shift + alt - 6 : yabai -m window --space 6 shift + alt - 7 : yabai -m window --space 7 -# Move window to different positions within the mosaic grid -shift + ctrl + alt - h : yabai -m window --warp west -shift + ctrl + alt - j : yabai -m window --warp south -shift + ctrl + alt - k : yabai -m window --warp north -shift + ctrl + alt - l : yabai -m window --warp east +# Move window to previous and next space +shift + alt - p : yabai -m window --space prev +shift + alt - n : yabai -m window --space next -# Focus or open Applications +# --------------------------- +# WINDOW MOVEMENT AND SWAP +# --------------------------- +# Move window within the current space +ctrl + alt - h : yabai -m window --warp west +ctrl + alt - l : yabai -m window --warp east +ctrl + alt - j : yabai -m window --warp south +ctrl + alt - k : yabai -m window --warp north + +# Swap windows +shift + alt - j : yabai -m window --swap south +shift + alt - k : yabai -m window --swap north +shift + alt - h : yabai -m window --swap west +shift + alt - l : yabai -m window --swap east + +# --------------------------- +# WINDOW AND SPACE MODIFICATIONS +# --------------------------- +# Toggle window float and maximize (zoom fullscreen) +shift + alt - t : yabai -m window --toggle float --grid 4:4:1:1:2:2 +shift + alt - m : yabai -m window --toggle zoom-fullscreen + +# Toggle window sticky (always visible across all spaces) +shift + alt - a : yabai -m window --toggle sticky + +# Rotate space layout clockwise and flip along axes +shift + alt - r : yabai -m space --rotate 270 +shift + alt - y : yabai -m space --mirror y-axis +shift + alt - x : yabai -m space --mirror x-axis + +# Move window between displays +shift + alt - s : yabai -m window --display west; yabai -m display --focus west +shift + alt - g : yabai -m window --display east; yabai -m display --focus east + +# --------------------------- +# APPLICATION LAUNCHER +# --------------------------- alt - t : open -a /Applications/WezTerm.app alt - f : open -a /Applications/Firefox.app -alt - n : open -a /Applications/Safari.app -alt - s : open -a /Applications/Slack.app +alt - s : open -a /Applications/Safari.app alt - v : open -a /Applications/VSCodium.app alt - m : open -a /System/Applications/Mail.app alt - w : open -a /Applications/Bitwarden.app +alt - i : open -a /System/Applications/Messages.app -# Stop/start/restart yabai +# --------------------------- +# SCREEN CAPTURE +# --------------------------- +cmd + shift - 3 : screencapture -x ~/Desktop/screenshot_$(date +%Y-%m-%d_%H-%M-%S).png +cmd + shift - 4 : screencapture -i ~/Desktop/screenshot_$(date +%Y-%m-%d_%H-%M-%S).png +cmd + shift - 5 : screencapture -w ~/Desktop/screenshot_$(date +%Y-%m-%d_%H-%M-%S).png + +# --------------------------- +# YABAI SERVICE CONTROL +# --------------------------- ctrl + alt - q : yabai --stop-service ctrl + alt - s : yabai --start-service ctrl + alt - r : yabai --restart-service diff --git a/starship/.config/starship.toml b/starship/.config/starship.toml index bad781f..91e4354 100644 --- a/starship/.config/starship.toml +++ b/starship/.config/starship.toml @@ -2,7 +2,7 @@ "$schema" = 'https://starship.rs/config-schema.json' add_newline = false -palette = "monokai_pro" +palette = "solarized_light" command_timeout = 5000 # Customize your prompt to ensure everything is on a single line @@ -49,7 +49,7 @@ disabled = false [character] success_symbol = "[ ❯](bold green)" error_symbol = "[ ✗](bold red)" -vicmd_symbol = "[ V](bold green)" +vimcmd_symbol = "[ V](bold green)" # Directory [directory] @@ -82,7 +82,7 @@ style = "blue" # C [c] format = "[ $symbol($version(-$name) )]($style)" -style = "bold 149" +style = "bold green" detect_files = ["Makefile"] # Conda diff --git a/wezterm/.config/wezterm/gpu-adapter.lua b/wezterm/.config/wezterm/gpu-adapter.lua new file mode 100644 index 0000000..07064cd --- /dev/null +++ b/wezterm/.config/wezterm/gpu-adapter.lua @@ -0,0 +1,135 @@ +local wezterm = require("wezterm") +local platform = require("platform") + +---@alias WeztermGPUBackend 'Vulkan'|'Metal'|'Gl'|'Dx12' +---@alias WeztermGPUDeviceType 'DiscreteGpu'|'IntegratedGpu'|'Cpu'|'Other' + +---@class WeztermGPUAdapter +---@field name string +---@field backend WeztermGPUBackend +---@field device number +---@field device_type WeztermGPUDeviceType +---@field driver? string +---@field driver_info? string +---@field vendor string + +---@alias AdapterMap { [WeztermGPUBackend]: WeztermGPUAdapter|nil }|nil + +---@class GpuAdapters +---@field __backends WeztermGPUBackend[] +---@field __preferred_backend WeztermGPUBackend +---@field __preferred_device_type WeztermGPUDeviceType +---@field DiscreteGpu AdapterMap +---@field IntegratedGpu AdapterMap +---@field Cpu AdapterMap +---@field Other AdapterMap +local GpuAdapters = {} +GpuAdapters.__index = GpuAdapters + +---See `https://github.com/gfx-rs/wgpu#supported-platforms` for more info on available backends +GpuAdapters.AVAILABLE_BACKENDS = { + windows = { "Dx12", "Vulkan", "Gl" }, + linux = { "Vulkan", "Gl" }, + mac = { "Metal" }, +} + +---@type WeztermGPUAdapter[] +GpuAdapters.ENUMERATED_GPUS = wezterm.gui.enumerate_gpus() + +---@return GpuAdapters +---@private +function GpuAdapters:init() + local initial = { + __backends = self.AVAILABLE_BACKENDS[platform.os], + __preferred_backend = self.AVAILABLE_BACKENDS[platform.os][1], + DiscreteGpu = nil, + IntegratedGpu = nil, + Cpu = nil, + Other = nil, + } + + -- iterate over the enumerated GPUs and create a lookup table (`AdapterMap`) + for _, adapter in ipairs(self.ENUMERATED_GPUS) do + if not initial[adapter.device_type] then + initial[adapter.device_type] = {} + end + initial[adapter.device_type][adapter.backend] = adapter + end + + local gpu_adapters = setmetatable(initial, self) + + return gpu_adapters +end + +---Will pick the best adapter based on the following criteria: +--- 1. Best GPU available (Discrete > Integrated > Other (for wgpu's OpenGl implementation on Discrete GPU) > Cpu) +--- 2. Best graphics API available (based off my very scientific scroll a big log file in neovim test 😁) +--- +---Graphics API choices are based on the platform: +--- - Windows: Dx12 > Vulkan > OpenGl +--- - Linux: Vulkan > OpenGl +--- - Mac: Metal +---@see GpuAdapters.AVAILABLE_BACKENDS +--- +---If the best adapter combo is not found, it will return `nil` and lets Wezterm decide the best adapter. +--- +---Please note these are my own personal preferences and may not be the best for your system. +---If you want to manually choose the adapter, use `GpuAdapters:pick_manual(backend, device_type)` +---Or feel free to re-arrange `GpuAdapters.AVAILABLE_BACKENDS` to you liking +---@return WeztermGPUAdapter|nil +function GpuAdapters:pick_best() + local adapters_options = self.DiscreteGpu + local preferred_backend = self.__preferred_backend + + if not adapters_options then + adapters_options = self.IntegratedGpu + end + + if not adapters_options then + adapters_options = self.Other + preferred_backend = "Gl" + end + + if not adapters_options then + adapters_options = self.Cpu + end + + if not adapters_options then + wezterm.log_error("No GPU adapters found. Using Default Adapter.") + return nil + end + + local adapter_choice = adapters_options[preferred_backend] + + if not adapter_choice then + wezterm.log_error("Preferred backend not available. Using Default Adapter.") + return nil + end + + return adapter_choice +end + +---Manually pick the adapter based on the backend and device type. +---If the adapter is not found, it will return nil and lets Wezterm decide the best adapter. +---@param backend WeztermGPUBackend +---@param device_type WeztermGPUDeviceType +---@return WeztermGPUAdapter|nil +function GpuAdapters:pick_manual(backend, device_type) + local adapters_options = self[device_type] + + if not adapters_options then + wezterm.log_error("No GPU adapters found. Using Default Adapter.") + return nil + end + + local adapter_choice = adapters_options[backend] + + if not adapter_choice then + wezterm.log_error("Preferred backend not available. Using Default Adapter.") + return nil + end + + return adapter_choice +end + +return GpuAdapters:init() diff --git a/wezterm/.config/wezterm/platform.lua b/wezterm/.config/wezterm/platform.lua index 3f8a1eb..903554a 100644 --- a/wezterm/.config/wezterm/platform.lua +++ b/wezterm/.config/wezterm/platform.lua @@ -1,16 +1,28 @@ local wezterm = require("wezterm") -local M = {} - local function is_found(str, pattern) return string.find(str, pattern) ~= nil end -function M.platform() +---@alias PlatformType 'windows' | 'linux' | 'mac' + +---@return {os: PlatformType, is_win: boolean, is_linux: boolean, is_mac: boolean} +local function platform() local is_win = is_found(wezterm.target_triple, "windows") local is_linux = is_found(wezterm.target_triple, "linux") - local is_mac = is_found(wezterm.target_triple, "darwin") - local os = is_win and "windows" or is_linux and "linux" or is_mac and "mac" or "unknown" + local is_mac = is_found(wezterm.target_triple, "apple") + local os + + if is_win then + os = "windows" + elseif is_linux then + os = "linux" + elseif is_mac then + os = "mac" + else + error("Unknown platform") + end + return { os = os, is_win = is_win, @@ -19,4 +31,6 @@ function M.platform() } end -return M +local _platform = platform() + +return _platform diff --git a/wezterm/.config/wezterm/theme-switcher.lua b/wezterm/.config/wezterm/theme-switcher.lua index 94462a1..7b57299 100644 --- a/wezterm/.config/wezterm/theme-switcher.lua +++ b/wezterm/.config/wezterm/theme-switcher.lua @@ -1,11 +1,9 @@ local wezterm = require("wezterm") local os = require("os") -local platform = require("platform") local M = {} -- Determine the appearance (light or dark) --- @return: The appearance local function get_appearance() if wezterm.gui then return wezterm.gui.get_appearance() @@ -13,10 +11,7 @@ local function get_appearance() return "Dark" end --- Set the color scheme and tab bar colors based on the appearance --- @param appearance: The appearance (light or dark) --- @param schemes: The color schemes for light and dark appearances --- @return: The color scheme for the appearance +-- Set the color scheme and tab bar colors based on appearance local function scheme_for_appearance(appearance, schemes) if appearance:find("Dark") then return schemes.dark @@ -31,65 +26,36 @@ local color_schemes = { light = "Solarized (light) (terminal.sexy)", } --- Define custom tab bar colors for light and dark themes +-- Custom tab bar colors for light and dark themes local tab_bar_colors = { dark = { - active_tab = { - bg_color = "#1c1f24", - fg_color = "#f8f8f2", - }, - inactive_tab = { - bg_color = "#3e4451", - fg_color = "#a0a0a0", - }, - inactive_tab_hover = { - bg_color = "#4e545e", - fg_color = "#c0c0c0", - }, - new_tab = { - bg_color = "#1c1f24", - fg_color = "#f8f8f2", - }, - new_tab_hover = { - bg_color = "#4e545e", - fg_color = "#c0c0c0", - }, + active_tab = { bg_color = "#1c1f24", fg_color = "#f8f8f2" }, + inactive_tab = { bg_color = "#3e4451", fg_color = "#a0a0a0" }, + inactive_tab_hover = { bg_color = "#4e545e", fg_color = "#c0c0c0" }, + new_tab = { bg_color = "#1c1f24", fg_color = "#f8f8f2" }, + new_tab_hover = { bg_color = "#4e545e", fg_color = "#c0c0c0" }, }, light = { - active_tab = { - bg_color = "#eee8d5", - fg_color = "#073642", - }, - inactive_tab = { - bg_color = "#93a1a1", - fg_color = "#586e75", - }, - inactive_tab_hover = { - bg_color = "#839496", - fg_color = "#586e75", - }, - new_tab = { - bg_color = "#eee8d5", - fg_color = "#073642", - }, - new_tab_hover = { - bg_color = "#839496", - fg_color = "#586e75", - }, + active_tab = { bg_color = "#eee8d5", fg_color = "#073642" }, + inactive_tab = { bg_color = "#93a1a1", fg_color = "#586e75" }, + inactive_tab_hover = { bg_color = "#839496", fg_color = "#586e75" }, + new_tab = { bg_color = "#eee8d5", fg_color = "#073642" }, + new_tab_hover = { bg_color = "#839496", fg_color = "#586e75" }, }, } --- Check if a command is available --- @param cmd: The command to check for --- @return: Whether the command is available +-- Check if a command is available (uses POSIX standard) local function is_command_available(cmd) - -- Use os.execute with a command that checks for command existence - local result = os.execute("command -v " .. cmd) - return result + local handle = io.popen("command -v " .. cmd .. " >/dev/null 2>&1; echo $?") + if handle == nil then + return false + end + local result = handle:read("*a"):gsub("%s+", "") + handle:close() + return tonumber(result) == 0 end --- Function to update the Starship palette in the starship.toml file using sed --- @param palette_name: The name of the palette to switch to +-- Function to update the Starship palette in the starship.toml file local function update_starship_palette(palette_name) if not is_command_available("starship") then wezterm.log_info("Starship is not installed.") @@ -97,38 +63,37 @@ local function update_starship_palette(palette_name) end local starship_config_path = os.getenv("XDG_CONFIG_HOME") .. "/starship.toml" - local replace_command - - if is_command_available("sd") then - -- Use sd if available - replace_command = string.format("sd 'palette = .+' 'palette = \"%s\"' %s", palette_name, starship_config_path) - else - -- Fall back to sed for both macOS and Linux - replace_command = - string.format("sed -i '' -e 's/palette = .*/palette = \"%s\"/' %s", palette_name, starship_config_path) + if not starship_config_path or starship_config_path == "" then + wezterm.log_error("XDG_CONFIG_HOME is not set or starship.toml not found.") + return end - os.execute(replace_command) + local replace_command + if is_command_available("sd") then + replace_command = string.format("sd 'palette = .+' 'palette = \"%s\"' %s", palette_name, starship_config_path) + else + local sed_inplace = wezterm.target_triple:find("darwin") and "sed -i ''" or "sed -i" + replace_command = + string.format("%s 's/palette = .*/palette = \"%s\"/' %s", sed_inplace, palette_name, starship_config_path) + end + + local result = os.execute(replace_command) + if result ~= 0 then + wezterm.log_error("Failed to update Starship palette.") + end end --- Apply the configuration and update the Starship palette --- @param config: The configuration object --- @return: The updated configuration object +-- Apply the configuration and update Starship palette function M.apply_to_config(config) local appearance = get_appearance() config.color_scheme = scheme_for_appearance(appearance, color_schemes) - config.colors = { - tab_bar = scheme_for_appearance(appearance, tab_bar_colors), - } + config.colors = { tab_bar = scheme_for_appearance(appearance, tab_bar_colors) } - -- Check if the shell is interactive - if os.getenv("PS1") then - -- Update the Starship palette based on the appearance - if appearance:find("Dark") then - update_starship_palette("monokai_pro") - else - update_starship_palette("solarized_light") - end + -- Update the Starship palette based on appearance + if appearance:find("Dark") then + update_starship_palette("monokai_pro") + else + update_starship_palette("solarized_light") end end diff --git a/wezterm/.config/wezterm/util.lua b/wezterm/.config/wezterm/util.lua index 037e3ff..fd7e6e1 100644 --- a/wezterm/.config/wezterm/util.lua +++ b/wezterm/.config/wezterm/util.lua @@ -1,5 +1,4 @@ local M = {} -local wezterm = require("wezterm") M.filter = function(tbl, callback) local filt_table = {} diff --git a/wezterm/.wezterm.lua b/wezterm/.wezterm.lua index 28074fb..56dd856 100644 --- a/wezterm/.wezterm.lua +++ b/wezterm/.wezterm.lua @@ -6,6 +6,7 @@ local act = wezterm.action local theme = require("theme-switcher") -- local kill_workspace = require("kill-workspace") local sessionizer = require("sessionizer.plugin.init") +local gpu_adapters = require("gpu-adapter") local config = {} @@ -20,27 +21,22 @@ end 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.macos_window_background_blur = 10 - config.default_prog = { "/bin/bash", "-l" } - config.font = wezterm.font_with_fallback({ - { family = "MesloLGS NF", scale = 0.9 }, - { family = "Menlo", scale = 0.9 }, - }) -elseif wezterm.target_triple == "aarch64-apple-darwin" then - config.macos_window_background_blur = 10 config.default_prog = { "/bin/zsh", "-l" } config.font = wezterm.font_with_fallback({ - -- { family = "JetBrainsMono Nerd Font", scale = 0.9 }, - { family = "MesloLGS NF", scale = 0.9 }, - { family = "Menlo", scale = 0.9 }, + { 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" } + config.font = wezterm.font_with_fallback({ + { family = "MesloLGS NF", scale = 1.0 }, + { family = "Menlo", scale = 1.0 }, }) - - config.front_end = "WebGpu" elseif wezterm.target_triple == "x86_64-unknown-linux-gnu" then config.default_prog = { "/bin/bash", "-l" } config.font = wezterm.font_with_fallback({ - { family = "MesloLGS NF", scale = 0.9 }, - { family = "Ubuntu Mono", scale = 0.9 }, + { family = "MesloLGS NF", scale = 1.0 }, + { family = "Ubuntu Mono", scale = 1.0 }, }) end @@ -51,6 +47,12 @@ 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, @@ -424,7 +426,6 @@ local projects = { wezterm.home_dir .. "/Documents", wezterm.home_dir .. "/.local/bin", wezterm.home_dir .. "/Google\\ Drive/My\\ Drive", - -- wezterm.home_dir .. "/.local/bin/fake_project", -- test project } sessionizer.set_projects(projects) diff --git a/yabai/.config/yabai/yabairc b/yabai/.config/yabai/yabairc index e45cbb9..97f6230 100755 --- a/yabai/.config/yabai/yabairc +++ b/yabai/.config/yabai/yabairc @@ -1,33 +1,41 @@ #!/usr/bin/env sh -# Global settings +# --------------------------- +# GLOBAL SETTINGS +# --------------------------- yabai -m config mouse_follows_focus off yabai -m config focus_follows_mouse off yabai -m config window_placement second_child -# yabai -m config window_topmost off -yabai -m config window_opacity off -yabai -m config window_opacity_duration 0.0 +yabai -m config window_opacity on # Opacity settings will now be respected +yabai -m config window_opacity_duration 0.2 yabai -m config window_shadow off # Uncomment the following line to disable window borders -# yabai -m config window_border off -# yabai -m config window_border_width 2 +# yabai -m config window_border off +# yabai -m config window_border_width 2 -# window management settings -yabai -m config active_window_opacity 1.0 -yabai -m config normal_window_opacity 0.75 -yabai -m config split_ratio 0.65 -yabai -m config auto_balance on +# --------------------------- +# WINDOW MANAGEMENT +# --------------------------- +yabai -m config active_window_opacity 1.0 # Full opacity for active window +yabai -m config normal_window_opacity 0.75 # Reduced opacity for inactive windows +yabai -m config split_ratio 0.65 # Adjust split ratio for bsp layout +yabai -m config auto_balance on # Auto-balance window sizes -# Mouse settings +# --------------------------- +# MOUSE SETTINGS +# --------------------------- yabai -m config mouse_modifier fn yabai -m config mouse_action1 move yabai -m config mouse_action2 resize -# General space settings +# --------------------------- +# SPACE SETTINGS +# --------------------------- yabai -m config layout bsp -yabai -m config top_padding 1 +yabai -m config top_padding 5 # Consistent padding for aesthetics yabai -m config bottom_padding 50 -yabai -m config left_padding 5 -yabai -m config right_padding 5 -yabai -m config window_gap 3 +yabai -m config left_padding 10 +yabai -m config right_padding 10 +yabai -m config window_gap 5 # Unified window gap for consistency + diff --git a/zsh/.fzf.zsh b/zsh/.fzf.zsh index 5d0d3d5..0f277b5 100755 --- a/zsh/.fzf.zsh +++ b/zsh/.fzf.zsh @@ -1,22 +1,40 @@ -# Setup fzf -# --------- -if [[ "$(uname -m)" == "arm64" ]]; then - # ARM-based Mac (Apple Silicon) - FZF_PATH="/opt/homebrew/opt/fzf" +# ------------- FZF Configuration ------------- + +# Determine the FZF path based on the available package manager +if command -v fzf >/dev/null; then + # Path when fzf is installed directly + FZF_PATH="$(dirname "$(command -v fzf)")" +elif [[ -x "/run/current-system/sw/bin/fzf" ]]; then + # Path when fzf is installed via Nix + FZF_PATH="/run/current-system/sw/bin/fzf" +elif command -v brew >/dev/null; then + # Path when fzf is installed via Homebrew (Darwin) + FZF_PATH="$(brew --prefix)/opt/fzf" else - # Intel-based Mac + # Fallback location for FZF FZF_PATH="/usr/local/opt/fzf" fi -if [[ ! "$PATH" == *$FZF_PATH/bin* ]]; then - PATH="${PATH:+${PATH}:}$FZF_PATH/bin" +# Ensure the FZF binary is in the PATH +if [[ ! "$PATH" == *"$FZF_PATH/bin"* ]]; then + PATH="${PATH:+${PATH}:}$FZF_PATH/bin" # Add FZF to PATH if not already included fi -# Auto-completion -# --------------- -[[ $- == *i* ]] && source "$FZF_PATH/shell/completion.zsh" 2> /dev/null +# Load fzf theme options if the theme file exists +FZF_THEME_FILE="${HOME}/.local/bin/scripts/fzf_theme" +[[ -f "$FZF_THEME_FILE" ]] && export FZF_DEFAULT_OPTS="$("$FZF_THEME_FILE")" # Set FZF default options -# Key bindings -# ------------ -source "$FZF_PATH/shell/key-bindings.zsh" +# Auto-completion and Key Bindings Setup +# ---------------------------------------- +if [[ $- == *i* ]]; then + # Load fzf key-bindings if available + [[ -f "$HOME/.fzf/key-bindings.zsh" ]] && . "$HOME/.fzf/key-bindings.zsh" + + # Load fzf completion if available + [[ -f "$HOME/.fzf/completion.zsh" ]] && . "$HOME/.fzf/completion.zsh" + + # Optional: Enable history search with fzf + # Uncomment the line below to activate the fzf history widget + # bindkey '^R' fzf-history-widget # Bind Ctrl+R to fzf history widget +fi diff --git a/zsh/.zprofile b/zsh/.zprofile index 0e15fcf..e430d68 100755 --- a/zsh/.zprofile +++ b/zsh/.zprofile @@ -1,36 +1,50 @@ -# Determine architecture and set brew paths -if [[ "$(uname -m)" == "arm64" ]]; then - # ARM-based Mac (Apple Silicon) - HOMEBREW_PREFIX="/opt/homebrew" +# 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 - # Intel-based Mac - HOMEBREW_PREFIX="/usr/local" + # Fallback to empty string if neither Nix nor Homebrew is available + export FZF_PATH="" fi -# Conditionally set the editor based on whether you're using SSH -if [[ -n $SSH_CONNECTION ]]; then - export EDITOR='vim' +# 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" fi -# 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" -fi +# Initialize direnv +eval "$(direnv hook zsh)" -# Source fzf configuration -if command -v fzf >/dev/null 2>&1; then - eval "$(fzf --zsh)" -fi +# Initialize zoxide +eval "$(zoxide init --cmd cd zsh)" -[ -f ~/.fzf.zsh ] && . ~/.fzf.zsh +# Initialize Starship +eval "$(starship init zsh)" +export STARSHIP_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/starship.toml" -# Initialize pyenv -if command -v pyenv >/dev/null 2>&1; then +# 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 -)" fi -if ! command -v nvm >/dev/null 2>&1; then - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh 2>&1 | bash >/dev/null 2>&1 -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 f0c788c..5c31d4a 100755 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -1,84 +1,91 @@ -# Ensure XDG_CONFIG_HOME is set -: "${XDG_CONFIG_HOME:=$HOME/.config}" +# ------------- Environment Setup ------------- -# Set default pager and editor globally +# XDG configuration home +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 pager, editor, and browser export PAGER="less -i -N -S -R" export EDITOR="nvim" export BROWSER="firefox" -# Set platform-specific Homebrew paths -if [[ "$(uname -m)" == "arm64" ]]; then - # ARM Apple Silicon - HOMEBREW_PREFIX="/opt/homebrew" -else - # Intel - HOMEBREW_PREFIX="/usr/local" -fi -# Ensure Homebrew bin/sbin are in the PATH -if [[ -d "$HOMEBREW_PREFIX" && ! "$PATH" =~ (^|:)${HOMEBREW_PREFIX}/bin(:|$) ]]; then - export PATH="${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin:$PATH" -fi +# ------------- Platform-Specific Setup ------------- -# 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 - -export MODULAR_HOME="/Users/$(whoami)/.modular" -export PATH="/Users/$(whoami)/.modular/pkg/packages.modular.com_mojo:$PATH" - -# Add ~/.local/bin to PATH if it exists -if [[ -d "$HOME/.local/bin" && ! "$PATH" =~ (^|:)${HOME}/.local/bin(:|$) ]]; then - export PATH="$HOME/.local/bin:$PATH" -fi - -# Add RVM to PATH if it exists -if [[ -d "$HOME/.rvm/bin" && ! "$PATH" =~ (^|:)${HOME}/.rvm/bin(:|$) ]]; then - export PATH="$PATH:$HOME/.rvm/bin" -fi - -# Add Go binaries to PATH if Go is installed -if command -v go &> /dev/null; then - # Set GOPATH and add Go binaries to PATH - export GOPATH="${GOPATH:-$HOME/.go}" - if [[ ! "$PATH" =~ (^|:)${GOPATH}/bin(:|$) ]]; then - export PATH="$PATH:${GOPATH}/bin" +# Determine Homebrew prefix based on platform +case "$(uname -s)" in + Darwin) + if [[ -d "/nix/store" ]]; then + HOMEBREW_PREFIX="/run/current-system/sw" # Darwin with nix + elif [[ "$(uname -m)" == "arm64" ]]; then + HOMEBREW_PREFIX="/opt/homebrew" # Apple Silicon + else + HOMEBREW_PREFIX="/usr/local" # Intel macOS fi -fi + ;; + *) + HOMEBREW_PREFIX="/usr/local" # Fallback for other systems + ;; +esac -# Add Cargo (Rust) binaries to PATH if they exist -if [[ -d "$HOME/.cargo/bin" && ! "$PATH" =~ (^|:)${HOME}/.cargo/bin(:|$) ]]; then - export PATH="$HOME/.cargo/bin:$PATH" -fi - -# nvm setup (Node Version Manager) -if [[ -d "$HOME/.nvm" && ! "$PATH" =~ (^|:)${HOME}/.nvm(:|$) ]]; then - export NVM_DIR="$HOME/.nvm" - [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # Load nvm - [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # nvm bash completion -fi - -# Add macOS-specific command-line utilities (GNU coreutils) to PATH if installed via Homebrew -if [[ -d "${HOMEBREW_PREFIX}/opt/coreutils/libexec/gnubin" && ! "$PATH" =~ (^|:)${HOMEBREW_PREFIX}/opt/coreutils/libexec/gnubin(:|$) ]]; then - export PATH="${HOMEBREW_PREFIX}/opt/coreutils/libexec/gnubin:$PATH" -fi - -# Add directories to PATH if they exist and are not already present -dirs=("${HOMEBREW_PREFIX}/bin" "${HOMEBREW_PREFIX}/sbin" "/usr/local/bin" "/usr/local/sbin") -for dir in "${dirs[@]}"; do - if [[ -d "$dir" && ! "$PATH" =~ (^|:)$dir(:|$) ]]; then - export PATH="$dir:$PATH" - fi +# Add Homebrew binaries to PATH if they exist +for dir in "${HOMEBREW_PREFIX}/bin" "${HOMEBREW_PREFIX}/sbin"; do + [[ -d "$dir" && ! "$PATH" =~ (^|:)$dir(:|$) ]] && export PATH="$dir:$PATH" done -# Ensure /usr/local/opt/openssl@1.1/bin is in the PATH if installed -if [[ -d "/usr/local/opt/openssl@1.1/bin" && ! "$PATH" =~ (^|:)/usr/local/opt/openssl@1.1/bin(:|$) ]]; then - export PATH="/usr/local/opt/openssl@1.1/bin:$PATH" + +# ------------- PATH and Tools Setup ------------- + +# Ensure PYENV_ROOT and MODULAR_HOME are in PATH if set +[[ -n "$PYENV_ROOT" ]] && export PATH="$PYENV_ROOT/bin:$PATH" +export MODULAR_HOME="$HOME/.modular" +export PATH="$MODULAR_HOME/pkg/packages.modular.com_mojo:$PATH" + +# Add ~/.local/bin to PATH if it exists +[[ -d "$HOME/.local/bin" ]] && export PATH="$HOME/.local/bin:$PATH" + +# Add RVM (Ruby) and Cargo (Rust) binaries to PATH if they exist +[[ -d "$HOME/.rvm/bin" ]] && export PATH="$PATH:$HOME/.rvm/bin" +[[ -d "$HOME/.cargo/bin" ]] && export PATH="$HOME/.cargo/bin:$PATH" + +# Add Go binaries if Go is installed +if command -v go &> /dev/null; then + export GOPATH="${GOPATH:-$HOME/.go}" + export PATH="$PATH:$GOPATH/bin" fi -# Ensure /usr/local/opt/llvm/bin is in the PATH if installed -if [[ -d "/usr/local/opt/llvm/bin" && ! "$PATH" =~ (^|:)/usr/local/opt/llvm/bin(:|$) ]]; then - export PATH="/usr/local/opt/llvm/bin:$PATH" +# Load nvm if installed +if [[ -d "$HOME/.nvm" ]]; then + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" + [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" fi +# Add coreutils to PATH for macOS if installed via Homebrew +[[ -d "${HOMEBREW_PREFIX}/opt/coreutils/libexec/gnubin" ]] && export PATH="${HOMEBREW_PREFIX}/opt/coreutils/libexec/gnubin:$PATH" + +# Add openssl@1.1 and llvm to PATH if installed (for macOS devs) +[[ -d "/usr/local/opt/openssl@1.1/bin" ]] && export PATH="/usr/local/opt/openssl@1.1/bin:$PATH" +[[ -d "/usr/local/opt/llvm/bin" ]] && export PATH="/usr/local/opt/llvm/bin:$PATH" + +# Add BasicTeX binaries for macOS if installed +[[ -d "/Library/TeX/texbin" ]] && export PATH="/Library/TeX/texbin:$PATH" + + +# ------------- Conda / Mamba Setup ------------- + +# Configure paths for Conda / Miniforge installations on Apple Silicon +CONDA_PATHS=("/opt/homebrew/Caskroom/miniforge/base" "/usr/local/Caskroom/miniforge/base") +for CONDA_PATH in "${CONDA_PATHS[@]}"; do + if [[ -d "$CONDA_PATH" ]]; then + [ -f "$CONDA_PATH/etc/profile.d/conda.sh" ] && . "$CONDA_PATH/etc/profile.d/conda.sh" + [ -f "$CONDA_PATH/etc/profile.d/mamba.sh" ] && . "$CONDA_PATH/etc/profile.d/mamba.sh" + export PATH="$CONDA_PATH/bin:$PATH" + break # Stop after the first available path + fi +done + +# Compilation flags (optional) +# export ARCHFLAGS="-arch x86_64 -arch arm64" + diff --git a/zsh/.zshrc b/zsh/.zshrc index 3a32648..275bb2d 100755 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -1,59 +1,46 @@ -# Enable profiling +# ------------ Profile Information ----------- # zmodload zsh/zprof -# Path to your oh-my-zsh installation -# export ZSH="$HOME/.oh-my-zsh" -# export ZSH_CUSTOM="$HOME/.oh-my-zsh/custom" -# export UPDATE_ZSH_DAYS=1 +# ------------ Basic Settings ------------- # Disable auto title DISABLE_AUTO_TITLE="true" -# Auto-update and other zsh settings -# DISABLE_UPDATE_PROMPT=true -# zstyle ':omz:update' mode reminder # remind to update - -# Uncomment to use case-sensitive completion +# Uncomment to enable case-sensitive or hyphen-insensitive completion # CASE_SENSITIVE="true" - -# Uncomment to use hyphen-insensitive completion # HYPHEN_INSENSITIVE="true" -# Miscellaneous configurations +# Miscellaneous configurations (uncomment as needed) # DISABLE_MAGIC_FUNCTIONS="true" # DISABLE_LS_COLORS="true" # ENABLE_CORRECTION="true" # COMPLETION_WAITING_DOTS="true" # DISABLE_UNTRACKED_FILES_DIRTY="true" -# Load zsh hooks -# autoload -Uz add-zsh-hook -# -# Load zsh completions +# ------------ 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 ------------- + +# Load zsh completions with optimization autoload -Uz compinit +fpath=(/run/current-system/sw/bin/zsh/site-functions $fpath) -# Fix: Ensure correct completion directory for Apple Silicon -fpath=(/opt/homebrew/share/zsh/site-functions $fpath) -compinit +# Optimize compinit loading and reduce .zcompdump frequency +ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump" +if [[ ! -f $ZSH_COMPDUMP ]]; then + compinit -d "$ZSH_COMPDUMP" +else + compinit -C -d "$ZSH_COMPDUMP" +fi -# Plugins to load -# plugins=( -# git -# docker -# zsh-syntax-highlighting -# zsh-autosuggestions -# colored-man-pages -# macos -# autoupdate -# zoxide -# ) -# export ZSH_AUTOSUGGEST_STRATEGY=( -# history -# completion -# ) - -# Source oh-my-zsh.sh -# . $ZSH/oh-my-zsh.sh +# ------------ Plugin Manager (Zinit) ------------- # Load Zinit ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" @@ -61,12 +48,14 @@ if [ ! -d "$ZINIT_HOME" ]; then mkdir -p "$(dirname "$ZINIT_HOME")" git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" fi -source "${ZINIT_HOME}/zinit.zsh" +. "${ZINIT_HOME}/zinit.zsh" # Ensure compinit is loaded after zinit autoload -Uz _zinit (( ${+_comps} )) && _comps[zinit]=_zinit +# ------------ Zinit Plugin Configuration ------------- + # Load plugins with zinit zinit light zsh-users/zsh-completions zinit light zsh-users/zsh-history-substring-search @@ -75,16 +64,25 @@ zinit light zsh-users/zsh-history-substring-search zinit ice wait lucid atinit"ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)" zinit load zsh-users/zsh-syntax-highlighting -# Load async auto-suggestions +# Async auto-suggestions zinit ice wait lucid atload"zle-line-init() { zle autosuggest-enable }; zle -N zle-line-init" zinit load zsh-users/zsh-autosuggestions -# zoxide +# Load zoxide zinit ice from"gh-r" as"program" pick"bin/zoxide" zinit load ajeetdsouza/zoxide -# Load eza completions if needed -[[ ! "$FPATH" =~ (^|:)${HOME}/.local/bin/eza/completions/zsh(:|$) ]] && export FPATH="$HOME/.local/bin/eza/completions/zsh:$FPATH" +# Install fzf using its GitHub release +zinit ice from"gh-r" as"program" pick"bin/fzf" +zinit light junegunn/fzf-bin + +# Load fzf shell completion and key bindings from the fzf repository +zinit ice depth=1; zinit light junegunn/fzf + +# Sourcing fzf configs +. ~/.fzf.zsh + +# ------------ Additional Programs Initialization ------------- # Initialize direnv eval "$(direnv hook zsh)" @@ -96,51 +94,39 @@ eval "$(zoxide init --cmd cd zsh)" eval "$(starship init zsh)" export STARSHIP_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/starship.toml" -# ----------------- Conda & Mamba Setup ----------------- -# Conda paths where Miniforge is installed (for Apple Silicon) -CONDA_PATHS=("/opt/homebrew/Caskroom/miniforge/base" "/usr/local/Caskroom/miniforge/base") +# ------------ Pyenv Setup ------------- -for CONDA_PATH in "${CONDA_PATHS[@]}"; do - if [ -d "$CONDA_PATH" ]; then - # Manually set up Conda if available - if [ -f "$CONDA_PATH/etc/profile.d/conda.sh" ]; then - . "$CONDA_PATH/etc/profile.d/conda.sh" - else - # Fall back to adding Conda's bin directory to PATH if the profile.d script isn't found - export PATH="$CONDA_PATH/bin:$PATH" - fi +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 - # Initialize Mamba if available - if [ -f "$CONDA_PATH/etc/profile.d/mamba.sh" ]; then - . "$CONDA_PATH/etc/profile.d/mamba.sh" - fi +# ------------ Custom Aliases ------------- - # Break after initializing the first found Conda path - break - fi -done - -# ----------------- Skip Conda Init ----------------- -# Prevent 'conda init' from running again to avoid resetting setup -# conda init "$(basename "${SHELL}")" >/dev/null 2>&1 - -# Compilation flags -# export ARCHFLAGS="-arch x86_64 -arch arm64" - -# Custom aliases alias python="python3" alias grep="grep --color=auto" - alias ..="cd .." alias ...="cd ../.." alias ....="cd ../../.." alias .....="cd ../../../.." - +# Source additional alias checks if available if [[ -f ~/.local/bin/scripts/check_aliases ]]; then . ~/.local/bin/scripts/check_aliases fi -# zprof (commented out for speed) -# zprof +# ------------ Conditional Settings ------------- + +# Conditionally set the editor based on SSH connection +[[ -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