tenseleyflow/gump / 84105d1

Browse files

use Enter key interception for fish instead of command_not_found

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
84105d1ad4d19d501507ca50eff4cc808fb7690c
Parents
fb39df9
Tree
3292cce

1 changed file

StatusFile+-
M src/cmd/init.rs 37 13
src/cmd/init.rsmodified
@@ -263,28 +263,52 @@ end
263263
         ));
264264
     }
265265
 
266
-    // fish_command_not_found for no-prefix jumping
266
+    // Intercept Enter key to check for gump jumps before execution
267267
     output.push_str(r#"
268
-# No-prefix directory jumping - must erase existing handler first
269
-functions -e fish_command_not_found
268
+# No-prefix directory jumping via Enter key interception
269
+function __gump_execute
270
+    set -l cmd (commandline -b)
271
+    set -l first_word (string split ' ' -- $cmd)[1]
272
+
273
+    # Skip if empty
274
+    if test -z "$first_word"
275
+        commandline -f execute
276
+        return
277
+    end
270278
 
271
-function fish_command_not_found --on-event fish_command_not_found
272
-    # Check if it's a local directory first
273
-    if test -d "$argv[1]"
274
-        cd $argv[1]
275
-        return 0
279
+    # Skip if command exists
280
+    if type -q "$first_word"
281
+        commandline -f execute
282
+        return
283
+    end
284
+
285
+    # Skip if starts with path characters
286
+    if string match -qr '^[./~]' -- "$first_word"
287
+        commandline -f execute
288
+        return
289
+    end
290
+
291
+    # Check if it's a local directory
292
+    if test -d "$first_word"
293
+        commandline -r "cd $first_word"
294
+        commandline -f execute
295
+        return
276296
     end
277297
 
278298
     # Query gump database
279
-    set -l result (command gump query -- $argv 2>/dev/null)
299
+    set -l result (command gump query -- $cmd 2>/dev/null)
280300
     if test -n "$result"
281
-        cd $result
282
-        return 0
301
+        commandline -r "cd \"$result\""
302
+        commandline -f execute
303
+        return
283304
     end
284305
 
285
-    # Fallback to default handler
286
-    __fish_default_command_not_found_handler $argv
306
+    # Not a gump match, execute normally
307
+    commandline -f execute
287308
 end
309
+
310
+bind \r __gump_execute
311
+bind \n __gump_execute
288312
 "#);
289313
 
290314
     output