🦊 Reformat code with shfmt
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
155114aaec
commit
b9c4ea7c77
1 changed files with 92 additions and 92 deletions
184
bemoji
184
bemoji
|
|
@ -21,38 +21,38 @@ bm_private_mode=${BEMOJI_PRIVATE_MODE:-false}
|
|||
bm_limit_recent="$BEMOJI_LIMIT_RECENT"
|
||||
|
||||
declare -A default_pickers=(
|
||||
["bemenu"]="bemenu -p 🔍 -i -l 20"
|
||||
["wofi"]="wofi -p 🔍 -i --show dmenu"
|
||||
["rofi"]="rofi -p 🔍 -i -dmenu --kb-custom-1 "Alt+1" --kb-custom-2 "Alt+2""
|
||||
["dmenu"]="dmenu -p 🔍 -i -l 20"
|
||||
["wmenu"]="wmenu -p 🔍 -i -l 20"
|
||||
["ilia"]="ilia -n -p textlist -l 'Emoji' -i desktop-magnifier"
|
||||
["fuzzel"]="fuzzel -d -p '🔍 '"
|
||||
["bemenu"]="bemenu -p 🔍 -i -l 20"
|
||||
["wofi"]="wofi -p 🔍 -i --show dmenu"
|
||||
["rofi"]="rofi -p 🔍 -i -dmenu --kb-custom-1 "Alt+1" --kb-custom-2 "Alt+2""
|
||||
["dmenu"]="dmenu -p 🔍 -i -l 20"
|
||||
["wmenu"]="wmenu -p 🔍 -i -l 20"
|
||||
["ilia"]="ilia -n -p textlist -l 'Emoji' -i desktop-magnifier"
|
||||
["fuzzel"]="fuzzel -d -p '🔍 '"
|
||||
)
|
||||
|
||||
# Report usage
|
||||
usage() {
|
||||
echo "Usage: $(basename "$0") [-t | -c | -e] [-f <filepath> ] [-p] [-P] [-D <choices>]" 1>&2
|
||||
echo
|
||||
echo "A simple emoji picker. Runs on bemenu/wofi/rofi/dmenu by default."
|
||||
echo "Invoked without arguments sends the picked emoji to the clipboard."
|
||||
echo
|
||||
echo " Command options (can be combined):"
|
||||
echo " -t, --type Simulate typing the emoji choice with the keyboard."
|
||||
echo " -c, --clip Send emoji choice to the clipboard. (default)"
|
||||
echo " -e, --echo Only echo out the picked emoji."
|
||||
echo ""
|
||||
echo " Other options:"
|
||||
echo " -n, --noline Do not print a newline after the picked emoji."
|
||||
echo " -p, --private Do not save picked emoji to recent history."
|
||||
echo " -P, --hist-limit <number> Limit number of recent emoji to display."
|
||||
echo " -D, --download <choice> Choose from default lists to download."
|
||||
echo " Valid choices: all|none|emoji|math|nerd (multiple choices possible)."
|
||||
echo " -f, --file <filepath> Use a custom emoji database. Can be a url which will be retrieved."
|
||||
echo " -v, --version Display current program version and directory configuration."
|
||||
echo " -h, --help Show this help."
|
||||
echo
|
||||
exit "$1"
|
||||
echo "Usage: $(basename "$0") [-t | -c | -e] [-f <filepath> ] [-p] [-P] [-D <choices>]" 1>&2
|
||||
echo
|
||||
echo "A simple emoji picker. Runs on bemenu/wofi/rofi/dmenu by default."
|
||||
echo "Invoked without arguments sends the picked emoji to the clipboard."
|
||||
echo
|
||||
echo " Command options (can be combined):"
|
||||
echo " -t, --type Simulate typing the emoji choice with the keyboard."
|
||||
echo " -c, --clip Send emoji choice to the clipboard. (default)"
|
||||
echo " -e, --echo Only echo out the picked emoji."
|
||||
echo ""
|
||||
echo " Other options:"
|
||||
echo " -n, --noline Do not print a newline after the picked emoji."
|
||||
echo " -p, --private Do not save picked emoji to recent history."
|
||||
echo " -P, --hist-limit <number> Limit number of recent emoji to display."
|
||||
echo " -D, --download <choice> Choose from default lists to download."
|
||||
echo " Valid choices: all|none|emoji|math|nerd (multiple choices possible)."
|
||||
echo " -f, --file <filepath> Use a custom emoji database. Can be a url which will be retrieved."
|
||||
echo " -v, --version Display current program version and directory configuration."
|
||||
echo " -h, --help Show this help."
|
||||
echo
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
version() {
|
||||
|
|
@ -61,70 +61,70 @@ 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
|
||||
}
|
||||
|
||||
parse_cli() {
|
||||
while getopts cD:ef:hnpP:tv-: arg "$@"; do
|
||||
case "$arg" in
|
||||
c) bm_cmds+=(_clipper) ;;
|
||||
D) _opt_set_download_list "${OPTARG}" ;;
|
||||
e) bm_cmds+=(cat) ;;
|
||||
f) _opt_set_custom_list "${OPTARG}" ;;
|
||||
h) usage 0 ;;
|
||||
n) bm_echo_newline=false ;;
|
||||
p) bm_private_mode=true ;;
|
||||
P) _opt_set_hist_limit "${OPTARG}" ;;
|
||||
t) bm_cmds+=(_typer) ;;
|
||||
v) version ;;
|
||||
-)
|
||||
LONG_OPTARG="${OPTARG#*=}"
|
||||
case "$OPTARG" in
|
||||
clip) bm_cmds+=(_clipper) ;;
|
||||
download=?*) _opt_set_download_list "${LONG_OPTARG}" ;;
|
||||
download*)
|
||||
_opt_set_download_list "${*:$OPTIND:1}"
|
||||
OPTIND=$((OPTIND + 1))
|
||||
;;
|
||||
echo) bm_cmds+=(cat) ;;
|
||||
file=?*) _opt_set_custom_list "${LONG_OPTARG}" ;;
|
||||
file*)
|
||||
_opt_set_custom_list "${*:$OPTIND:1}"
|
||||
OPTIND=$((OPTIND + 1))
|
||||
;;
|
||||
help) usage 0 ;;
|
||||
noline) bm_echo_newline=false ;;
|
||||
private) bm_private_mode=true ;;
|
||||
hist-limit=?*) _opt_set_hist_limit "${LONG_OPTARG}" ;;
|
||||
hist-limit*)
|
||||
_opt_set_hist_limit "${*:$OPTIND:1}"
|
||||
OPTIND=$((OPTIND + 1))
|
||||
;;
|
||||
type) bm_cmds+=(_typer) ;;
|
||||
version) version ;;
|
||||
'') break ;;
|
||||
*)
|
||||
echo "Unknown option: ${OPTARG}" 1>&2
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
\?) exit 2 ;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
OPTIND=1
|
||||
while getopts cD:ef:hnpP:tv-: arg "$@"; do
|
||||
case "$arg" in
|
||||
c) bm_cmds+=(_clipper) ;;
|
||||
D) _opt_set_download_list "${OPTARG}" ;;
|
||||
e) bm_cmds+=(cat) ;;
|
||||
f) _opt_set_custom_list "${OPTARG}" ;;
|
||||
h) usage 0 ;;
|
||||
n) bm_echo_newline=false ;;
|
||||
p) bm_private_mode=true ;;
|
||||
P) _opt_set_hist_limit "${OPTARG}" ;;
|
||||
t) bm_cmds+=(_typer) ;;
|
||||
v) version ;;
|
||||
-)
|
||||
LONG_OPTARG="${OPTARG#*=}"
|
||||
case "$OPTARG" in
|
||||
clip) bm_cmds+=(_clipper) ;;
|
||||
download=?*) _opt_set_download_list "${LONG_OPTARG}" ;;
|
||||
download*)
|
||||
_opt_set_download_list "${*:$OPTIND:1}"
|
||||
OPTIND=$((OPTIND + 1))
|
||||
;;
|
||||
echo) bm_cmds+=(cat) ;;
|
||||
file=?*) _opt_set_custom_list "${LONG_OPTARG}" ;;
|
||||
file*)
|
||||
_opt_set_custom_list "${*:$OPTIND:1}"
|
||||
OPTIND=$((OPTIND + 1))
|
||||
;;
|
||||
help) usage 0 ;;
|
||||
noline) bm_echo_newline=false ;;
|
||||
private) bm_private_mode=true ;;
|
||||
hist-limit=?*) _opt_set_hist_limit "${LONG_OPTARG}" ;;
|
||||
hist-limit*)
|
||||
_opt_set_hist_limit "${*:$OPTIND:1}"
|
||||
OPTIND=$((OPTIND + 1))
|
||||
;;
|
||||
type) bm_cmds+=(_typer) ;;
|
||||
version) version ;;
|
||||
'') break ;;
|
||||
*)
|
||||
echo "Unknown option: ${OPTARG}" 1>&2
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
\?) exit 2 ;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
OPTIND=1
|
||||
}
|
||||
|
||||
_opt_set_custom_list() {
|
||||
BEMOJI_CUSTOM_LIST="$1"
|
||||
BEMOJI_CUSTOM_LIST="$1"
|
||||
}
|
||||
_opt_set_download_list() {
|
||||
BEMOJI_DOWNLOAD_LIST="$1"
|
||||
BEMOJI_DOWNLOAD_LIST="$1"
|
||||
}
|
||||
_opt_set_hist_limit() {
|
||||
bm_limit_recent="$1"
|
||||
bm_limit_recent="$1"
|
||||
}
|
||||
|
||||
prepare_db() {
|
||||
|
|
@ -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."
|
||||
}
|
||||
|
||||
|
|
@ -265,18 +265,18 @@ _typer() {
|
|||
_picker() {
|
||||
if [ -n "$BEMOJI_PICKER_CMD" ]; then
|
||||
eval "${BEMOJI_PICKER_CMD[*]}"
|
||||
return
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
for tool in "${!default_pickers[@]}"; do
|
||||
if command -v "$tool" >/dev/null 2>&1; then
|
||||
eval "${default_pickers[$tool]}"
|
||||
return
|
||||
fi
|
||||
done
|
||||
for tool in "${!default_pickers[@]}"; do
|
||||
if command -v "$tool" >/dev/null 2>&1; then
|
||||
eval "${default_pickers[$tool]}"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
msg "No suitable picker tool found."
|
||||
exit 1
|
||||
msg "No suitable picker tool found."
|
||||
exit 1
|
||||
}
|
||||
|
||||
parse_cli "$@"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue