🦊 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"
|
bm_limit_recent="$BEMOJI_LIMIT_RECENT"
|
||||||
|
|
||||||
declare -A default_pickers=(
|
declare -A default_pickers=(
|
||||||
["bemenu"]="bemenu -p 🔍 -i -l 20"
|
["bemenu"]="bemenu -p 🔍 -i -l 20"
|
||||||
["wofi"]="wofi -p 🔍 -i --show dmenu"
|
["wofi"]="wofi -p 🔍 -i --show dmenu"
|
||||||
["rofi"]="rofi -p 🔍 -i -dmenu --kb-custom-1 "Alt+1" --kb-custom-2 "Alt+2""
|
["rofi"]="rofi -p 🔍 -i -dmenu --kb-custom-1 "Alt+1" --kb-custom-2 "Alt+2""
|
||||||
["dmenu"]="dmenu -p 🔍 -i -l 20"
|
["dmenu"]="dmenu -p 🔍 -i -l 20"
|
||||||
["wmenu"]="wmenu -p 🔍 -i -l 20"
|
["wmenu"]="wmenu -p 🔍 -i -l 20"
|
||||||
["ilia"]="ilia -n -p textlist -l 'Emoji' -i desktop-magnifier"
|
["ilia"]="ilia -n -p textlist -l 'Emoji' -i desktop-magnifier"
|
||||||
["fuzzel"]="fuzzel -d -p '🔍 '"
|
["fuzzel"]="fuzzel -d -p '🔍 '"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Report usage
|
# Report usage
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $(basename "$0") [-t | -c | -e] [-f <filepath> ] [-p] [-P] [-D <choices>]" 1>&2
|
echo "Usage: $(basename "$0") [-t | -c | -e] [-f <filepath> ] [-p] [-P] [-D <choices>]" 1>&2
|
||||||
echo
|
echo
|
||||||
echo "A simple emoji picker. Runs on bemenu/wofi/rofi/dmenu by default."
|
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 "Invoked without arguments sends the picked emoji to the clipboard."
|
||||||
echo
|
echo
|
||||||
echo " Command options (can be combined):"
|
echo " Command options (can be combined):"
|
||||||
echo " -t, --type Simulate typing the emoji choice with the keyboard."
|
echo " -t, --type Simulate typing the emoji choice with the keyboard."
|
||||||
echo " -c, --clip Send emoji choice to the clipboard. (default)"
|
echo " -c, --clip Send emoji choice to the clipboard. (default)"
|
||||||
echo " -e, --echo Only echo out the picked emoji."
|
echo " -e, --echo Only echo out the picked emoji."
|
||||||
echo ""
|
echo ""
|
||||||
echo " Other options:"
|
echo " Other options:"
|
||||||
echo " -n, --noline Do not print a newline after the picked emoji."
|
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, --private Do not save picked emoji to recent history."
|
||||||
echo " -P, --hist-limit <number> Limit number of recent emoji to display."
|
echo " -P, --hist-limit <number> Limit number of recent emoji to display."
|
||||||
echo " -D, --download <choice> Choose from default lists to download."
|
echo " -D, --download <choice> Choose from default lists to download."
|
||||||
echo " Valid choices: all|none|emoji|math|nerd (multiple choices possible)."
|
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 " -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 " -v, --version Display current program version and directory configuration."
|
||||||
echo " -h, --help Show this help."
|
echo " -h, --help Show this help."
|
||||||
echo
|
echo
|
||||||
exit "$1"
|
exit "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
version() {
|
version() {
|
||||||
|
|
@ -61,70 +61,70 @@ version() {
|
||||||
}
|
}
|
||||||
|
|
||||||
msg() {
|
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
|
printf "%s\n" "$1" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_cli() {
|
parse_cli() {
|
||||||
while getopts cD:ef:hnpP:tv-: arg "$@"; do
|
while getopts cD:ef:hnpP:tv-: arg "$@"; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
c) bm_cmds+=(_clipper) ;;
|
c) bm_cmds+=(_clipper) ;;
|
||||||
D) _opt_set_download_list "${OPTARG}" ;;
|
D) _opt_set_download_list "${OPTARG}" ;;
|
||||||
e) bm_cmds+=(cat) ;;
|
e) bm_cmds+=(cat) ;;
|
||||||
f) _opt_set_custom_list "${OPTARG}" ;;
|
f) _opt_set_custom_list "${OPTARG}" ;;
|
||||||
h) usage 0 ;;
|
h) usage 0 ;;
|
||||||
n) bm_echo_newline=false ;;
|
n) bm_echo_newline=false ;;
|
||||||
p) bm_private_mode=true ;;
|
p) bm_private_mode=true ;;
|
||||||
P) _opt_set_hist_limit "${OPTARG}" ;;
|
P) _opt_set_hist_limit "${OPTARG}" ;;
|
||||||
t) bm_cmds+=(_typer) ;;
|
t) bm_cmds+=(_typer) ;;
|
||||||
v) version ;;
|
v) version ;;
|
||||||
-)
|
-)
|
||||||
LONG_OPTARG="${OPTARG#*=}"
|
LONG_OPTARG="${OPTARG#*=}"
|
||||||
case "$OPTARG" in
|
case "$OPTARG" in
|
||||||
clip) bm_cmds+=(_clipper) ;;
|
clip) bm_cmds+=(_clipper) ;;
|
||||||
download=?*) _opt_set_download_list "${LONG_OPTARG}" ;;
|
download=?*) _opt_set_download_list "${LONG_OPTARG}" ;;
|
||||||
download*)
|
download*)
|
||||||
_opt_set_download_list "${*:$OPTIND:1}"
|
_opt_set_download_list "${*:$OPTIND:1}"
|
||||||
OPTIND=$((OPTIND + 1))
|
OPTIND=$((OPTIND + 1))
|
||||||
;;
|
;;
|
||||||
echo) bm_cmds+=(cat) ;;
|
echo) bm_cmds+=(cat) ;;
|
||||||
file=?*) _opt_set_custom_list "${LONG_OPTARG}" ;;
|
file=?*) _opt_set_custom_list "${LONG_OPTARG}" ;;
|
||||||
file*)
|
file*)
|
||||||
_opt_set_custom_list "${*:$OPTIND:1}"
|
_opt_set_custom_list "${*:$OPTIND:1}"
|
||||||
OPTIND=$((OPTIND + 1))
|
OPTIND=$((OPTIND + 1))
|
||||||
;;
|
;;
|
||||||
help) usage 0 ;;
|
help) usage 0 ;;
|
||||||
noline) bm_echo_newline=false ;;
|
noline) bm_echo_newline=false ;;
|
||||||
private) bm_private_mode=true ;;
|
private) bm_private_mode=true ;;
|
||||||
hist-limit=?*) _opt_set_hist_limit "${LONG_OPTARG}" ;;
|
hist-limit=?*) _opt_set_hist_limit "${LONG_OPTARG}" ;;
|
||||||
hist-limit*)
|
hist-limit*)
|
||||||
_opt_set_hist_limit "${*:$OPTIND:1}"
|
_opt_set_hist_limit "${*:$OPTIND:1}"
|
||||||
OPTIND=$((OPTIND + 1))
|
OPTIND=$((OPTIND + 1))
|
||||||
;;
|
;;
|
||||||
type) bm_cmds+=(_typer) ;;
|
type) bm_cmds+=(_typer) ;;
|
||||||
version) version ;;
|
version) version ;;
|
||||||
'') break ;;
|
'') break ;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown option: ${OPTARG}" 1>&2
|
echo "Unknown option: ${OPTARG}" 1>&2
|
||||||
usage 1
|
usage 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
\?) exit 2 ;;
|
\?) exit 2 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
OPTIND=1
|
OPTIND=1
|
||||||
}
|
}
|
||||||
|
|
||||||
_opt_set_custom_list() {
|
_opt_set_custom_list() {
|
||||||
BEMOJI_CUSTOM_LIST="$1"
|
BEMOJI_CUSTOM_LIST="$1"
|
||||||
}
|
}
|
||||||
_opt_set_download_list() {
|
_opt_set_download_list() {
|
||||||
BEMOJI_DOWNLOAD_LIST="$1"
|
BEMOJI_DOWNLOAD_LIST="$1"
|
||||||
}
|
}
|
||||||
_opt_set_hist_limit() {
|
_opt_set_hist_limit() {
|
||||||
bm_limit_recent="$1"
|
bm_limit_recent="$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_db() {
|
prepare_db() {
|
||||||
|
|
@ -175,7 +175,7 @@ dl_nerd_symbols() {
|
||||||
local nerd all
|
local nerd all
|
||||||
nerd=$(curl -sSL "https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/css/nerd-fonts-generated.css")
|
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/')
|
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."
|
msg "Downloaded nerdfont symbols set."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -265,18 +265,18 @@ _typer() {
|
||||||
_picker() {
|
_picker() {
|
||||||
if [ -n "$BEMOJI_PICKER_CMD" ]; then
|
if [ -n "$BEMOJI_PICKER_CMD" ]; then
|
||||||
eval "${BEMOJI_PICKER_CMD[*]}"
|
eval "${BEMOJI_PICKER_CMD[*]}"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for tool in "${!default_pickers[@]}"; do
|
for tool in "${!default_pickers[@]}"; do
|
||||||
if command -v "$tool" >/dev/null 2>&1; then
|
if command -v "$tool" >/dev/null 2>&1; then
|
||||||
eval "${default_pickers[$tool]}"
|
eval "${default_pickers[$tool]}"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
msg "No suitable picker tool found."
|
msg "No suitable picker tool found."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_cli "$@"
|
parse_cli "$@"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue