Text attachments should display in the browser, not forced downloaded

cracauer@

Developer
Text attachments should display in the browser, not forced downloaded.

Consider the first post here: https://forums.freebsd.org/threads/audinst-hud-mx1usb-dac-sound-volume-very-low.102321/

I want to see dmesg. As it is right now I have to download it, open it from HD and then clean up afterwards. It should just display the text in a browser tab. This is done via http header.

I know that XenForo does this by default and last I heard there was no option to turn this nonsense off. But maybe there us a way, or an update or something.
 
using firefox to navigate to

file:///var/run/dmesg.boot

And opening it works for me and displays text in the firefox window.
That works for files on the local system, but I believe cracauer@ is talking about text files that someone attaches to a post on the forum. The thread linked in the OP has 3 attachments, all text files. If you want to look at the contents, clicking on one causes a download, not just open in a new tab.
 
OK. I can configure the DOWNLOAD setting in firefox to "Always ask you where to save files"
this pops up a dialouge where I can view the file in an editor or I can select a browser to view the file in .
 
I have two scripts; one monitors the download of text files.
The other opens hx or vim to view the file.
Install pkg install entr
You can change the editor.
Sorry, the comments are in French.
15:32 %> cat watch-txt.sh
#!/bin/sh

DL="$HOME/Telechargement"
CACHE="/tmp/hx_last_opened_txt"

[ -d "$DL" ] || exit 1

# surveille le dossier lui-même
while true; do
printf '%s\n' "$DL" | entr -d sh -c '
DL="'"$DL"'"
CACHE="'"$CACHE"'"

FILE=$(find "$DL" -maxdepth 1 -type f -name "*.txt" -print 2>/dev/null \
| xargs ls -t 2>/dev/null | head -n 1)

[ -n "$FILE" ] || exit 0

MTIME=$(stat -f "%m" "$FILE" 2>/dev/null) || exit 0
NOW=$(date +%s)
AGE=$((NOW - MTIME))

# ignorer les vieux fichiers
[ "$AGE" -gt 5 ] && exit 0

LAST=""
[ -f "$CACHE" ] && LAST=$(cat "$CACHE" 2>/dev/null)

# éviter de rouvrir le même fichier
[ "$FILE" = "$LAST" ] && exit 0

echo "$FILE" > "$CACHE"

# laisser finir le renommage / flush Firefox
sleep 1

exec xfce4-terminal --hold -e "hx \"$FILE\""
'
done

and
15:33 %> cat open-last-txt.sh
#!/bin/sh

DL="$HOME/Telechargement"

# dlast file downloaded
FILE=$(ls -t "$DL"/*.txt 2>/dev/null | head -n 1)

[ -z "$FILE" ] && exit 0

# open helix
exec hx "$FILE"
my editor is hx
 
Back
Top