comint-watch-for-password-prompt (see the Shell Mode manual).The following environment variables make sense when using Emacs:
export EDITOR="/usr/bin/emacsclient -a /usr/bin/emacs" export ALTERNATE_EDITOR="/usr/bin/emacs"
Put it into files like ~/.bashrc, ~/.zshrc and/or ~/.xsession (see Environmental Settings or MacBook Software Installation Wiki page).
To have shell coloring in Shell Mode the following code might be helpful in ~/.bashrc, ~/.zshrc or equivalent.
if [ "${INSIDE_EMACS/*comint*/comint}" == "comint" -o \ "${INSIDE_EMACS/*tramp*/tramp}" == "tramp" ] ; then export GIT_PAGER="" export TERM=ansi fi
If you want to use sudo with Emacs Lisp function shell-command then it possibly does not work in a graphical environment like GTK+. 1) For this case i created a shell-script askpass.sh, with the following content:
#!/bin/sh gksudo --print-pass --preserve-env --description "sudo password" 2>/dev/null
Then set environment variable
export SUDO_ASKPASS="$HOME/bin/askpass.sh"
and implement your shell command:
(shell-command (format "sudo -E -A my-sudo-cmd %s" my-sudo-execdir))
On macOS the same principles hold true. One proposed solution is to use pinentry-mac (installed via Homebrew) together with this ss-askpass wrapper.
comint-watch-for-password-prompt (see the Shell Mode manual).