Replace `which` with `command -v` in remote Emacs article.

This commit is contained in:
tastytea 2019-10-17 21:32:26 +02:00
parent 4c5d314b64
commit 02970f8493
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 14 additions and 14 deletions

View File

@ -179,22 +179,22 @@ NOTE: I wrote the following code for Zsh, but it should also work for Bash.
----
{{< highlight zsh >}}
# Set preferred editor.
if which emacsclient > /dev/null; then
VISUAL="$(which emacsclient) -f ~/.emacs.d/server/server -a emacs"
if command -v emacsclient > /dev/null; then
VISUAL="$(command -v emacsclient) -f ~/.emacs.d/server/server -a emacs"
if [[ -n "${SSH_CONNECTION}" ]]; then # Logged in via SSH.
if which emacsremote > /dev/null; then
VISUAL="$(which emacsremote)"
if command -v emacsremote > /dev/null; then
VISUAL="$(command -v emacsremote)"
fi
elif [[ $(id -u) -eq 0 ]] && which emacsremote > /dev/null; then
elif [[ $(id -u) -eq 0 ]] && command -v emacsremote > /dev/null; then
# Edit files as root in the Emacs instance run by the current user.
VISUAL="$(which emacsremote) --sudo --local"
VISUAL="$(command -v emacsremote) --sudo --local"
fi
elif which emacs > /dev/null; then
VISUAL="$(which emacs)"
elif which vim > /dev/null; then
VISUAL="$(which vim)"
elif which nano > /dev/null; then
VISUAL="$(which nano)"
elif command -v emacs > /dev/null; then
VISUAL="$(command -v emacs)"
elif command -v vim > /dev/null; then
VISUAL="$(command -v vim)"
elif command -v nano > /dev/null; then
VISUAL="$(command -v nano)"
fi
export VISUAL
export EDITOR="${VISUAL}"
@ -208,9 +208,9 @@ if [[ "${VISUAL}" =~ "emacs(client|remote)" ]]; then
if [[ "${VISUAL}" =~ "emacsremote$" ]]; then
# Don't block the terminal until the file is closed.
alias se="${VISUAL} -n --sudo"
elif which emacsremote >/dev/null && [[ -z "${SSH_CONNECTION}" ]]; then
elif command -v emacsremote >/dev/null && [[ -z "${SSH_CONNECTION}" ]]; then
# Edit files as root in the Emacs instance run by the current user.
alias se="$(which emacsremote) -n --sudo --local"
alias se="$(command -v emacsremote) -n --sudo --local"
fi
else
alias e="${VISUAL}"