I was wondering if it is possible to use the current login user name in Emacs config files (in elisp)?
For example, some times the username and default database for a PostgreSQL database are the same as the current login Unix/Linux user name in many multi-user environment. When configuring a Emacs SQL mode and supplying user and database to connect to, something as the following can be used in the Emacs config.
(setq sql-postgres-login-params
'((user :default "postgres")
(database :default "postgres")
(server :default "localhost")
(port :default 5432)))
How can I replace the username
and database
from "postgres"
to the value of $(whoami)
in Linux/Unix?
That would be user-login-name. Just in case you don't know, be sure to no write it inside a quoted list. You can use a backquote:
`((user :default ,user-login-name))