Compare commits

...

2 commits

Author SHA1 Message Date
b9c4ea7c77
🦊 Reformat code with shfmt
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-02-06 16:27:26 +01:00
155114aaec
🐛 Fix newline option only applied to main command
When sending an emoji to clipboard or typing it with the <alt+1> and
<alt+2> 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.
2025-02-06 16:25:02 +01:00

21
bemoji
View file

@ -61,7 +61,7 @@ version() {
}
msg() {
# Outputs a message to stderr, to be used for info, warning and error messages.
# Outputs a message to stderr, to be used for info, warning and error messages.
printf "%s\n" "$1" >&2
}
@ -175,7 +175,7 @@ dl_nerd_symbols() {
local nerd all
nerd=$(curl -sSL "https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/css/nerd-fonts-generated.css")
all+=$(printf "%s" "$nerd" | sed -ne '/\.nf-/p' -e '/\s*[^_]content:/p' | sed -e 'N;s/^\.nf-\(.*\):before.* content: \"\\\(.*\)\";/\\U\2 \1/')
echo -e "$all" > "$bm_db_location/nerdfont.txt"
echo -e "$all" >"$bm_db_location/nerdfont.txt"
msg "Downloaded nerdfont symbols set."
}
@ -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