diff --git a/modules/applications/zsh.nix b/modules/applications/zsh.nix index aadc67d..ce87f0a 100644 --- a/modules/applications/zsh.nix +++ b/modules/applications/zsh.nix @@ -29,8 +29,33 @@ in plugins = [ "git" ]; theme = "frisk"; }; - loginExtra = '' - eval "$(zoxide init --cmd cmd zsh)" + initContent = '' + command_not_found_handler() { + local cmd="$1" + + # If the thing you typed is a regular file, try to open it + if [[ -f "$cmd" ]]; then + # Determine MIME type + local mime + mime=$(xdg-mime query filetype -- "$cmd" 2>/dev/null) + + if [[ -n "$mime" ]]; then + print "Opening '$cmd' with xdg-open (MIME: $mime)…" + xdg-open "$cmd" >/dev/null 2>&1 & + return 0 + else + print "No known MIME type for '$cmd'." + print "You can assign one using:" + print " xdg-mime install .xml" + print " xdg-mime default .desktop $cmd" + return 1 + fi + fi + + # Default: real command not found + print "zsh: command not found: $cmd" + return 127 + } ''; }; };