├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── README.md └── src ├── gitmojis.json └── main.rs /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "aho-corasick" 5 | version = "0.6.9" 6 | source = "registry+https://github.com/rust-lang/crates.io-index" 7 | dependencies = [ 8 | "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 9 | ] 10 | 11 | [[package]] 12 | name = "autocfg" 13 | version = "0.1.2" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | 16 | [[package]] 17 | name = "backtrace" 18 | version = "0.3.14" 19 | source = "registry+https://github.com/rust-lang/crates.io-index" 20 | dependencies = [ 21 | "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 22 | "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", 23 | "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 24 | "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", 25 | "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", 26 | "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", 27 | ] 28 | 29 | [[package]] 30 | name = "backtrace-sys" 31 | version = "0.1.28" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | dependencies = [ 34 | "cc 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", 35 | "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", 36 | ] 37 | 38 | [[package]] 39 | name = "cc" 40 | version = "1.0.32" 41 | source = "registry+https://github.com/rust-lang/crates.io-index" 42 | 43 | [[package]] 44 | name = "cfg-if" 45 | version = "0.1.6" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | 48 | [[package]] 49 | name = "failure" 50 | version = "0.1.5" 51 | source = "registry+https://github.com/rust-lang/crates.io-index" 52 | dependencies = [ 53 | "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", 54 | "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 55 | ] 56 | 57 | [[package]] 58 | name = "failure_derive" 59 | version = "0.1.5" 60 | source = "registry+https://github.com/rust-lang/crates.io-index" 61 | dependencies = [ 62 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 63 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 64 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 65 | "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", 66 | ] 67 | 68 | [[package]] 69 | name = "gitmoji-selector" 70 | version = "0.1.0" 71 | dependencies = [ 72 | "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 73 | "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 74 | "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", 75 | "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", 76 | "serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", 77 | ] 78 | 79 | [[package]] 80 | name = "itoa" 81 | version = "0.4.3" 82 | source = "registry+https://github.com/rust-lang/crates.io-index" 83 | 84 | [[package]] 85 | name = "lazy_static" 86 | version = "1.2.0" 87 | source = "registry+https://github.com/rust-lang/crates.io-index" 88 | 89 | [[package]] 90 | name = "libc" 91 | version = "0.2.48" 92 | source = "registry+https://github.com/rust-lang/crates.io-index" 93 | 94 | [[package]] 95 | name = "memchr" 96 | version = "2.1.3" 97 | source = "registry+https://github.com/rust-lang/crates.io-index" 98 | dependencies = [ 99 | "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 100 | "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", 101 | ] 102 | 103 | [[package]] 104 | name = "proc-macro2" 105 | version = "0.4.27" 106 | source = "registry+https://github.com/rust-lang/crates.io-index" 107 | dependencies = [ 108 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 109 | ] 110 | 111 | [[package]] 112 | name = "quote" 113 | version = "0.6.11" 114 | source = "registry+https://github.com/rust-lang/crates.io-index" 115 | dependencies = [ 116 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 117 | ] 118 | 119 | [[package]] 120 | name = "regex" 121 | version = "1.1.0" 122 | source = "registry+https://github.com/rust-lang/crates.io-index" 123 | dependencies = [ 124 | "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", 125 | "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 126 | "regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", 127 | "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", 128 | "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 129 | ] 130 | 131 | [[package]] 132 | name = "regex-syntax" 133 | version = "0.6.5" 134 | source = "registry+https://github.com/rust-lang/crates.io-index" 135 | dependencies = [ 136 | "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 137 | ] 138 | 139 | [[package]] 140 | name = "rustc-demangle" 141 | version = "0.1.13" 142 | source = "registry+https://github.com/rust-lang/crates.io-index" 143 | 144 | [[package]] 145 | name = "ryu" 146 | version = "0.2.7" 147 | source = "registry+https://github.com/rust-lang/crates.io-index" 148 | 149 | [[package]] 150 | name = "serde" 151 | version = "1.0.87" 152 | source = "registry+https://github.com/rust-lang/crates.io-index" 153 | 154 | [[package]] 155 | name = "serde_derive" 156 | version = "1.0.87" 157 | source = "registry+https://github.com/rust-lang/crates.io-index" 158 | dependencies = [ 159 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 160 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 161 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 162 | ] 163 | 164 | [[package]] 165 | name = "serde_json" 166 | version = "1.0.38" 167 | source = "registry+https://github.com/rust-lang/crates.io-index" 168 | dependencies = [ 169 | "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 170 | "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", 171 | "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", 172 | ] 173 | 174 | [[package]] 175 | name = "syn" 176 | version = "0.15.26" 177 | source = "registry+https://github.com/rust-lang/crates.io-index" 178 | dependencies = [ 179 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 180 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 181 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 182 | ] 183 | 184 | [[package]] 185 | name = "synstructure" 186 | version = "0.10.1" 187 | source = "registry+https://github.com/rust-lang/crates.io-index" 188 | dependencies = [ 189 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 190 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 191 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 192 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 193 | ] 194 | 195 | [[package]] 196 | name = "thread_local" 197 | version = "0.3.6" 198 | source = "registry+https://github.com/rust-lang/crates.io-index" 199 | dependencies = [ 200 | "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 201 | ] 202 | 203 | [[package]] 204 | name = "ucd-util" 205 | version = "0.1.3" 206 | source = "registry+https://github.com/rust-lang/crates.io-index" 207 | 208 | [[package]] 209 | name = "unicode-xid" 210 | version = "0.1.0" 211 | source = "registry+https://github.com/rust-lang/crates.io-index" 212 | 213 | [[package]] 214 | name = "utf8-ranges" 215 | version = "1.0.2" 216 | source = "registry+https://github.com/rust-lang/crates.io-index" 217 | 218 | [[package]] 219 | name = "winapi" 220 | version = "0.3.6" 221 | source = "registry+https://github.com/rust-lang/crates.io-index" 222 | dependencies = [ 223 | "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 224 | "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 225 | ] 226 | 227 | [[package]] 228 | name = "winapi-i686-pc-windows-gnu" 229 | version = "0.4.0" 230 | source = "registry+https://github.com/rust-lang/crates.io-index" 231 | 232 | [[package]] 233 | name = "winapi-x86_64-pc-windows-gnu" 234 | version = "0.4.0" 235 | source = "registry+https://github.com/rust-lang/crates.io-index" 236 | 237 | [metadata] 238 | "checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e" 239 | "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" 240 | "checksum backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5a90e2b463010cd0e0ce9a11d4a9d5d58d9f41d4a6ba3dcaf9e68b466e88b4" 241 | "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" 242 | "checksum cc 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "ad0daef304fa0b4238f5f7ed7178774b43b06f6a9b6509f6642bef4ff1f7b9b2" 243 | "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" 244 | "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" 245 | "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" 246 | "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" 247 | "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" 248 | "checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047" 249 | "checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8" 250 | "checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" 251 | "checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" 252 | "checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" 253 | "checksum regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8c2f35eedad5295fdf00a63d7d4b238135723f92b434ec06774dad15c7ab0861" 254 | "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" 255 | "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" 256 | "checksum serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)" = "2e20fde37801e83c891a2dc4ebd3b81f0da4d1fb67a9e0a2a3b921e2536a58ee" 257 | "checksum serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)" = "633e97856567e518b59ffb2ad7c7a4fd4c5d91d9c7f32dd38a27b2bf7e8114ea" 258 | "checksum serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "27dce848e7467aa0e2fcaf0a413641499c0b745452aaca1194d24dedde9e13c9" 259 | "checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" 260 | "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" 261 | "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" 262 | "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" 263 | "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" 264 | "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" 265 | "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" 266 | "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 267 | "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 268 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gitmoji-selector" 3 | version = "0.1.0" 4 | authors = ["Tom Houlé "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | serde_json = "1.0.38" 9 | serde = "1.0.87" 10 | serde_derive = "1.0.87" 11 | regex = "1.1.0" 12 | failure = "0.1.5" 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gitmoji-selector 2 | 3 | Gitmojis taken from: https://raw.githubusercontent.com/carloscuesta/gitmoji/master/src/data/gitmojis.json 4 | 5 | # Installation 6 | 7 | With the rust toolchain installed 8 | 9 | - if you have the source navigate to the source directory (same as this 10 | README), then run the following command: 11 | 12 | ```sh 13 | cargo install --path=. --force 14 | ``` 15 | 16 | - directly from git: cargo install --git=https://github.com/tomhoule/gitmoji-selector --force 17 | 18 | # External dependencies 19 | 20 | fzf with fzf-tmux. Also assumes you run this in tmux. 21 | 22 | # Use in vim 23 | 24 | Add this line to your `.vimrc` or `init.vim`. With `j` in normal mode, 25 | you can select a gitmoji and insert it at the current cursor position. 26 | 27 | ```vimscript 28 | nmap j "=system('gitmoji-selector')P 29 | ``` 30 | 31 | You can of course change what keys it is bound to. 32 | 33 | # Use in Emacs 34 | 35 | You can add this function to your Emacs configuration: 36 | 37 | ```emacs-lisp 38 | (defun gitmoji-selector () 39 | (interactive) 40 | (insert (shell-command-to-string "gitmoji-selector"))) 41 | ``` 42 | 43 | Bind it to a keybinding, for example if using evil-leader: 44 | 45 | ```emacs-lisp 46 | (evil-leader/set-key 47 | "e" 'gitmoji-selector) 48 | ``` 49 | -------------------------------------------------------------------------------- /src/gitmojis.json: -------------------------------------------------------------------------------- 1 | { 2 | "gitmojis": [ 3 | { 4 | "emoji": "🎨", 5 | "entity": "🎨", 6 | "code": ":art:", 7 | "description": "Improving structure / format of the code.", 8 | "name": "art" 9 | }, 10 | { 11 | "emoji": "⚡️", 12 | "entity": "⚡", 13 | "code": ":zap:", 14 | "description": "Improving performance.", 15 | "name": "zap" 16 | }, 17 | { 18 | "emoji": "🔥", 19 | "entity": "🔥", 20 | "code": ":fire:", 21 | "description": "Removing code or files.", 22 | "name": "fire" 23 | }, 24 | { 25 | "emoji": "🐛", 26 | "entity": "🐛", 27 | "code": ":bug:", 28 | "description": "Fixing a bug.", 29 | "name": "bug" 30 | }, 31 | { 32 | "emoji": "🚑", 33 | "entity": "🚑", 34 | "code": ":ambulance:", 35 | "description": "Critical hotfix.", 36 | "name": "ambulance" 37 | }, 38 | { 39 | "emoji": "✨", 40 | "entity": "✨", 41 | "code": ":sparkles:", 42 | "description": "Introducing new features.", 43 | "name": "sparkles" 44 | }, 45 | { 46 | "emoji": "📝", 47 | "entity": "📝", 48 | "code": ":memo:", 49 | "description": "Writing docs.", 50 | "name": "memo" 51 | }, 52 | { 53 | "emoji": "🚀", 54 | "entity": "🚀", 55 | "code": ":rocket:", 56 | "description": "Deploying stuff.", 57 | "name": "rocket" 58 | }, 59 | { 60 | "emoji": "💄", 61 | "entity": "&#ff99cc;", 62 | "code": ":lipstick:", 63 | "description": "Updating the UI and style files.", 64 | "name": "lipstick" 65 | }, 66 | { 67 | "emoji": "🎉", 68 | "entity": "🎉", 69 | "code": ":tada:", 70 | "description": "Initial commit.", 71 | "name": "tada" 72 | }, 73 | { 74 | "emoji": "✅", 75 | "entity": "✅", 76 | "code": ":white_check_mark:", 77 | "description": "Adding tests.", 78 | "name": "white-check-mark" 79 | }, 80 | { 81 | "emoji": "🔒", 82 | "entity": "🔒", 83 | "code": ":lock:", 84 | "description": "Fixing security issues.", 85 | "name": "lock" 86 | }, 87 | { 88 | "emoji": "🍎", 89 | "entity": "🍎", 90 | "code": ":apple:", 91 | "description": "Fixing something on macOS.", 92 | "name": "apple" 93 | }, 94 | { 95 | "emoji": "🐧", 96 | "entity": "🐧", 97 | "code": ":penguin:", 98 | "description": "Fixing something on Linux.", 99 | "name": "penguin" 100 | }, 101 | { 102 | "emoji": "🏁", 103 | "entity": "🏁", 104 | "code": ":checkered_flag:", 105 | "description": "Fixing something on Windows.", 106 | "name": "checkered-flag" 107 | }, 108 | { 109 | "emoji": "🤖", 110 | "entity": "🤖", 111 | "code": ":robot:", 112 | "description": "Fixing something on Android.", 113 | "name": "robot" 114 | }, 115 | { 116 | "emoji": "🍏", 117 | "entity": "🍏", 118 | "code": ":green_apple:", 119 | "description": "Fixing something on iOS.", 120 | "name": "green-apple" 121 | }, 122 | { 123 | "emoji": "🔖", 124 | "entity": "🔖", 125 | "code": ":bookmark:", 126 | "description": "Releasing / Version tags.", 127 | "name": "bookmark" 128 | }, 129 | { 130 | "emoji": "🚨", 131 | "entity": "🚨", 132 | "code": ":rotating_light:", 133 | "description": "Removing linter warnings.", 134 | "name": "rotating-light" 135 | }, 136 | { 137 | "emoji": "🚧", 138 | "entity": "🚧", 139 | "code": ":construction:", 140 | "description": "Work in progress.", 141 | "name": "construction" 142 | }, 143 | { 144 | "emoji": "💚", 145 | "entity": "💚", 146 | "code": ":green_heart:", 147 | "description": "Fixing CI Build.", 148 | "name": "green-heart" 149 | }, 150 | { 151 | "emoji": "⬇️", 152 | "entity": "⬇️", 153 | "code": ":arrow_down:", 154 | "description": "Downgrading dependencies.", 155 | "name": "arrow-down" 156 | }, 157 | { 158 | "emoji": "⬆️", 159 | "entity": "⬆️", 160 | "code": ":arrow_up:", 161 | "description": "Upgrading dependencies.", 162 | "name": "arrow-up" 163 | }, 164 | { 165 | "emoji": "📌", 166 | "entity": "📌", 167 | "code": ":pushpin:", 168 | "description": "Pinning dependencies to specific versions.", 169 | "name": "pushpin" 170 | }, 171 | { 172 | "emoji": "👷", 173 | "entity": "👷", 174 | "code": ":construction_worker:", 175 | "description": "Adding CI build system.", 176 | "name": "construction-worker" 177 | }, 178 | { 179 | "emoji": "📈", 180 | "code": ":chart_with_upwards_trend:", 181 | "description": "Adding analytics or tracking code.", 182 | "name": "chart-with-upwards-trend" 183 | }, 184 | { 185 | "emoji": "♻️", 186 | "entity": "♲", 187 | "code": ":recycle:", 188 | "description": "Refactoring code.", 189 | "name": "recycle" 190 | }, 191 | { 192 | "emoji": "🐳", 193 | "entity": "🐳", 194 | "code": ":whale:", 195 | "description": "Work about Docker.", 196 | "name": "whale" 197 | }, 198 | { 199 | "emoji": "➕", 200 | "entity": "➕", 201 | "code": ":heavy_plus_sign:", 202 | "description": "Adding a dependency.", 203 | "name": "heavy-plus-sign" 204 | }, 205 | { 206 | "emoji": "➖", 207 | "entity": "➖", 208 | "code": ":heavy_minus_sign:", 209 | "description": "Removing a dependency.", 210 | "name": "heavy-minus-sign" 211 | }, 212 | { 213 | "emoji": "🔧", 214 | "entity": "🔧", 215 | "code": ":wrench:", 216 | "description": "Changing configuration files.", 217 | "name": "wrench" 218 | }, 219 | { 220 | "emoji": "🌐", 221 | "entity": "🌐", 222 | "code": ":globe_with_meridians:", 223 | "description": "Internationalization and localization.", 224 | "name": "globe-with-meridians" 225 | }, 226 | { 227 | "emoji": "✏️", 228 | "entity": "", 229 | "code": ":pencil2:", 230 | "description": "Fixing typos.", 231 | "name": "pencil" 232 | }, 233 | { 234 | "emoji": "💩", 235 | "entity": "", 236 | "code": ":hankey:", 237 | "description": "Writing bad code that needs to be improved.", 238 | "name": "hankey" 239 | }, 240 | { 241 | "emoji": "⏪", 242 | "entity": "⏪", 243 | "code": ":rewind:", 244 | "description": "Reverting changes.", 245 | "name": "rewind" 246 | }, 247 | { 248 | "emoji": "🔀", 249 | "entity": "🔀", 250 | "code": ":twisted_rightwards_arrows:", 251 | "description": "Merging branches.", 252 | "name": "twisted-rightwards-arrows" 253 | }, 254 | { 255 | "emoji": "📦", 256 | "entity": "F4E6;", 257 | "code": ":package:", 258 | "description": "Updating compiled files or packages.", 259 | "name": "package" 260 | }, 261 | { 262 | "emoji": "👽", 263 | "entity": "F47D;", 264 | "code": ":alien:", 265 | "description": "Updating code due to external API changes.", 266 | "name": "alien" 267 | }, 268 | { 269 | "emoji": "🚚", 270 | "entity": "F69A;", 271 | "code": ":truck:", 272 | "description": "Moving or renaming files.", 273 | "name": "truck" 274 | }, 275 | { 276 | "emoji": "📄", 277 | "entity": "F4C4;", 278 | "code": ":page_facing_up:", 279 | "description": "Adding or updating license.", 280 | "name": "page-facing-up" 281 | }, 282 | { 283 | "emoji": "💥", 284 | "entity": "💥", 285 | "code": ":boom:", 286 | "description": "Introducing breaking changes.", 287 | "name": "boom" 288 | }, 289 | { 290 | "emoji": "🍱", 291 | "entity": "F371", 292 | "code": ":bento:", 293 | "description": "Adding or updating assets.", 294 | "name": "bento" 295 | }, 296 | { 297 | "emoji": "👌", 298 | "entity": "👌", 299 | "code": ":ok_hand:", 300 | "description": "Updating code due to code review changes.", 301 | "name": "ok-hand" 302 | }, 303 | { 304 | "emoji": "♿️", 305 | "entity": "♿", 306 | "code": ":wheelchair:", 307 | "description": "Improving accessibility.", 308 | "name": "wheelchair" 309 | }, 310 | { 311 | "emoji": "💡", 312 | "entity": "💡", 313 | "code": ":bulb:", 314 | "description": "Documenting source code.", 315 | "name": "bulb" 316 | }, 317 | { 318 | "emoji": "🍻", 319 | "entity": "🍻", 320 | "code": ":beers:", 321 | "description": "Writing code drunkenly.", 322 | "name": "beers" 323 | }, 324 | { 325 | "emoji": "💬", 326 | "entity": "💬", 327 | "code": ":speech_balloon:", 328 | "description": "Updating text and literals.", 329 | "name": "speech-balloon" 330 | }, 331 | { 332 | "emoji": "🗃", 333 | "entity": "🗃", 334 | "code": ":card_file_box:", 335 | "description": "Performing database related changes.", 336 | "name": "card-file-box" 337 | }, 338 | { 339 | "emoji": "🔊", 340 | "entity": "🔊", 341 | "code": ":loud_sound:", 342 | "description": "Adding logs.", 343 | "name": "loud-sound" 344 | }, 345 | { 346 | "emoji": "🔇", 347 | "entity": "🔇", 348 | "code": ":mute:", 349 | "description": "Removing logs.", 350 | "name": "mute" 351 | }, 352 | { 353 | "emoji": "👥", 354 | "entity": "👥", 355 | "code": ":busts_in_silhouette:", 356 | "description": "Adding contributor(s).", 357 | "name": "busts-in-silhouette" 358 | }, 359 | { 360 | "emoji": "🚸", 361 | "entity": "🚸", 362 | "code": ":children_crossing:", 363 | "description": "Improving user experience / usability.", 364 | "name": "children-crossing" 365 | }, 366 | { 367 | "emoji": "🏗", 368 | "entity": "f3d7;", 369 | "code": ":building_construction:", 370 | "description": "Making architectural changes.", 371 | "name": "building-construction" 372 | }, 373 | { 374 | "emoji": "📱", 375 | "entity": "📱", 376 | "code": ":iphone:", 377 | "description": "Working on responsive design.", 378 | "name": "iphone" 379 | }, 380 | { 381 | "emoji": "🤡", 382 | "entity": "🤡", 383 | "code": ":clown_face:", 384 | "description": "Mocking things.", 385 | "name": "clown-face" 386 | }, 387 | { 388 | "emoji": "🥚", 389 | "entity": "🥚", 390 | "code": ":egg:", 391 | "description": "Adding an easter egg.", 392 | "name": "egg" 393 | }, 394 | { 395 | "emoji": "🙈", 396 | "entity": "bdfe7;", 397 | "code": ":see_no_evil:", 398 | "description": "Adding or updating a .gitignore file", 399 | "name": "see-no-evil" 400 | }, 401 | { 402 | "emoji": "📸", 403 | "entity": "📸", 404 | "code": ":camera_flash:", 405 | "description": "Adding or updating snapshots", 406 | "name": "camera-flash" 407 | }, 408 | { 409 | "emoji": "⚗", 410 | "entity": "📸", 411 | "code": ":alembic:", 412 | "description": "Experimenting new things", 413 | "name": "alembic" 414 | }, 415 | { 416 | "emoji": "🔍", 417 | "entity": "🔍", 418 | "code": ":mag:", 419 | "description": "Improving SEO", 420 | "name": "mag" 421 | }, 422 | { 423 | "emoji": "☸️", 424 | "entity": "☸", 425 | "code": ":wheel_of_dharma:", 426 | "description": "Work about Kubernetes", 427 | "name": "wheel-of-dharma" 428 | }, 429 | { 430 | "emoji": "🏷️", 431 | "entity": "🏷", 432 | "code": ":label:", 433 | "description": "Adding or updating types (Flow, TypeScript)", 434 | "name": "label" 435 | } 436 | ] 437 | } 438 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | #![warn(rust_2018_idioms)] 2 | ///! 📝📝📝📝📝📝 3 | use serde_derive::*; 4 | use std::borrow::Cow; 5 | use std::process::{Command, Stdio}; 6 | 7 | // From the gitmojis repo 8 | const GITMOJIS_JSON: &str = include_str!("./gitmojis.json"); 9 | 10 | #[derive(Debug, Deserialize)] 11 | struct GitmojisJson<'a> { 12 | gitmojis: Vec>, 13 | } 14 | 15 | #[derive(Debug, Deserialize)] 16 | struct Gitmoji<'a> { 17 | emoji: Cow<'a, str>, 18 | code: Cow<'a, str>, 19 | description: Cow<'a, str>, 20 | name: Cow<'a, str>, 21 | } 22 | 23 | fn main() -> Result<(), failure::Error> { 24 | use std::io::{Read, Write}; 25 | 26 | if let Err(_) = std::env::var("TMUX") { 27 | Err(failure::format_err!( 28 | "gitmoji-selector must be run inside tmux" 29 | ))? 30 | } 31 | 32 | let gitmojis: GitmojisJson<'_> = serde_json::from_str(GITMOJIS_JSON)?; 33 | let mut child_process = Command::new("fzf-tmux") 34 | .stdin(Stdio::piped()) 35 | .stdout(Stdio::piped()) 36 | .stderr(Stdio::piped()) 37 | .spawn()?; 38 | 39 | let mut stdin = child_process.stdin.take().expect("no access to fzf stdin"); 40 | for gitmoji in &gitmojis.gitmojis { 41 | write!( 42 | stdin, 43 | "{} - {} - {}\n", 44 | gitmoji.emoji, gitmoji.code, gitmoji.description 45 | )?; 46 | } 47 | 48 | child_process.wait()?; 49 | 50 | let mut stdout = child_process 51 | .stdout 52 | .take() 53 | .expect("no access to fzf stdout"); 54 | 55 | // Regex to split the line in space-separated groups. We are only interested in the first one 56 | // (the emoji). 57 | let emoji_regex = regex::Regex::new(r"[^ ]*")?; 58 | 59 | let mut stdout_string: String = String::with_capacity(300); 60 | stdout.read_to_string(&mut stdout_string)?; 61 | 62 | print!( 63 | "{}", 64 | emoji_regex 65 | .captures_iter(&stdout_string) 66 | // get the first captured match 67 | .next() 68 | // get the first capture group (there is only one) 69 | .and_then(|cap| cap.get(0)) 70 | .map(|m| m.as_str()) 71 | .unwrap_or("ø") 72 | ); 73 | 74 | Ok(()) 75 | } 76 | --------------------------------------------------------------------------------