You can use the .psqlrc for this purpose, though I suppose you could also real that in via a file on demand, too. You make entries something like:
\set show_slow_queries
'SELECT
(total_time / 1000 / 60) as total_minutes,
(total_time/calls) as average_time, query
FROM pg_stat_statements
ORDER BY 1 DESC
LIMIT 100;'
and then later at the command prompt you access it as; ":show_slow_queries".
I have a few system queries like this in my .psqlrc file, but I don't do much which this feature often truth be told. I have a pretty strong knowledge of the database schema I work with, I do a lot of work on systems I don't regularly control so its not dependably available, and readline history suffices for more immediate needs.
i use ssms for mssql, and i have a large solution with multiple projects
i know datagrip can be used in the same way as ssms, but can you this be done using psql