Gnome / Ubuntu: Configure MIME-Type

Show default mime
https://wiki.ubuntuusers.de/xdg-utils/

file --mime script1.sh
xdg-mime query filetype script1.sh
xdg-mime query default text/x-shellscript
 
xdg-mime query default inode/directory
xdg-mime query default text/html
xdg-mime query default x-scheme-handler/mailto
xdg-mime query default text/plain
xdg-mime query default image/jpeg
xdg-mime query default application/pdf
 
# set default browser?
https://askubuntu.com/questions/1161752/how-can-i-configure-a-domain-specific-default-browser
gio mime x-scheme-handler/http
gio mime x-scheme-handler/https
xdg-settings set default-web-browser chromium-browser.desktop

Configure user default MIME-Type application

#xdg-mime default code.desktop text/plain
xdg-mime default code_code.desktop text/plain
xdg-mime default code_code.desktop application/x-shellscript

# old
https://wiki.selfhtml.org/wiki/MIME-Type/%C3%9Cbersicht#T
by user

mkdir -p ~/.local/share/applications
 
cat <<EOF>> ~/.local/share/applications/mimeapps.list
[Default Applications]
text/plain = code.desktop
text/x-shellscript = code.desktop
EOF
 
sed -i 's|text/plain = .*|text/plain = code.desktop|g' ~/.local/share/applications/mimeapps.list

Configure global

/etc/gnome/defaults.list
sudo sed -i 's|text/plain=gedit.desktop|text/plain=code.desktop|g' /etc/gnome/defaults.list

gio
https://help.gnome.org/admin/system-admin-guide/stable/mime-types-application-user.html.en

gio mime text/plain