From 3cebacf81a70ca8eb1d6a18039b5d6cf43115839 Mon Sep 17 00:00:00 2001 From: sev Date: Sat, 14 Dec 2024 16:20:06 -0600 Subject: [PATCH] zsh: replace some ifs with short ifs --- etc/zsh/.zprofile | 6 +++--- etc/zsh/.zshrc | 4 ++-- etc/zsh/functions/Prompts/prompt_arrows_setup | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/etc/zsh/.zprofile b/etc/zsh/.zprofile index c66bfb5..5b5870f 100644 --- a/etc/zsh/.zprofile +++ b/etc/zsh/.zprofile @@ -179,11 +179,11 @@ if [[ ! -v _sev_setup_ssh ]] { if [[ -f $e ]] { IFS=$'\0' read -r sock pid <$e } - if [[ -S $sock && $pid > 0 ]] && kill -0 $pid >/dev/null 2>&1; then + if ([[ -S $sock && $pid > 0 ]] && kill -0 $pid >/dev/null 2>&1) { [[ -o interactive ]] && print -P "Reusing agent PID $pid%f" export SSH_AUTH_SOCK=$sock export SSH_AGENT_PID=$pid - else + } else { # TODO: ensure ssh-agent path looks legit to avoid unsafe eval? # XXX: doesn't appear to be any other way to handle redirection. # because eval needs to write to current scope environment @@ -198,7 +198,7 @@ if [[ ! -v _sev_setup_ssh ]] { } echo -En - $SSH_AUTH_SOCK$'\0'$SSH_AGENT_PID >!$e unset c - fi + } unset okc e sock pid } elif [[ ! -v SSH_AUTH_SOCK && -v commands[gpg] ]] { # since gpg should have been started above, just export and notify diff --git a/etc/zsh/.zshrc b/etc/zsh/.zshrc index 0b72a56..d2d0870 100644 --- a/etc/zsh/.zshrc +++ b/etc/zsh/.zshrc @@ -143,12 +143,12 @@ if [[ ! -v _sev_force_zkbd && ( -v terminfo || -v termcap ) ]] { } find_keymap if [[ -z $keymap ]] { - if read -q "?Can't read terminfo. Add new zkbd keymap? [y/N]"; then + if (read -q "?Can't read terminfo. Add new zkbd keymap? [y/N]") { echo autoload -Uz zkbd && zkbd unfunction zkbd find_keymap - fi + } echo } if [[ -n $keymap ]] { diff --git a/etc/zsh/functions/Prompts/prompt_arrows_setup b/etc/zsh/functions/Prompts/prompt_arrows_setup index 9c59b8f..991332d 100644 --- a/etc/zsh/functions/Prompts/prompt_arrows_setup +++ b/etc/zsh/functions/Prompts/prompt_arrows_setup @@ -105,15 +105,15 @@ function prompt_arrows_precmd { } function prompt_arrows_preview { - if (( ! $#* )); then - prompt_preview_theme arrows 2line - print '\n' - prompt_preview_theme arrows right - print - else - prompt_preview_theme arrows "$@" - print - fi + if (( ! $#* )) { + prompt_preview_theme arrows 2line + print '\n' + prompt_preview_theme arrows right + print + } else { + prompt_preview_theme arrows "$@" + print + } } function +vi-prompt_arrows_revertfix() { -- 2.48.1