summaryrefslogtreecommitdiff
path: root/.local/bin/fcode
blob: 2c8041d36ba3e7d6fa22ac541f7bc36b4c7f11d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

# fzf-unicode: get a list of emojis or unicode charecters using fzf
# place your charecter files in plain text in ~/.local/share/chars/*

if [ "$OPENFLAG" = 0 ]; then
	chosen="$(printf '%s\n' "$@" | cut -d\  -f1 | tr -d '\n')"
	printf "%s" "$chosen" | xclip -selection clipboard
	notify-send "'$chosen' copied to clipboard."
	exit
fi

[ -z "$FZF_HISTDIR" ] &&
	export FZF_HISTDIR="${XDG_STATE_HOME:-$HOME/.local/state}/fzf"
mkdir -pv "$FZF_HISTDIR"
export FZF_HIST="$FZF_HISTDIR/unicode_history"

cat ~/.local/share/chars/* |
	fzf -m --history="$FZF_HIST" \
		--header="Copy Emojis to Clipboard" --header-first \
		--preview 'printf "%s\n" {+} | cut -d\  -f1 | tr -d "\n"' \
		--preview-window=nohidden,up,1 \
		--bind 'ctrl-/:change-preview-window(down|up)' \
		--bind "enter:execute(echo {q} >> \"$FZF_HIST\"; OPENFLAG=0 \"$0\" {+})"