From 294ed44e1a8dd7a6026213380c41bceb1a4a162a Mon Sep 17 00:00:00 2001 From: sev Date: Wed, 3 Jan 2024 07:44:40 -0600 Subject: [PATCH] zsh: clean up echo usage --- etc/zsh/.zlogout | 4 ++-- etc/zsh/.zprofile | 4 ++-- etc/zsh/.zshenv | 2 +- etc/zsh/.zshrc | 6 +++--- etc/zsh/functions/Prompts/prompt_arrows_setup | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/etc/zsh/.zlogout b/etc/zsh/.zlogout index 1b2b266..8ab31d1 100644 --- a/etc/zsh/.zlogout +++ b/etc/zsh/.zlogout @@ -15,7 +15,7 @@ if [[ -o interactive ]] { # send xterm scrollback clear extension just in case: # - TERM may not be set correctly # - terminfo/termcap database entry for reset may be buggy - echo -n '\e[3J' + echo -en '\e[3J' # use terminfo/termcap directly instead of relying on system clear/reset: # - often they are just wrappers for ncurses tput or other tools # - they may not even exist on lightweight systems @@ -35,7 +35,7 @@ if [[ -o interactive ]] { } if (( y == 0 )) { # fallback, send ECMA-48 clear - echo -n '\e[2J' + echo -en '\e[2J' } echo logout } diff --git a/etc/zsh/.zprofile b/etc/zsh/.zprofile index 58ebfa1..5ead916 100644 --- a/etc/zsh/.zprofile +++ b/etc/zsh/.zprofile @@ -71,7 +71,7 @@ if [[ ! -v DBUS_SESSION_BUS_ADDRESS && -v commands[dbus-launch] ]] { # clunky (e.g. asking for password twice) to make it worth it. function _gpg_socketpath { # dirs are percent-encoded: https://stackoverflow.com/a/64312099 - echo ${1//(#b)%([[:xdigit:]](#c2))/${(#):-0x$match[1]}} + echo -E - ${1//(#b)%([[:xdigit:]](#c2))/${(#):-0x$match[1]}} } if [[ ! -v _sev_setup_gpg_forward && -v commands[gpg] ]] { # XXX: assuming /tmp exists and is writable on destination @@ -193,7 +193,7 @@ if [[ ! -v _sev_setup_ssh ]] { } else { eval $(eval $=c) >/dev/null 2>&1 } - echo -n $SSH_AUTH_SOCK$'\0'$SSH_AGENT_PID >!$e + echo -En - $SSH_AUTH_SOCK$'\0'$SSH_AGENT_PID >!$e unset c fi unset okc e sock pid diff --git a/etc/zsh/.zshenv b/etc/zsh/.zshenv index 99e3372..1bcc1f8 100644 --- a/etc/zsh/.zshenv +++ b/etc/zsh/.zshenv @@ -103,7 +103,7 @@ export LANG=${LANG:-en_US.UTF-8} [[ -v _sev_home ]] || export _sev_home=$HOME ## fix broken term -# NOTE: we do this here instead of .zshrc since we might echo stuff +# NOTE: we do this here instead of .zshrc since we might print stuff if [[ -t 1 ]] { # only if stdout is tty [[ ! -v TERM ]] && export TERM=xterm-256color >/dev/null 2>&1 if [[ $#terminfo -eq 0 ]] { diff --git a/etc/zsh/.zshrc b/etc/zsh/.zshrc index f8d9843..90f4870 100644 --- a/etc/zsh/.zshrc +++ b/etc/zsh/.zshrc @@ -137,7 +137,7 @@ if [[ ! -v _sev_force_zkbd && ( -v terminfo || -v termcap ) ]] { if [[ -n $keymap ]] { source $keymap } else { - echo "Failed to source keymap file $keymap" >&2 + echo -E "Failed to source keymap file $keymap" >&2 } unfunction find_keymap; unset keymap } @@ -268,7 +268,7 @@ if [[ -v commands[zoxide] ]] { } alias cd..=up ## dotfiles -alias dfu='d=${$(echo ~/.zshenv):P:h:h};GIT_DIR=$d/.git GIT_WORK_TREE=$d git pull' +alias dfu='d=${$(echo -E - ~/.zshenv):P:h:h};GIT_DIR=$d/.git GIT_WORK_TREE=$d git pull' ### hooks autoload -Uz add-zsh-hook @@ -341,7 +341,7 @@ case $OSTYPE; in function vol { if [[ -z "$1" ]] { for x in $(mixerctl -a | grep 'outputs\.master'); do - echo $x + echo -E - $x done return } diff --git a/etc/zsh/functions/Prompts/prompt_arrows_setup b/etc/zsh/functions/Prompts/prompt_arrows_setup index 8c280f4..9c59b8f 100644 --- a/etc/zsh/functions/Prompts/prompt_arrows_setup +++ b/etc/zsh/functions/Prompts/prompt_arrows_setup @@ -68,7 +68,7 @@ function prompt_arrows_setup() { PROMPT="%F{$c}>>> $hist" ;; *) - echo "Unknown prompt mode $m" + echo -E "Unknown prompt mode $m" return ;; } -- 2.47.0