Gnome / Ubuntu: Configure MIME-Type

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

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

Configure user default MIME-Type application

xdg-mime default code.desktop text/plain
xdg-mime default code_code.desktop text/plain

# 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