Bash aliases and functions can’t contain (white)space characters. Since Flatpak programs can’t seemingly feasibly ship with man pages I’d prefer the following functionality for a program (as an example):
command
executes
man mpv
w3m 'https://mpv.io/manual/stable/'
So man mpv would run w3m 'https://mpv.io/manual/stable/' (opens the online documentation in a browser).
I’ve of course used an dashed alias so far, but retaining the past command is much preferred due to muscle memory (I used to source mpv from RPM Fusion).
alias man-mpv='w3m "https://mpv.io/manual/stable/"'
You want to change the man command, mpv is just the argument.
Either you add those entries yourself (which flatpak should totally do), or yoz write a wrapper for man that looks up custom pages if the manpage is not found.
#!/bin/bash
man() {
#check if man entry exists, dont output error messages
if man -w "$1" >/dev/null 2>&1; then
command man "$1"
#otherwise use custom command per entry, put as many elifs here as needed
elif [[ "$1" == "mpv" ]]; then
w3m 'https://mpv.io/manual/stable/'
else
echo "No manual entry found for $1"
fi
}
man "$@"
To be fair the best solution would be if flatpak could have a dedicated man entry container that it can use, and man having support for it.
@boredsquirrel Doesn’t work on my end. I created and ran the script, but man mpv prints the echo error message you’ve added. The native man pages appear to load.
I also tested in a fresh Fedora 39 VM. I may be using the script incorrectly, I’m not familiar with wrapper scripts.
I’m playing with this, added as a function to my bashrc
Edit … added comments
flatman () {
#looking to see if a manpage exists where fedora normally keeps them
manfile=$(ls /usr/share/man/*/"${1}".[0-9].gz 2>/dev/null || ls /usr/local/share/man/*/"${1}".[0-9].gz 2>/dev/null)
if [[ ! -z "${manfile}" ]]; then
# if the manfile variable is not null look at the regular man age
man "${1}"
else
# if $1 matches the pattern below use that for the man page otherwise
# say there is nothing to display
case "${1}" in
mpv)
w3m "https://mpv.io/manual/stable/" 2>/dev/null
;;
*)
echo "Nothing to display"
;;
esac
fi
}