✨ Add ability to download nerdfont symbols (#10)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Same as the other symbol download options, this one takes a list of all nerdfont icons and wrangles them into shape to be usable with the emoji picker. Can be used by invoking `bemoji -D nerd` or `bemoji -D all`. Fixes #10.
This commit is contained in:
parent
54b72e583b
commit
e720343ffc
4 changed files with 30 additions and 10 deletions
|
@ -10,9 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Pass through return code 1 from selection tool
|
- Pass through return code 1 from selection tool
|
||||||
- (!) Number of displayed recent emoji can be set with `-P` option. This replaces previous `-P`
|
- (!) Number of displayed recent emoji can be set with `-P` option:
|
||||||
history flag toggle. Use number to set amount of recent entries to display, `-P3`. To
|
This replaces previous `-P` history flag toggle. Use number to set amount of recent
|
||||||
completely hide history use `-P0`
|
entries to display, `-P3`. To completely hide history use `-P0`.
|
||||||
|
- Add nerdfont emoji set download with `-D nerd`
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
12
README.md
12
README.md
|
@ -184,24 +184,24 @@ The path can also be a weblink which bemoji will download and use:
|
||||||
bemoji -f "https://raw.githubusercontent.com/jchook/emoji-menu/master/data/emojis.txt"
|
bemoji -f "https://raw.githubusercontent.com/jchook/emoji-menu/master/data/emojis.txt"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Download additional emoji set
|
### Download additional emoji sets
|
||||||
|
|
||||||
bemoji automatically downloads an emoji list for you to use on first invocation.
|
bemoji automatically downloads an emoji list for you to use on first invocation.
|
||||||
By default, it only downloads emoji, though you can have it download math symbols as well.
|
By default, it only downloads emoji, though you can have it download math symbols and nerdfont icons as well.
|
||||||
To download additional sets, execute bemoji like the following:
|
To download additional sets, execute bemoji like the following:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bemoji -D all
|
bemoji -D all
|
||||||
```
|
```
|
||||||
|
|
||||||
This will download *all* default sets bemoji knows - which is currently the default emoji list and a long list of math symbols.
|
This will download *all* default sets bemoji knows - which is currently the default emoji list, nerd font icons, and a long list of math symbols.
|
||||||
Other valid options for this setting are `emoji`, `math`, `none`.
|
Other valid options for this setting are `emoji`, `math`, `nerd`, `none`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bemoji -D "math emoji"
|
bemoji -D "math emoji nerd"
|
||||||
```
|
```
|
||||||
|
|
||||||
The above command is equivalent as you can mention multiple sets you want downloaded.
|
The above command is equivalent to `all` as you can mention multiple sets you want downloaded.
|
||||||
|
|
||||||
If set to `none` and no files are in the emoji directory,
|
If set to `none` and no files are in the emoji directory,
|
||||||
bemoji will complain and not show anything.
|
bemoji will complain and not show anything.
|
||||||
|
|
13
bemoji
13
bemoji
|
@ -37,7 +37,7 @@ usage() {
|
||||||
echo " -p Do not save picked emoji to recent history."
|
echo " -p Do not save picked emoji to recent history."
|
||||||
echo " -P <number> Limit number of recent emoji to display."
|
echo " -P <number> Limit number of recent emoji to display."
|
||||||
echo " -D <choice> Choose from default lists to download."
|
echo " -D <choice> Choose from default lists to download."
|
||||||
echo " Valid choices: all|none|emoji|math (multiple choices possible)."
|
echo " Valid choices: all|none|emoji|math|nerd (multiple choices possible)."
|
||||||
echo " -f <filepath> Use a custom emoji database. Can be a url which will be retrieved."
|
echo " -f <filepath> Use a custom emoji database. Can be a url which will be retrieved."
|
||||||
echo " -v Display current program version and directory configuration."
|
echo " -v Display current program version and directory configuration."
|
||||||
echo " -h Show this help."
|
echo " -h Show this help."
|
||||||
|
@ -81,6 +81,7 @@ prepare_db() {
|
||||||
elif echo "$BEMOJI_DOWNLOAD_LIST" | grep -q -e 'all'; then
|
elif echo "$BEMOJI_DOWNLOAD_LIST" | grep -q -e 'all'; then
|
||||||
dl_default_emoji
|
dl_default_emoji
|
||||||
dl_math_symbols
|
dl_math_symbols
|
||||||
|
dl_nerd_symbols
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
if echo "$BEMOJI_DOWNLOAD_LIST" | grep -q -e 'emoji'; then
|
if echo "$BEMOJI_DOWNLOAD_LIST" | grep -q -e 'emoji'; then
|
||||||
|
@ -89,6 +90,9 @@ prepare_db() {
|
||||||
if echo "$BEMOJI_DOWNLOAD_LIST" | grep -q -e 'math'; then
|
if echo "$BEMOJI_DOWNLOAD_LIST" | grep -q -e 'math'; then
|
||||||
dl_math_symbols
|
dl_math_symbols
|
||||||
fi
|
fi
|
||||||
|
if echo "$BEMOJI_DOWNLOAD_LIST" | grep -q -e 'nerd'; then
|
||||||
|
dl_nerd_symbols
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -n "$(find "$bm_db_location" -maxdepth 0 -type d -empty 2>/dev/null)" ]; then
|
if [ -n "$(find "$bm_db_location" -maxdepth 0 -type d -empty 2>/dev/null)" ]; then
|
||||||
|
@ -107,6 +111,13 @@ dl_math_symbols() {
|
||||||
grep -ve '^#' | cut -d';' -f3,7 | sed -e 's/;/ /' >"$bm_db_location/math.txt"
|
grep -ve '^#' | cut -d';' -f3,7 | sed -e 's/;/ /' >"$bm_db_location/math.txt"
|
||||||
printf "Downloaded math symbols set.\n"
|
printf "Downloaded math symbols set.\n"
|
||||||
}
|
}
|
||||||
|
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"
|
||||||
|
printf "Downloaded nerdfont symbols set.\n"
|
||||||
|
}
|
||||||
|
|
||||||
gather_emojis() {
|
gather_emojis() {
|
||||||
if [ -n "$BEMOJI_CUSTOM_LIST" ] && [ -f "$BEMOJI_CUSTOM_LIST" ]; then
|
if [ -n "$BEMOJI_CUSTOM_LIST" ] && [ -f "$BEMOJI_CUSTOM_LIST" ]; then
|
||||||
|
|
|
@ -38,3 +38,11 @@ emoji2 picked up"
|
||||||
assert_equal "$outcome" "Σ GREEK CAPITAL LETTER SIGMA"
|
assert_equal "$outcome" "Σ GREEK CAPITAL LETTER SIGMA"
|
||||||
unstub curl
|
unstub curl
|
||||||
}
|
}
|
||||||
|
@test "Runs nerdfont download on -D nerd option" {
|
||||||
|
stub curl \
|
||||||
|
"printf 'meangingless\nafiller lines\n.nf-md-pipe_wrench:before { \n content: \"\\\f1354\";\n }'"
|
||||||
|
run bemoji -D nerd 3>&-
|
||||||
|
outcome=$(cat "$BEMOJI_DB_LOCATION/nerdfont.txt")
|
||||||
|
assert_equal "$outcome" " md-pipe_wrench"
|
||||||
|
unstub curl
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue