From 8e4a4961cc126779a5570518e4b819d0520c2cfe Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Sat, 24 Jun 2023 11:58:20 -0400 Subject: [PATCH] qutebrowser: use fish as a file manager --- src/.config/qbprof/dsc/config/config.py | 5 +++++ src/.config/qutebrowser/config.py | 5 +++++ src/.local/bin/fish-fm | 26 +++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100755 src/.local/bin/fish-fm diff --git a/src/.config/qbprof/dsc/config/config.py b/src/.config/qbprof/dsc/config/config.py index c75cd4b..6bc27ff 100644 --- a/src/.config/qbprof/dsc/config/config.py +++ b/src/.config/qbprof/dsc/config/config.py @@ -14,3 +14,8 @@ c.fonts.default_family = "JetBrains Mono" c.downloads.location.directory = "~/quar/" c.scrolling.smooth = True c.downloads.remove_finished = 1000 + +# homegrown file selector +c.fileselect.handler = "external" +c.fileselect.multiple_files.command = ["st", "-e", "fish", "-C", "set -x OUTPUT {}; source ~/.local/bin/fish-fm"] +c.fileselect.single_file.command = ["st", "-e", "fish", "-C", "set -x OUTPUT {}; source ~/.local/bin/fish-fm"] diff --git a/src/.config/qutebrowser/config.py b/src/.config/qutebrowser/config.py index b327c46..e6ec6dd 100644 --- a/src/.config/qutebrowser/config.py +++ b/src/.config/qutebrowser/config.py @@ -115,3 +115,8 @@ config.bind("ct", "hint title userscript code_select.py") # use libre redirects config.bind(",fl", "hint links userscript fixlink.sh") config.bind(",fL", "hint links userscript fixlink-tab.sh") + +# homegrown file selector +c.fileselect.handler = "external" +c.fileselect.multiple_files.command = ["st", "-e", "fish", "-C", "set -x OUTPUT {}; source ~/.local/bin/fish-fm"] +c.fileselect.single_file.command = ["st", "-e", "fish", "-C", "set -x OUTPUT {}; source ~/.local/bin/fish-fm"] diff --git a/src/.local/bin/fish-fm b/src/.local/bin/fish-fm new file mode 100755 index 0000000..6ab4058 --- /dev/null +++ b/src/.local/bin/fish-fm @@ -0,0 +1,26 @@ +#!/bin/fish +# simple wrapper to let you select files in the terminal +# call it like this: +# +# fish -P -C "set -x OUTPUT [output file]; source fish-fm" +# +# if specified, $OUTPUT will contain the selected paths +# otherwise paths are printed to stdout +# in the shell, write the following to select files: +# +# sel file1 file2 file3 +# + +if test -z "$OUTPUT" + set OUTPUT /dev/stdout +end + +# clear output +printf "" > "$OUTPUT" + +function sel + for arg in $argv + realpath "$arg" >> "$OUTPUT" + end + exit +end