diff --git a/hosts/darwin/home-default.nix b/hosts/darwin/home-default.nix index 1579f55..a17907d 100644 --- a/hosts/darwin/home-default.nix +++ b/hosts/darwin/home-default.nix @@ -28,6 +28,43 @@ programs.home-manager.enable = true; + # darwin-specific alias + programs.zsh.shellAliases = { + oss = "sudo darwin-rebuild switch --flake ~/.config/nix#$(hostname)"; + + preview = "open -a Preview"; + slide = "open -a SlidePilot"; + pixel = "open -a 'Pixelmator Pro'"; + inkscape = "open -a Inkscape"; + }; + + # Darwin-specific zsh functions + programs.zsh.initExtra = '' + # Function to search and open all macOS applications + function app() { + local app_path + local file_to_open="$1" + + app_path=$( (find -L /Applications -name "*.app" -maxdepth 2 2>/dev/null; \ + find -L ~/Applications -name "*.app" -maxdepth 3 2>/dev/null; \ + find /System/Applications -name "*.app" -maxdepth 2 2>/dev/null; \ + find /System/Applications/Utilities -name "*.app" -maxdepth 1 2>/dev/null) | + sort | uniq | + fzf --header="Select app to open''${file_to_open:+ file: $file_to_open}" \ + --preview 'basename {} .app' \ + --preview-window=up:1 \ + --height=40%) + + if [[ -n "$app_path" ]]; then + if [[ -n "$file_to_open" ]]; then + open -a "$app_path" "$file_to_open" + else + open "$app_path" + fi + fi + } + ''; + home.packages = with pkgs; [ # Network and file transfer lftp diff --git a/hosts/nixos/home-default.nix b/hosts/nixos/home-default.nix index 7ca43ec..bd2a428 100644 --- a/hosts/nixos/home-default.nix +++ b/hosts/nixos/home-default.nix @@ -22,6 +22,11 @@ programs.home-manager.enable = true; + # nixOS-specific alias + programs.zsh.shellAliases = { + oss = "sudo nixos-rebuild switch --flake ~/.config/nix#$(hostname)"; + }; + home.packages = with pkgs; [ # Network and file transfer lftp diff --git a/hosts/nixos/hs/home.nix b/hosts/nixos/hs/home.nix index 4f6710b..5ad8f80 100644 --- a/hosts/nixos/hs/home.nix +++ b/hosts/nixos/hs/home.nix @@ -6,6 +6,9 @@ ]; # hs-specific home configuration - # Example: Server-specific tools, monitoring utilities, etc. + programs.zsh.shellAliases = { + # Disk health monitoring + smart-report = "sudo /home/yanlin/.config/nix/scripts/daily-smart-report.sh"; + }; -} \ No newline at end of file +} diff --git a/modules/zsh.nix b/modules/zsh.nix index 7a62d62..387d001 100644 --- a/modules/zsh.nix +++ b/modules/zsh.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: +{ config, pkgs, ... }: let projectsConfig = import ../config/projects.nix { homeDirectory = config.home.homeDirectory; }; @@ -27,17 +27,6 @@ in hm = "home-manager"; hms = "home-manager switch --flake ~/.config/nix#$(whoami)@$(hostname)"; hms-offline = "home-manager switch --flake ~/.config/nix#$(whoami)@$(hostname) --option substitute false"; - doss = "sudo darwin-rebuild switch --flake ~/.config/nix#$(hostname)"; - noss = "sudo nixos-rebuild switch --flake ~/.config/nix#$(hostname)"; - # Disk health monitoring - smart-report = "sudo /home/yanlin/.config/nix/scripts/daily-smart-report.sh"; - - } // lib.optionalAttrs pkgs.stdenv.isDarwin { - # macOS-specific app aliases - preview = "open -a Preview"; - slide = "open -a SlidePilot"; - pixel = "open -a 'Pixelmator Pro'"; - inkscape = "open -a Inkscape"; }; initContent = '' @@ -122,31 +111,6 @@ in fi } - # Function to search and open all macOS applications (macOS only) - ${lib.optionalString pkgs.stdenv.isDarwin '' - function app() { - local app_path - local file_to_open="$1" - - app_path=$( (find -L /Applications -name "*.app" -maxdepth 2 2>/dev/null; \ - find -L ~/Applications -name "*.app" -maxdepth 3 2>/dev/null; \ - find /System/Applications -name "*.app" -maxdepth 2 2>/dev/null; \ - find /System/Applications/Utilities -name "*.app" -maxdepth 1 2>/dev/null) | - sort | uniq | - fzf --header="Select app to open''${file_to_open:+ file: $file_to_open}" \ - --preview 'basename {} .app' \ - --preview-window=up:1 \ - --height=40%) - - if [[ -n "$app_path" ]]; then - if [[ -n "$file_to_open" ]]; then - open -a "$app_path" "$file_to_open" - else - open "$app_path" - fi - fi - } - ''} # Interactive project launcher with fzf function proj() {