Skip to content

Instantly share code, notes, and snippets.

@tombh
Last active March 28, 2025 23:50
Show Gist options
  • Select an option

  • Save tombh/5d96587dabebff7e59d801a845acbf92 to your computer and use it in GitHub Desktop.

Select an option

Save tombh/5d96587dabebff7e59d801a845acbf92 to your computer and use it in GitHub Desktop.

Revisions

  1. tombh revised this gist Mar 28, 2025. 1 changed file with 5 additions and 9 deletions.
    14 changes: 5 additions & 9 deletions emoji.bash
    Original file line number Diff line number Diff line change
    @@ -4,24 +4,19 @@
    # Usage: `chmod a+x emoji.bash`, then run the script whenever you to pick emojis

    export EMOJI_CHAR_PATH="/tmp/unicode_result-$USER.txt"
    touch "$EMOJI_CHAR_PATH"

    function _unicode_search {
    local type=$1
    local char
    local args

    [ "$type" = "" ] && args=(
    -format '%(char l:auto)%(wide_padding) %(name)'
    -compact
    print all
    )
    [ "$type" = "emoji" ] && args=(
    args=(
    -format '%(emoji l:auto) %(name)'
    -compact
    emoji all
    )

    # `nix-env -iA nixpkgs.uni`
    char=$(uni "${args[@]}" | fzf | cut -d' ' -f1)
    echo -n "$char" >"$EMOJI_CHAR_PATH"
    echo -n "$char"
    @@ -42,9 +37,10 @@ function emoji_picker {
    -o "initial_window_height=15c" \
    -o "font_size=20" \
    bash -c \
    "_unicode_search emoji"
    "./emoji.bash _unicode_search"

    wtype "$(cat "$EMOJI_CHAR_PATH")"
    }

    emoji_picker
    subcommand=${1:-emoji_picker}
    "$subcommand"
  2. tombh revised this gist Mar 28, 2025. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions emoji.bash
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # Dependencies: `uni`, `wl-copy`, `kitty`, `wtype`, `fzf`
    # `uni` project: https://github.com/source-foundry/uni

    # Call `emoji_picker()` to use.
    # Usage: `chmod a+x emoji.bash`, then run the script whenever you to pick emojis

    export EMOJI_CHAR_PATH="/tmp/unicode_result-$USER.txt"

    @@ -45,4 +45,6 @@ function emoji_picker {
    "_unicode_search emoji"

    wtype "$(cat "$EMOJI_CHAR_PATH")"
    }
    }

    emoji_picker
  3. tombh revised this gist Mar 28, 2025. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions emoji.bash
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    # Dependencies: `uni`, `wl-copy`, `kitty`, `wtype`, `fzf`
    # `uni` project: https://github.com/source-foundry/uni

    # Call `emoji_picker()` to use.

  4. tombh revised this gist Mar 28, 2025. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions emoji.bash
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    # Dependencies: `uni`, `wl-copy`, `kitty`, `wtype`, `fzf`

    # Call `emoji_picker()` to use.

    export EMOJI_CHAR_PATH="/tmp/unicode_result-$USER.txt"

    function _unicode_search {
  5. tombh created this gist Mar 7, 2025.
    45 changes: 45 additions & 0 deletions emoji.bash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    # Dependencies: `uni`, `wl-copy`, `kitty`, `wtype`, `fzf`

    export EMOJI_CHAR_PATH="/tmp/unicode_result-$USER.txt"

    function _unicode_search {
    local type=$1
    local char
    local args

    [ "$type" = "" ] && args=(
    -format '%(char l:auto)%(wide_padding) %(name)'
    -compact
    print all
    )
    [ "$type" = "emoji" ] && args=(
    -format '%(emoji l:auto) %(name)'
    -compact
    emoji all
    )

    # `nix-env -iA nixpkgs.uni`
    char=$(uni "${args[@]}" | fzf | cut -d' ' -f1)
    echo -n "$char" >"$EMOJI_CHAR_PATH"
    echo -n "$char"
    }

    function unicode_search {
    local type=$1
    local char && char=$(_unicode_search "$type")
    echo "$char" | wl-copy --trim-newline
    echo "Copied $char to clipboard"
    }

    function emoji_picker {
    kitty \
    --title "Emoji Picker" \
    -o "remember_window_size=no" \
    -o "initial_window_width=45c" \
    -o "initial_window_height=15c" \
    -o "font_size=20" \
    bash -c \
    "_unicode_search emoji"

    wtype "$(cat "$EMOJI_CHAR_PATH")"
    }