Advertisement
metalx1000

Get list of Emoji Icons for Linux Shell

Oct 29th, 2018
1,120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.15 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################################
  3. #Copyright (C) 2019  Kris Occhipinti
  4. #https://filmsbykris.com
  5.  
  6. #This program is free software: you can redistribute it and/or modify
  7. #it under the terms of the GNU General Public License as published by
  8. #the Free Software Foundation, either version 3 of the License, o
  9. #(at your option) any later version.
  10.  
  11. #This program is distributed in the hope that it will be useful,
  12. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. #GNU General Public License for more details.
  15.  
  16. #You should have received a copy of the GNU General Public License
  17. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18. ######################################################################
  19.  
  20. output="$HOME/.files/emojis.lst"
  21.  
  22. function main(){
  23.   if [ "$1" = "update" ];then
  24.     getlist
  25.   elif [ "$1" = "menu" ];then
  26.     menu
  27.   else
  28.     xfce4-terminal -e 'bash -c "/usr/local/bin/emojis menu"'
  29.   fi
  30. }
  31.  
  32. function menu(){
  33.  
  34.   # Give fzf list of all unicode characters to copy.
  35.   # Shows the selected character in dunst if running.
  36.  
  37.   fzf="$HOME/.fzf/bin/fzf"
  38.   #e="$(grep -v "#" "$output" | dmenu -i -l 20 -fn Monospace-18 | awk '{print $1}' | tr -d '\n'|fzf)"
  39.   #e="$(grep -v "#" "$output" |awk '{for (i=2; i<NF; i++) printf $i " "; print $NF}'  |dmenu -i -l 20 -fn Monospace-18)"
  40.   e="$(grep -v "#" "$output" |$fzf|awk '{print $1}')"
  41.   #e="$(grep " $e\$" "$output" | awk '{print $1}' | tr -d '\n')"
  42.   echo "$e" | xclip -selection clipboard
  43.   echo "$e" | xclip
  44.  
  45.   pgrep -x dunst >/dev/null && notify-send "$e copied to clipboard."
  46. }
  47.  
  48. function getlist(){
  49.   mkdir -p "$HOME/.files"
  50.   wget -qO- "https://en.wikipedia.org/wiki/Emoji"|\
  51.     tr "\n" " "|\
  52.     sed 's/<td/\n/g'|\
  53.     grep "U+"|\
  54.     grep "^ title"|while read l
  55.     do
  56.       t="$(echo "$l"|cut -d\: -f2|cut -d\" -f1)"
  57.       e="$(echo "$l"|sed 's/title="/|/g'|cut -d\| -f3|cut -d\" -f1)"
  58.       if [ "$e" != " " ]
  59.       then
  60.         echo "$e$t"
  61.       fi
  62.     done|tee "$output"
  63.  
  64.     echo "emoji list has been saved to $output"
  65.   }
  66.  
  67. main $*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement