posts/fish-fm.md: added
This commit is contained in:
parent
d2dba470f5
commit
aa16f1f674
62
posts/fish-fm.md
Normal file
62
posts/fish-fm.md
Normal file
@ -0,0 +1,62 @@
|
||||
# using the shell as a file picker for qutebrowser
|
||||
|
||||
2023-06-28
|
||||
|
||||
[Qutebrowser](https://github.com/qutebrowser/qutebrowser) is pretty great (thanks The-Compiler <3).
|
||||
For those who don't know about it, it's essentially a Vim-like browser:
|
||||
there's a bunch of cryptic shortcuts, but they maximize your efficiency.
|
||||
The best part of Vim, which is replicated in Qutebrowser,
|
||||
is the ability to do everything without taking your hands off the keyboard.
|
||||
|
||||
Anyways, an issue I had was that when uploading a file in Qutebrowser is that it calls on a normal GUI file picker.
|
||||
This is probably a sane default, but the default file picker does not have Vim shortcuts (absolutely unusable!).
|
||||
Now, you *could* use [ranger](https://github.com/ranger/ranger), or [vifm](https://github.com/vifm/vifm)
|
||||
in the way described [here](https://reddit.baby/r/qutebrowser/comments/r9igqe/need_help_using_ranger_as_file_chooser/),
|
||||
but that's boring.
|
||||
Instead, as a masochist power user, I manage all my files exclusively in the shell,
|
||||
and I wanted to have that experience in Qutebrowser.
|
||||
So, I made a 25-line script `fish-fm` that does just that.
|
||||
|
||||
## demonstration
|
||||
|
||||
Here's an example usage of fish-fm.
|
||||
|
||||
First, when a website asks you to upload a file, qutebrowser opens a terminal window with fish-fm.
|
||||
Then, you have a full fish shell in which
|
||||
you can run `sxiv`, `mpv`, or any other command to inspect your files first.
|
||||
This also includes all its features like history and autosuggestions.
|
||||
Once you figure out what you want to upload, you then run `sel [file paths]`.
|
||||
The great thing about this is that you can use any glob or even xargs with this command.
|
||||
As a demo:
|
||||
|
||||
![](../public/img/fish-fm/term-thumb.jpg)
|
||||
![](../public/img/fish-fm/discord-thumb.jpg)
|
||||
|
||||
### sxiv selection
|
||||
|
||||
Optionally, you can run `ssel [directory or file paths]`,
|
||||
which uses sxiv to view your images.
|
||||
Then, you can mark the images (see sxiv's man page), and those will be uploaded.
|
||||
|
||||
![](../public/img/fish-fm/sxiv.jpg)
|
||||
|
||||
## installation
|
||||
|
||||
+ Install the dependencies: qutebrowser, fish
|
||||
+ Copy [fish-fm](https://github.com/dogeystamp/dots/blob/main/src/.local/bin/fish-fm) somewhere in your PATH.
|
||||
+ Create a qutebrowser [config.py](https://github.com/qutebrowser/qutebrowser/blob/master/doc/help/configuring.asciidoc#configuring-qutebrowser-via-configpy).
|
||||
Then, add these lines:
|
||||
|
||||
```
|
||||
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"]
|
||||
```
|
||||
|
||||
Depending on your terminal, you might have to edit these commands.
|
||||
I personally use `st`; yours may be different.
|
||||
The `{}` here is a placeholder for a temporary file where fish-fm writes its output.
|
||||
This is necessary because terminals don't forward the stdout of their commands,
|
||||
so fish-fm can't just print the files selected.
|
||||
|
||||
+ Your file picker is now a fish shell.
|
BIN
public/img/fish-fm/discord-thumb.jpg
Normal file
BIN
public/img/fish-fm/discord-thumb.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
public/img/fish-fm/discord.jpg
Normal file
BIN
public/img/fish-fm/discord.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
BIN
public/img/fish-fm/sxiv.jpg
Normal file
BIN
public/img/fish-fm/sxiv.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
public/img/fish-fm/term-thumb.jpg
Normal file
BIN
public/img/fish-fm/term-thumb.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.0 KiB |
BIN
public/img/fish-fm/term.jpg
Normal file
BIN
public/img/fish-fm/term.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Loading…
Reference in New Issue
Block a user