From 155114aaec59df2c45e21f20889daa6ed6afc943 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Feb 2025 16:25:02 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20newline=20option=20only=20?= =?UTF-8?q?applied=20to=20main=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When sending an emoji to clipboard or typing it with the and shortcuts (currently only in rofi) the set newline option would not be applied. This fixes it and unifies the way emoji are printed using printf. Fixes #41. --- bemoji | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bemoji b/bemoji index 1f61ae9..af5560f 100755 --- a/bemoji +++ b/bemoji @@ -287,6 +287,14 @@ exit_value="$?" [ "$bm_private_mode" = true ] || add_to_recent "$result" result=$(echo "$result" | grep -o '^\S\+' | tr -d '\n') +printout() { # $1=emoji + if [ "$bm_echo_newline" = true ]; then + printf "%s\n" "$*" + else + printf "%s" "$*" + fi +} + case "$exit_value" in 1) exit 1 @@ -295,21 +303,20 @@ case "$exit_value" in if [ ${#bm_cmds[@]} -eq 0 ]; then if [ -n "$bm_default_cmd" ]; then # shellcheck disable=SC2068 - echo "$result" | ${bm_default_cmd[@]} + printout "$result" | ${bm_default_cmd[@]} exit fi bm_cmds+=(_clipper) fi for cmd in "${bm_cmds[@]}"; do - [ "$bm_echo_newline" = true ] && echo_opts= || echo_opts=-n - echo $echo_opts "$result" | "$cmd" + printout "$result" | "$cmd" done ;; 10) - echo "$result" | _clipper + printout "$result" | _clipper ;; 11) - echo "$result" | _typer + printout "$result" | _typer ;; esac exit