From cf8b4b8d7e8e8d1b0e972c49a2637896691abde1 Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 28 Mar 2022 06:18:33 +0200 Subject: [PATCH] Zsh: replace $(id -u) with ${EUID} Less subshells spawned. --- .config/zsh/.zprofile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.config/zsh/.zprofile b/.config/zsh/.zprofile index 1afff98..846bb59 100644 --- a/.config/zsh/.zprofile +++ b/.config/zsh/.zprofile @@ -23,7 +23,7 @@ if command -v emacsclient > /dev/null; then else VISUAL="$(command -v emacs)" fi - if [[ $(id -u) -eq 0 ]]; then + if [[ ${EUID} -eq 0 ]]; then # Edit files as root in the Emacs instance run by the current user. VISUAL="$(command -v emacsremote) --sudo --local" fi @@ -151,8 +151,8 @@ esac # Run SSH/GPG agents if they are installed and not already started. If they are # started, attempt to inherit them. if command -v keychain > /dev/null; then - if [[ $(pgrep --uid $(id -u) ssh-agent) - && $(pgrep --uid $(id -u) gpg-agent) ]]; then + if [[ $(pgrep --uid ${EUID} ssh-agent) + && $(pgrep --uid ${EUID} gpg-agent) ]]; then # Set environment variables from files. if [[ -z "${SSH_AUTH_SOCK}" ]]; then source "${HOME}/.keychain/$(hostname)-sh" @@ -175,11 +175,11 @@ if command -v keychain > /dev/null; then else # keychain not installed, start SSH/GPG agents if they are not running. if command -v ssh-agent > /dev/null \ - && [[ ! $(pgrep --uid $(id -u) ssh-agent) ]]; then + && [[ ! $(pgrep --uid ${EUID} ssh-agent) ]]; then eval $(ssh-agent -t 16H 2> /dev/null) fi if command -v gpg-agent > /dev/null \ - && [[ ! $(pgrep --uid $(id -u) gpg-agent) ]]; then + && [[ ! $(pgrep --uid ${EUID} gpg-agent) ]]; then eval $(gpg-agent --daemon --quiet --default-cache-ttl $((60*16)) \ --max-cache-ttl $((60*16))) fi