Always executing a command in local user space reddit / emacs ---------------------------------------------------------------------- Tohiko · 2022-06-12 19:49 When I execute the command ``` (shell-command-to-string "whoami") ``` in a local buffer, I get the local user name as expected. However, when I execute the same command on a tramp buffer (for example editing a root file with `sudo-edit`), I get the `root` username. How can I ensure that my command is always executed on the local user space regardless on the current buffer? ---------------------------------------------------------------------- ieure · 2022-06-12 23:10 Commands run in the context of `default-directory`, which is good: you can do things like run compilation on remote hosts. If you want something to execute in a different location, you can let- bind `default-directory` around the expression, so it points at `~/` or some other path on your local machine. ---------------------------------------------------------------------- Tohiko · 2022-06-13 09:36 Yep, this works!