Add app to favorites from command line

Unfortunately, as an end-user you can only "read" and "write" (also reset) the array that dictates the list of favourite apps by using dconf/gsettings. For example, as mentioned here, you can get the value by running

gsettings get org.gnome.shell favorite-apps

and write a new value by a suitable gsettings set command. There is no straightforward way to append to the array, you can only overwrite.

But you can combine these two and have a custom command. You need to know the name of the .desktop launcher associated to the application you want to add to the favourites first. Let's say it is appname.desktop. Then you can run the following to add the application associated to appname.desktop to the favourites:

gsettings set org.gnome.shell favorite-apps "$(gsettings get org.gnome.shell favorite-apps | sed s/.$//), 'appname.desktop']"