summary refs log tree commit diff stats
path: root/user
diff options
context:
space:
mode:
authorAlan Pearce2024-04-28 15:07:41 +0200
committerAlan Pearce2024-04-28 15:07:41 +0200
commit3687c74befcaea4e309161f211a7397c4366ae56 (patch)
treec5fb1814f75703adcbd6e322040c2719a104e9e0 /user
parentc3e487e8d7bf5f708b401c018594972a283be365 (diff)
downloadnixfiles-3687c74befcaea4e309161f211a7397c4366ae56.tar.lz
nixfiles-3687c74befcaea4e309161f211a7397c4366ae56.tar.zst
nixfiles-3687c74befcaea4e309161f211a7397c4366ae56.zip
fish: write function to enable `open -a appname[.desktop]` on linux
Diffstat (limited to 'user')
-rw-r--r--user/settings/fish.nix19
1 files changed, 18 insertions, 1 deletions
diff --git a/user/settings/fish.nix b/user/settings/fish.nix
index f6ad67da..de4ec062 100644
--- a/user/settings/fish.nix
+++ b/user/settings/fish.nix
@@ -43,7 +43,24 @@
     functions = {
       ds = "du -hd1 $argv[1] | sort -h";
       last_history_item = "echo $history[1]";
-    };
+    } // (lib.attrsets.optionalAttrs pkgs.stdenv.isLinux {
+      open = ''
+        argparse h/help a/application -- $argv
+        or return
+
+        if set -ql _flag_help
+           echo "open [-h|--help] [-a application] [arguments...]"
+           return 1
+        end
+
+        if set -ql _flag_application
+           # TODO: support reverse-domain- named files (e.g. org.kde.kate.desktop)
+           ${pkgs.gtk3}/bin/gtk-launch $argv[1]
+        else
+          xdg-open $argv
+        end
+      '';
+    });
   };
   xdg.configFile."fish/completions" = {
     recursive = true;